1/* 2Language: Lisp 3Description: Generic lisp syntax 4Author: Vasily Polovnyov <vast@whiteants.net> 5*/ 6 7hljs.LANGUAGES.lisp = function(){ 8 var LISP_IDENT_RE = '[a-zA-Z_\\-\\+\\*\\/\\<\\=\\>\\&\\#][a-zA-Z0-9_\\-\\+\\*\\/\\<\\=\\>\\&\\#]*' 9 var LISP_SIMPLE_NUMBER_RE = '(\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s)(\\+|\\-)?\\d+)?' 10 return { 11 case_insensitive: true, 12 defaultMode: { 13 lexems: [LISP_IDENT_RE], 14 contains: ['literal', 'number', 'string', 'comment', 'quoted', 'list'], 15 illegal: '[^\\s]' 16 }, 17 modes: [ 18 hljs.QUOTE_STRING_MODE, 19 { 20 className: 'number', 21 begin: LISP_SIMPLE_NUMBER_RE, end: '^' 22 }, 23 { 24 className: 'number', 25 begin: '#b[0-1]+(/[0-1]+)?', end: '^' 26 }, 27 { 28 className: 'number', 29 begin: '#o[0-7]+(/[0-7]+)?', end: '^' 30 }, 31 { 32 className: 'number', 33 begin: '#x[0-9a-f]+(/[0-9a-f]+)?', end: '^' 34 }, 35 { 36 className: 'number', 37 begin: '#c\\(' + LISP_SIMPLE_NUMBER_RE + ' +' + LISP_SIMPLE_NUMBER_RE, end: '\\)' 38 }, 39 { 40 className: 'comment', 41 begin: ';', end: '$' 42 }, 43 { 44 className: 'quoted', 45 begin: '[\'`]\\(', end: '\\)', 46 contains: ['number', 'string', 'variable', 'keyword', 'quoted_list'] 47 }, 48 { 49 className: 'quoted', 50 begin: '\\(quote ', end: '\\)', 51 contains: ['number', 'string', 'variable', 'keyword', 'quoted_list'], 52 lexems: [LISP_IDENT_RE], 53 keywords: {'title': {'quote': 1}} 54 }, 55 { 56 className: 'quoted_list', 57 begin: '\\(', end: '\\)', 58 contains: ['quoted_list', 'literal', 'number', 'string'] 59 }, 60 { 61 className: 'list', 62 begin: '\\(', end: '\\)', 63 contains: ['title','body'] 64 }, 65 { 66 className: 'title', 67 begin: LISP_IDENT_RE, end: '^', 68 endsWithParent: true 69 }, 70 { 71 className: 'body', 72 begin: '^', endsWithParent: true, excludeEnd: true, 73 contains: ['quoted', 'list', 'literal', 'number', 'string', 'comment', 'variable', 'keyword'] 74 }, 75 { 76 className: 'keyword', 77 begin: '[:&]' + LISP_IDENT_RE, end: '^' 78 }, 79 { 80 className: 'variable', 81 begin: '\\*', end: '\\*' 82 }, 83 { 84 className: 'literal', 85 begin: '\\b(t{1}|nil)\\b', end: '^' 86 } 87 ] 88 }; 89}(); 90