workaround for unsupported regex features

This commit is contained in:
nightwing 2013-04-05 23:59:34 +04:00
commit 5d63adb2a7
4 changed files with 38 additions and 109 deletions

View file

@ -47,29 +47,19 @@ var ForthHighlightRules = function() {
this.$rules = { start: [ { include: '#forth' } ], this.$rules = { start: [ { include: '#forth' } ],
'#comment': '#comment':
[ { token: 'comment.line.double-dash.forth', [ { token: 'comment.line.double-dash.forth',
regex: '(?<=^|\\s)--\\s.*$', regex: '(?:^|\\s)--\\s.*$',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(--\\s.*$)',
comment: 'line comments for iForth' }, comment: 'line comments for iForth' },
{ token: 'comment.line.backslash.forth', { token: 'comment.line.backslash.forth',
regex: '(?<=^|\\s)\\\\[\\s\\S]*$', regex: '(?:^|\\s)\\\\[\\s\\S]*$',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(\\\\[\\s\\S]*$)',
comment: 'ANSI line comment' }, comment: 'ANSI line comment' },
{ token: 'comment.line.backslash-g.forth', { token: 'comment.line.backslash-g.forth',
regex: '(?<=^|\\s)\\\\[Gg] .*$', regex: '(?:^|\\s)\\\\[Gg] .*$',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(\\\\[Gg] .*$)',
comment: 'gForth line comment' }, comment: 'gForth line comment' },
{ token: 'comment.block.forth', { token: 'comment.block.forth',
regex: '(?<=^|\\s)\\(\\*(?=\\s)', regex: '(?:^|\\s)\\(\\*(?=\\s|$)',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(\\(\\*)(?=\\s)',
push: push:
[ { token: 'comment.block.forth', [ { token: 'comment.block.forth',
regex: '(?<=^|\\s)\\*\\)(?=\\s)', regex: '(?:^|\\s)\\*\\)(?=\\s|$)',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(\\*\\))(?=\\s)',
next: 'pop' }, next: 'pop' },
{ defaultToken: 'comment.block.forth' } ], { defaultToken: 'comment.block.forth' } ],
comment: 'multiline comments for iForth' }, comment: 'multiline comments for iForth' },
@ -84,24 +74,16 @@ var ForthHighlightRules = function() {
{ defaultToken: 'comment.block.documentation.forth' } ], { defaultToken: 'comment.block.documentation.forth' } ],
comment: 'documentation comments for iForth' }, comment: 'documentation comments for iForth' },
{ token: 'comment.line.parentheses.forth', { token: 'comment.line.parentheses.forth',
regex: '(?<=^|\\s)\\.?\\( [^)]*\\)', regex: '(?:^|\\s)\\.?\\( [^)]*\\)',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(\\.?\\( [^)]*\\))',
comment: 'ANSI line comment' } ], comment: 'ANSI line comment' } ],
'#constant': '#constant':
[ { token: 'constant.language.forth', [ { token: 'constant.language.forth',
regex: '(?<=^|\\s)(?:TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s)', regex: '(?:^|\\s)(?:TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?i:(?<=^|\\s)(TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s))' },
{ token: 'constant.numeric.forth', { token: 'constant.numeric.forth',
regex: '(?<=^|\\s)[$#%]?[-+]?[0-9]+(?:\\.[0-9]*e-?[0-9]+|\\.?[0-9a-fA-F]*)(?=\\s)', regex: '(?:^|\\s)[$#%]?[-+]?[0-9]+(?:\\.[0-9]*e-?[0-9]+|\\.?[0-9a-fA-F]*)(?=\\s|$)',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)([$#%]?[-+]?[0-9]+(\\.[0-9]*e(-?[0-9]+)|\\.?[0-9a-fA-F]*))(?=\\s)' },
{ token: 'constant.character.forth', { token: 'constant.character.forth',
regex: '(?<=^|\\s)(?:[&^]\\S|(?:"|\')\\S(?:"|\'))(?=\\s)', regex: '(?:^|\\s)(?:[&^]\\S|(?:"|\')\\S(?:"|\'))(?=\\s|$)',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(([&^]\\S)|(("|\')\\S("|\')))(?=\\s)' } ],
'#forth': '#forth':
[ { include: '#constant' }, [ { include: '#constant' },
{ include: '#comment' }, { include: '#comment' },
@ -112,64 +94,45 @@ var ForthHighlightRules = function() {
{ include: '#word-def' } ], { include: '#word-def' } ],
'#storage': '#storage':
[ { token: 'storage.type.forth', [ { token: 'storage.type.forth',
regex: '(?<=^|\\s)(?:2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY)(?=\\s)', regex: '(?:^|\\s)(?:2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY))(?=\\s)' } ],
'#string': '#string':
[ { token: 'string.quoted.double.forth', [ { token: 'string.quoted.double.forth',
regex: '(?:(?<=ABORT" )|(?<=BREAK" )|(?<=\\." )|C" |0"|S\\\\?" )[^"]+"', regex: '(ABORT" |BREAK" |\\." |C" |0"|S\\\\?" )([^"]+")',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?i:((?<=ABORT" )|(?<=BREAK" )|(?<=\\." )|(C" )|(0")|(S\\\\?" )))[^"]+"' },
{ token: 'string.unquoted.forth', { token: 'string.unquoted.forth',
regex: '(?:(?<=INCLUDE)|(?<=NEEDS)|(?<=REQUIRE)|(?<=USE))[ ]\\S+(?=\\s)', regex: '(?:INCLUDE|NEEDS|REQUIRE|USE)[ ]\\S+(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?i:((?<=INCLUDE)|(?<=NEEDS)|(?<=REQUIRE)|(?<=USE)))[ ]\\S+(?=\\s)' } ],
'#variable': '#variable':
[ { token: 'variable.language.forth', [ { token: 'variable.language.forth',
regex: '\\b(?:I|J)\\b', regex: '\\b(?:I|J)\\b',
caseInsensitive: true } ], caseInsensitive: true } ],
'#word': '#word':
[ { token: 'keyword.control.immediate.forth', [ { token: 'keyword.control.immediate.forth',
regex: '(?<=^|\\s)\\[(?:\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE)\\](?=\\s)', regex: '(?:^|\\s)\\[(?:\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE)\\](?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)\\[(?i:(\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE))\\](?=\\s)' },
{ token: 'keyword.other.immediate.forth', { token: 'keyword.other.immediate.forth',
regex: '(?<=^|\\s)(?:COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|])(?=\\s)', regex: '(?:^|\\s)(?:COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|])(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|]))(?=\\s)' },
{ token: 'keyword.control.compile-only.forth', { token: 'keyword.control.compile-only.forth',
regex: '(?<=^|\\s)(?:-DO|\\-LOOP|\\?DO|\\?LEAVE|\\+DO|\\+LOOP|ABORT\\"|AGAIN|AHEAD|BEGIN|CASE|DO|ELSE|ENDCASE|ENDIF|ENDOF|ENDTRY\\-IFERROR|ENDTRY|FOR|IF|IFERROR|LEAVE|LOOP|NEXT|RECOVER|REPEAT|RESTORE|THEN|TRY|U\\-DO|U\\+DO|UNTIL|WHILE)(?=\\s)', regex: '(?:^|\\s)(?:-DO|\\-LOOP|\\?DO|\\?LEAVE|\\+DO|\\+LOOP|ABORT\\"|AGAIN|AHEAD|BEGIN|CASE|DO|ELSE|ENDCASE|ENDIF|ENDOF|ENDTRY\\-IFERROR|ENDTRY|FOR|IF|IFERROR|LEAVE|LOOP|NEXT|RECOVER|REPEAT|RESTORE|THEN|TRY|U\\-DO|U\\+DO|UNTIL|WHILE)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(-DO|\\-LOOP|\\?DO|\\?LEAVE|\\+DO|\\+LOOP|ABORT\\"|AGAIN|AHEAD|BEGIN|CASE|DO|ELSE|ENDCASE|ENDIF|ENDOF|ENDTRY\\-IFERROR|ENDTRY|FOR|IF|IFERROR|LEAVE|LOOP|NEXT|RECOVER|REPEAT|RESTORE|THEN|TRY|U\\-DO|U\\+DO|UNTIL|WHILE))(?=\\s)' },
{ token: 'keyword.other.compile-only.forth', { token: 'keyword.other.compile-only.forth',
regex: '(?<=^|\\s)(?:\\?DUP-0=-IF|\\?DUP-IF|\\)|\\[|\\[\'\\]|\\[CHAR\\]|\\[COMPILE\\]|\\[IS\\]|\\[TO\\]|<COMPILATION|<INTERPRETATION|ASSERT\\(|ASSERT0\\(|ASSERT1\\(|ASSERT2\\(|ASSERT3\\(|COMPILATION>|DEFERS|DOES>|INTERPRETATION>|OF|POSTPONE)(?=\\s)', regex: '(?:^|\\s)(?:\\?DUP-0=-IF|\\?DUP-IF|\\)|\\[|\\[\'\\]|\\[CHAR\\]|\\[COMPILE\\]|\\[IS\\]|\\[TO\\]|<COMPILATION|<INTERPRETATION|ASSERT\\(|ASSERT0\\(|ASSERT1\\(|ASSERT2\\(|ASSERT3\\(|COMPILATION>|DEFERS|DOES>|INTERPRETATION>|OF|POSTPONE)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(\\?DUP-0=-IF|\\?DUP-IF|\\)|\\[|\\[\'\\]|\\[CHAR\\]|\\[COMPILE\\]|\\[IS\\]|\\[TO\\]|<COMPILATION|<INTERPRETATION|ASSERT\\(|ASSERT0\\(|ASSERT1\\(|ASSERT2\\(|ASSERT3\\(|COMPILATION>|DEFERS|DOES>|INTERPRETATION>|OF|POSTPONE))(?=\\s)' },
{ token: 'keyword.other.non-immediate.forth', { token: 'keyword.other.non-immediate.forth',
regex: '(?<=^|\\s)(?:\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE)(?=\\s)', regex: '(?:^|\\s)(?:\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE))(?=\\s)' },
{ token: 'keyword.other.warning.forth', { token: 'keyword.other.warning.forth',
regex: '(?<=^|\\s)(?:~~|BREAK:|BREAK"|DBG)(?=\\s)', regex: '(?:^|\\s)(?:~~|BREAK:|BREAK"|DBG)(?=\\s|$)',
caseInsensitive: true, caseInsensitive: true,
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=^|\\s)(?i:(~~|BREAK:|BREAK"|DBG))(?=\\s)' } ],
'#word-def': '#word-def':
[ { token: [ { token:
[ 'keyword.other.compile-only.forth', [ 'keyword.other.compile-only.forth',
'keyword.other.compile-only.forth',
'meta.block.forth', 'meta.block.forth',
'entity.name.function.forth', 'entity.name.function.forth' ],
'meta.block.forth', regex: '(:NONAME)|(^:|\\s:)(\\s)(\\S+)(?=\\s|$)',
'keyword.other.compile-only.forth' ],
regex: '(^:|\\s:)(\\s)(\\S+)(\\s)|(:NONAME)',
caseInsensitive: true, caseInsensitive: true,
push: push:
[ { token: 'keyword.other.compile-only.forth', [ { token: 'keyword.other.compile-only.forth',

View file

@ -638,12 +638,7 @@ var HTMLTwigHighlightRules = function() {
'punctuation.separator.key-value.html' ], 'punctuation.separator.key-value.html' ],
regex: '\\b(id)\\b(\\s*)(=)', regex: '\\b(id)\\b(\\s*)(=)',
push: push:
[ { token: [], [{ token: 'punctuation.definition.string.begin.html',
regex: '(?<=\'|")',
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<=\'|")',
next: 'pop' },
{ token: 'punctuation.definition.string.begin.html',
regex: '"', regex: '"',
push: push:
[ { token: 'punctuation.definition.string.end.html', [ { token: 'punctuation.definition.string.end.html',
@ -661,7 +656,8 @@ var HTMLTwigHighlightRules = function() {
{ include: '#embedded-code' }, { include: '#embedded-code' },
{ include: '#entities' }, { include: '#entities' },
{ defaultToken: 'string.quoted.single.html' } ] }, { defaultToken: 'string.quoted.single.html' } ] },
{ defaultToken: 'meta.attribute-with-value.id.html' } ] } ], { defaultToken: 'meta.attribute-with-value.id.html' },
{ token: '', regex: '', next: 'pop' } ] } ],
'#tag-stuff': '#tag-stuff':
[ { include: '#tag-id-attribute' }, [ { include: '#tag-id-attribute' },
{ include: '#tag-generic-attribute' }, { include: '#tag-generic-attribute' },

View file

@ -55,8 +55,8 @@ var Mode = function() {
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);
(function() { (function() {
this.lineCommentStart = "//"; this.lineCommentStart = "#";
this.blockComment = {start: "/*", end: "*/"}; this.blockComment = "";
// Extra logic goes here. // Extra logic goes here.
}).call(Mode.prototype); }).call(Mode.prototype);

View file

@ -60,32 +60,15 @@ var JuliaHighlightRules = function() {
[ { token: [ { token:
[ 'punctuation.definition.comment.julia', [ 'punctuation.definition.comment.julia',
'comment.line.number-sign.julia' ], 'comment.line.number-sign.julia' ],
regex: '(?<!\\$)(#)(?!\\{)(.*$)', regex: '(#)(?!\\{)(.*$)'} ],
TODO: 'FIXME: regexp doesn\'t have js equivalent',
originalRegex: '(?<!\\$)(#)(?!\\{).*$\\n?' } ],
'#function_call': '#function_call':
[ { todo: [ { token: [ 'support.function.julia', 'text' ],
{ token: [ 'support.function.julia', 'text' ], regex: '([a-zA-Z0-9_]+!?)(\\w*\\()'} ],
regex: '([a-zA-Z0-9_]+!?)(\\w*\\()',
push:
[ { token: [ 'text', 'keyword.operator.transposed-func.julia' ],
regex: '(\\))((?:(?:\'|\\.\')*\\.?\')?)',
next: 'pop' },
{ include: '$self' } ] } } ],
'#function_decl': '#function_decl':
[ { todo: [ { token: [ 'keyword.other.julia', 'meta.function.julia',
{ token: 'entity.name.function.julia', 'meta.function.julia','text' ],
[ 'keyword.other.julia', regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)(\\w*)([(\\\\{])'} ],
'meta.function.julia', '#keyword':
'entity.name.function.julia',
'meta.function.julia',
'meta.function.julia' ],
regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)(\\w*)([(\\\\{])',
push:
[ { token: 'meta.function.julia', regex: '[)\\\\}]', next: 'pop' },
{ include: '$self' },
{ defaultToken: 'meta.function.julia' } ] } } ],
'#keyword':
[ { token: 'keyword.other.julia', [ { token: 'keyword.other.julia',
regex: '\\b(?:function|type|immutable|macro|quote|abstract|bitstype|typealias|module|baremodule|new)\\b' }, regex: '\\b(?:function|type|immutable|macro|quote|abstract|bitstype|typealias|module|baremodule|new)\\b' },
{ token: 'keyword.control.julia', { token: 'keyword.control.julia',
@ -114,26 +97,13 @@ var JuliaHighlightRules = function() {
{ token: 'keyword.operator.dots.julia', { token: 'keyword.operator.dots.julia',
regex: '\\.(?=[a-zA-Z])|\\.\\.+' }, regex: '\\.(?=[a-zA-Z])|\\.\\.+' },
{ token: 'keyword.operator.interpolation.julia', { token: 'keyword.operator.interpolation.julia',
regex: '\\$(?=.+)' }, regex: '\\$#?(?=.)' },
{ token: [ 'variable', 'keyword.operator.transposed-variable.julia' ], { token: [ 'variable', 'keyword.operator.transposed-variable.julia' ],
regex: '(\\w+)((?:\'|\\.\')*\\.?\')' }, regex: '(\\w+)((?:\'|\\.\')*\\.?\')' },
{ todo: { token: 'text',
{ token: 'test', regex: '\\[|\\('},
regex: '\\[', { token: [ 'text', 'keyword.operator.transposed-matrix.julia' ],
push: regex: "([\\]\\)])((?:'|\\.')*\\.?')"} ],
[ { token: [ 'test', 'keyword.operator.transposed-matrix.julia' ],
regex: '(\\])((?:\'|\\.\')*\\.?\')',
next: 'pop' },
{ include: '$self' },
{ defaultToken: 'test' } ] } },
{ todo:
{ token: 'text',
regex: '\\(',
push:
[ { token: [ 'text', 'keyword.operator.transposed-parens.julia' ],
regex: '(\\))((?:\'|\\.\')*\\.?\')',
next: 'pop' },
{ include: '$self' } ] } } ],
'#string': '#string':
[ { token: 'punctuation.definition.string.begin.julia', [ { token: 'punctuation.definition.string.begin.julia',
regex: '\'', regex: '\'',