Created
June 21, 2016 18:20
-
-
Save jtenner/15e57fb94a7b196e7299a0c86714bc11 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
Script "Entry Point" | |
= code:(TemplateString / DoubleQuotedString / SingleQuotedString / Numeric | |
/ Keyword / Identifier / Comment / .)* { | |
return code.join('') | |
} | |
Comment "Comment" | |
= comment:("//" [^\n]*) { | |
return '<span class="comment">' + [].concat.apply([], comment).join('') +'</span>' | |
} | |
Keyword "Keyword" | |
= keyword:("animation"/"await"/"wait"/"pause"/ | |
"bg"/"button"/"entity"/"character"/ | |
"clear"/"if"/"then"/"else"/"end"/ | |
"while"/"expose"/"hide"/"jump"/ | |
"set"/"play"/"stop"/"return"/ | |
"sfx"/"bgm"/"show"/"hide"/"textcolor"/ | |
"alpha"/"run"/"behind"/"neutral"/ | |
"hover"/"mousedown"/"center"/ | |
"centerx"/"centery"/"skewx"/"skewy"/ | |
"color"/ "cursor"/ "defmood"/ "mood"/ | |
"feels"/ "feeling"/ "feel"/ "use"/ "ease"/ | |
"on"/ "move"/ "at"/ "name"/ "rotateto"/ "rotate"/ | |
"scale"/ "size"/ "shearx"/ "sheary"/ "skewx"/ "skewy"/ | |
"zindex"/ "label"/ "scene") { | |
return '<span class="keyword">' + keyword +'</span>' | |
} | |
Numeric "Numeric" | |
= num:[0-9\.]+ unit:("\%"/ "px"/ "vw"/ "vh"/ "aw"/ "ah"/ "deg"/ "rad"/ "s"/ "ms")? { | |
return '<span class="numeric">' + num.join('') + (unit || "") + '</span>'; | |
} | |
Identifier "Identifier" | |
= first:[a-zA-Z_] tail:[a-zA-Z0-9_]* { | |
return '<span class="identifier">' + first + tail.join('') + '</span>'; | |
} | |
SingleQuotedString "Single Quoted String" | |
= val:("'" (EscapedSingleQuote / NotSingleQuote)* "'") | |
{ | |
return '<span class="string">' + [].concat.apply([], val).join('') + '</span>'; | |
} | |
EscapedSingleQuote | |
= "\\'" | |
NotSingleQuote | |
= [^'] | |
DoubleQuotedString "Double Quoted String" | |
= val: ('"' (EscapedDoubleQuote / NotDoubleQuote)* '"') | |
{ | |
return '<span class="string">' + [].concat.apply([], val).join('') + '</span>'; | |
} | |
EscapedDoubleQuote | |
= '\\"' | |
NotDoubleQuote | |
= [^"] | |
TemplateString "Template String" | |
= val: ('`' (TemplateExpression / EscapedTickQuote / NotTickQuote)* '`') { | |
return '<span class="string">' + [].concat.apply([], val).join('') + '</span>'; | |
} | |
EscapedTickQuote | |
= '\\`' | |
NotTickQuote | |
= [^`] | |
TemplateExpression "Template Expression" | |
= val:("${" [^}]* "}") { | |
return '<span class="template">' + [].concat.apply([], val).join('') + '</span>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment