Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clean up lexer rules

  • Loading branch information...
commit 8d7d68355e3132cbc7dd5750eb206cc6cfa09698 1 parent 350b4ca
Zach Carter zaach authored
Showing with 104 additions and 110 deletions.
  1. +104 −110 lib/lexer.l
214 lib/lexer.l
View
@@ -8,16 +8,16 @@ RCLASS "["({BSL}|[^\\\]])*"]"
%%
-";"\s+/("++"|"--") {return ';'}
-\n(\s|\n)*/("++"|"--") {return ';'}
-\n(\s|\n)* %{ if(yy.ASI){ yy.ASI=false; return ';';} else yy.lineBreak = true; %}
-\s+ {yy.ASI=false; /* skip whitespace */}
-"//".* {/* skip comment */}
-"#".* {/* skip comment */}
-"/*"(.|\n)*?"*/" {yy.ASI=false; /* skip comment */}
+";"\s+/("++"|"--") return ';'
+\n(\s|\n)*/("++"|"--") return ';'
+\n(\s|\n)* if (yy.ASI) { yy.ASI=false; return ';';} else yy.lineBreak = true;
+\s+ yy.ASI=false; /* skip whitespace */
+"//".* /* skip comment */
+"#".* /* skip comment */
+"/*"(.|\n)*?"*/" yy.ASI=false; /* skip comment */
-"0"[xX][a-fA-F0-9]+/([^a-zA-Z$_]{0,1}) {return 'NUMBER';}
-([1-9][0-9]+|[0-9]){frac}?{exp}?/([^a-zA-Z$_]{0,1}) {return 'NUMBER';}
+"0"[xX][a-fA-F0-9]+/([^a-zA-Z$_]{0,1}) return 'NUMBER';
+([1-9][0-9]+|[0-9]){frac}?{exp}?/([^a-zA-Z$_]{0,1}) return 'NUMBER';
'"'("\\x"[a-fA-F0-9]{2}|"\\u"[a-fA-F0-9]{4}|"\\"[^xu]|[^"{esc}\n])*'"' {yytext = yytext.substr(1,yyleng-2); return 'STRING';}
"'"("\\"['bfvnrt/{esc}]|"\\u"[a-fA-F0-9]{4}|[^'{esc}])*"'" {yytext = yytext.substr(1,yyleng-2); return 'STRING';}
@@ -51,107 +51,101 @@ RCLASS "["({BSL}|[^\\\]])*"]"
%}
-"{" %{ return 'OPENBRACE' %}
-"}" %{ return 'CLOSEBRACE' %}
-"[" {return '['}
-"]" {return ']'}
-"(" {return '('}
-")" {return ')'}
-"," {return ','}
-"." {return '.'}
-";" {yy.ASI = false; return ';'}
-":" {return ':'}
-"+=" {return 'PLUSEQUAL'}
-"-=" {return 'MINUSEQUAL'}
-"*=" {return 'MULTEQUAL'}
-"%=" {return 'MODEQUAL'}
-"&=" {return 'ANDEQUAL'}
-"|=" {return 'OREQUAL'}
-"^=" {return 'XOREQUAL'}
-"<<=" {return 'LSHIFTEQUAL'}
-">>=" {return 'RSHIFTEQUAL'}
-">>>=" {return 'URSHIFTEQUAL'}
-"/=" {return 'DIVEQUAL'}
-"<=" {return 'LE'}
-">=" {return 'GE'}
-"===" {return 'STREQ'}
-"!==" {return 'STRNEQ'}
-"==" {return 'EQEQ'}
-"!=" {return 'NE'}
-"&&" {return 'AND'}
-"||" {return 'OR'}
-"++" {return 'PLUSPLUS'}
-"--" {return 'MINUSMINUS'}
-">>>" {return 'URSHIFT'}
-"<<" {return 'LSHIFT'}
-">>" {return 'RSHIFT'}
-"+" {return '+'}
-"-" {return '-'}
-"*" {return '*'}
-"%" {return '%'}
-"<" {return '<'}
-">" {return '>'}
-"&" {return '&'}
-"|" {return '|'}
-"^" {return '^'}
-"!" {return '!'}
-"~" {return '~'}
-"?" {return '?'}
-"/" {return '/'}
-"=" {return '='}
-
-"break" {yy.ASI = true; return 'BREAK'}
-"case" {return 'CASE'}
-"continue" {yy.ASI = true; return 'CONTINUE'}
-"debugger" {return 'DEBUGGER'}
-"default" {return 'DEFAULT'}
-"delete" {return 'DELETETOKEN'}
-"do" {return 'DO'}
-"else" {return 'ELSE'}
-"finally" {return 'FINALLY'}
-"for" {return 'FOR'}
-"function" {return 'FUNCTION'}
-"if" {return 'IF'}
-"in" {return 'INTOKEN'}
-"instanceof" {return 'INSTANCEOF'}
-"new" {return 'NEW'}
-"return" {yy.ASI = true; return 'RETURN'}
-"switch" {return 'SWITCH'}
-"try" {return 'TRY'}
-"catch" {return 'CATCH'}
-"throw" {yy.ASI = true; return 'THROW'}
-"typeof" {return 'TYPEOF'}
-"var" {return 'VAR'}
-"void" {return 'VOIDTOKEN'}
-"while" {return 'WHILE'}
-"with" {return 'WITH'}
-
-"class" {return 'WITH'}
-"const" {return 'CONSTTOKEN'}
-"enum" {return 'ENUM'}
-"export" {return 'EXPORT'}
-"extends" {return 'EXTENDS'}
-"import" {return 'IMPORT'}
-"super" {return 'SUPERTOKEN'}
-
-"implements" {return 'IMPLEMENTS'}
-"interface" {return 'INTERFACE'}
-"let" {return 'LET'}
-"package" {return 'PACKAGE'}
-"private" {return 'PRIVATE'}
-"protected" {return 'PROTECTED'}
-"public" {return 'PUBLIC'}
-"static" {return 'STATIC'}
-"yield" {return 'YIELD'}
-
-"this" {return 'THISTOKEN'}
-"true" {return 'TRUETOKEN'}
-"false" {return 'FALSETOKEN'}
-"null" {return 'NULLTOKEN'}
-
-({IDS})+({IDS}|[0-9])* {return 'IDENT';}
-
-. {return 'INVALID'}
+"{" return 'OPENBRACE'
+"}" return 'CLOSEBRACE'
+"[" return '['
+"]" return ']'
+"(" return '('
+")" return ')'
+"," return ','
+"." return '.'
+";" yy.ASI = false; return ';'
+":" return ':'
+"+=" return 'PLUSEQUAL'
+"-=" return 'MINUSEQUAL'
+"*=" return 'MULTEQUAL'
+"%=" return 'MODEQUAL'
+"&=" return 'ANDEQUAL'
+"|=" return 'OREQUAL'
+"^=" return 'XOREQUAL'
+"<<=" return 'LSHIFTEQUAL'
+">>=" return 'RSHIFTEQUAL'
+">>>=" return 'URSHIFTEQUAL'
+"/=" return 'DIVEQUAL'
+"<=" return 'LE'
+">=" return 'GE'
+"===" return 'STREQ'
+"!==" return 'STRNEQ'
+"==" return 'EQEQ'
+"!=" return 'NE'
+"&&" return 'AND'
+"||" return 'OR'
+"++" return 'PLUSPLUS'
+"--" return 'MINUSMINUS'
+">>>" return 'URSHIFT'
+"<<" return 'LSHIFT'
+">>" return 'RSHIFT'
+"+" return '+'
+"-" return '-'
+"*" return '*'
+"%" return '%'
+"<" return '<'
+">" return '>'
+"&" return '&'
+"|" return '|'
+"^" return '^'
+"!" return '!'
+"~" return '~'
+"?" return '?'
+"/" return '/'
+"=" return '='
+"break" yy.ASI = true; return 'BREAK'
+"case" return 'CASE'
+"continue" yy.ASI = true; return 'CONTINUE'
+"debugger" return 'DEBUGGER'
+"default" return 'DEFAULT'
+"delete" return 'DELETETOKEN'
+"do" return 'DO'
+"else" return 'ELSE'
+"finally" return 'FINALLY'
+"for" return 'FOR'
+"function" return 'FUNCTION'
+"if" return 'IF'
+"in" return 'INTOKEN'
+"instanceof" return 'INSTANCEOF'
+"new" return 'NEW'
+"return" yy.ASI = true; return 'RETURN'
+"switch" return 'SWITCH'
+"try" return 'TRY'
+"catch" return 'CATCH'
+"throw" yy.ASI = true; return 'THROW'
+"typeof" return 'TYPEOF'
+"var" return 'VAR'
+"void" return 'VOIDTOKEN'
+"while" return 'WHILE'
+"with" return 'WITH'
+"class" return 'WITH'
+"const" return 'CONSTTOKEN'
+"enum" return 'ENUM'
+"export" return 'EXPORT'
+"extends" return 'EXTENDS'
+"import" return 'IMPORT'
+"super" return 'SUPERTOKEN'
+"implements" return 'IMPLEMENTS'
+"interface" return 'INTERFACE'
+"let" return 'LET'
+"package" return 'PACKAGE'
+"private" return 'PRIVATE'
+"protected" return 'PROTECTED'
+"public" return 'PUBLIC'
+"static" return 'STATIC'
+"yield" return 'YIELD'
+"this" return 'THISTOKEN'
+"true" return 'TRUETOKEN'
+"false" return 'FALSETOKEN'
+"null" return 'NULLTOKEN'
+({IDS})+({IDS}|[0-9])* return 'IDENT';
+. return 'INVALID'
%%
Please sign in to comment.
Something went wrong with that request. Please try again.