Skip to content

Instantly share code, notes, and snippets.

@imjching
Created February 17, 2017 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjching/ca2db329305dedf2cb8e2a5a3f97c648 to your computer and use it in GitHub Desktop.
Save imjching/ca2db329305dedf2cb8e2a5a3f97c648 to your computer and use it in GitHub Desktop.
ScriptLexer.g4
// Name our lexer (the name must match the filename)
lexer grammar ScriptLexer;
// Define string values - either unquoted or quoted
STRING : ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'@')+ |
('"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"') ;
// Skip all spaces, tabs, newlines
WS : [ \t\r\n]+ -> skip ;
// Skip comments
LINE_COMMENT : '//' ~[\r\n]* '\r'? '\n' -> skip ;
// Define punctuations
LPAREN : '<' ;
RPAREN : '>' ;
EQUALS : '=' ;
SEMICO : ';' ;
ASSIGN : ':=' ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment