2024-08-02 20:03:49 +00:00
|
|
|
<lexer>
|
|
|
|
<config>
|
|
|
|
<name>ChaiScript</name>
|
|
|
|
<alias>chai</alias>
|
|
|
|
<alias>chaiscript</alias>
|
|
|
|
<filename>*.chai</filename>
|
|
|
|
<mime_type>text/x-chaiscript</mime_type>
|
|
|
|
<mime_type>application/x-chaiscript</mime_type>
|
|
|
|
<dot_all>true</dot_all>
|
|
|
|
</config>
|
|
|
|
<rules>
|
|
|
|
<state name="dqstring">
|
|
|
|
<rule pattern="\$\{[^"}]+?\}">
|
|
|
|
<token type="LiteralStringInterpol"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="\$">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="\\\\">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="\\"">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[^\\"$]+">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern=""">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
<pop depth="1"/>
|
|
|
|
</rule>
|
|
|
|
</state>
|
|
|
|
<state name="commentsandwhitespace">
|
|
|
|
<rule pattern="\s+">
|
|
|
|
<token type="Text"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="//.*?\n">
|
|
|
|
<token type="CommentSingle"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="/\*.*?\*/">
|
|
|
|
<token type="CommentMultiline"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="^\#.*?\n">
|
|
|
|
<token type="CommentSingle"/>
|
|
|
|
</rule>
|
|
|
|
</state>
|
|
|
|
<state name="slashstartsregex">
|
|
|
|
<rule>
|
|
|
|
<include state="commentsandwhitespace"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/([gim]+\b|\B)">
|
|
|
|
<token type="LiteralStringRegex"/>
|
|
|
|
<pop depth="1"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(?=/)">
|
|
|
|
<token type="Text"/>
|
|
|
|
<push state="#pop" state="badregex"/>
|
|
|
|
</rule>
|
|
|
|
<rule>
|
|
|
|
<pop depth="1"/>
|
|
|
|
</rule>
|
|
|
|
</state>
|
|
|
|
<state name="badregex">
|
|
|
|
<rule pattern="\n">
|
|
|
|
<token type="Text"/>
|
|
|
|
<pop depth="1"/>
|
|
|
|
</rule>
|
|
|
|
</state>
|
|
|
|
<state name="root">
|
|
|
|
<rule>
|
|
|
|
<include state="commentsandwhitespace"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="\n">
|
|
|
|
<token type="Text"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[^\S\n]+">
|
|
|
|
<token type="Text"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?">
|
|
|
|
<token type="Operator"/>
|
|
|
|
<push state="slashstartsregex"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[{(\[;,]">
|
|
|
|
<token type="Punctuation"/>
|
|
|
|
<push state="slashstartsregex"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[})\].]">
|
|
|
|
<token type="Punctuation"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[=+\-*/]">
|
|
|
|
<token type="Operator"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(for|in|while|do|break|return|continue|if|else|throw|try|catch)\b">
|
|
|
|
<token type="Keyword"/>
|
|
|
|
<push state="slashstartsregex"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(var)\b">
|
|
|
|
<token type="KeywordDeclaration"/>
|
|
|
|
<push state="slashstartsregex"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(attr|def|fun)\b">
|
|
|
|
<token type="KeywordReserved"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(true|false)\b">
|
|
|
|
<token type="KeywordConstant"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="(eval|throw)\b">
|
|
|
|
<token type="NameBuiltin"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="`\S+`">
|
|
|
|
<token type="NameBuiltin"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[$a-zA-Z_]\w*">
|
|
|
|
<token type="NameOther"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?">
|
|
|
|
<token type="LiteralNumberFloat"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="0x[0-9a-fA-F]+">
|
|
|
|
<token type="LiteralNumberHex"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="[0-9]+">
|
|
|
|
<token type="LiteralNumberInteger"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern=""">
|
|
|
|
<token type="LiteralStringDouble"/>
|
|
|
|
<push state="dqstring"/>
|
|
|
|
</rule>
|
|
|
|
<rule pattern="'(\\\\|\\'|[^'])*'">
|
|
|
|
<token type="LiteralStringSingle"/>
|
|
|
|
</rule>
|
|
|
|
</state>
|
|
|
|
</rules>
|
2024-08-26 23:18:28 +00:00
|
|
|
</lexer>
|