Created
October 20, 2013 21:14
-
-
Save arcanis/7075437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( 'ace/mode/pegjs', [ | |
'ace/lib/oop', | |
'ace/mode/text_highlight_rules', | |
'ace/mode/javascript_highlight_rules' | |
], function ( oop, textHighlightRules, javascriptHighlightRules ) { | |
'use strict'; | |
var TextHighlightRules = textHighlightRules.TextHighlightRules; | |
var JavaScriptHighlightRules = javascriptHighlightRules.JavaScriptHighlightRules; | |
var pegjsHighlightRules = function ( ) { | |
this.$rules = { | |
'start' : [ { | |
token : 'constant.language', | |
regex : '[a-z][a-zA-Z]+' | |
}, { | |
token : 'keyword.operator', | |
regex : '[=/]', | |
next : 'peg-rule' | |
} ], | |
'peg-rule' : [ { | |
token : 'string', | |
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' | |
}, { | |
token : 'string', | |
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" | |
}, { | |
token : 'keyword.operator', | |
regex : '^\\S*(?=[=/{(]|$)', | |
next : 'wait' | |
}, { | |
token : 'variable', | |
regex : '[a-z][a-zA-Z]+:' | |
}, { | |
token : 'identifier', | |
regex : '[a-z][a-zA-Z]+' | |
}, { | |
token : 'string', | |
regex : '\\[(?:(?:\\\\.)|(?:[^\\]\\\\]))*?\\]' | |
}, { | |
token : 'keyword.operator', | |
regex : '[+?*()/]' | |
}, { | |
token : 'keyword.operator', | |
regex : '{', | |
next : 'js-start' | |
} ] | |
}; | |
for ( var i in this.$rules ) { | |
this.$rules[ i ].unshift( { | |
token : 'comment', | |
regex : '/\\*', | |
next : 'comment' | |
} ); | |
} | |
this.$rules.comment = [ { | |
token : 'comment', | |
regex : '\\*/', | |
next : 'start' | |
}, { | |
token : 'comment', | |
regex : '.' | |
} ]; | |
this.embedRules( JavaScriptHighlightRules, 'js-', [ | |
{ token : 'keyword', regex : '}', next : 'start' } | |
] ); | |
}; | |
oop.inherits( pegjsHighlightRules, TextHighlightRules ); | |
return { pegjsHighlightRules : pegjsHighlightRules }; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment