Skip to content
This repository
tree: 72f256d2fb
Fetching contributors…

Cannot retrieve contributors at this time

file 163 lines (147 sloc) 4.475 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
esc "\\"
int ([0-9]|[1-9][0-9]+)
exp ([eE][-+]?[0-9]+)
frac ("."[0-9]+)
IDS [a-zA-Z$_]|"\u"[a-fA-F0-9]{4}
BSL "\\".
RCLASS "["({BSL}|[^\\[])*"]"

%%

";"\s+/("++"|"--") {return ';'}
\n+/("++"|"--") {return ';'}
\n+ %{ if(yy.ASI){ yy.ASI=false; return ';';} else yy.lineBreak = true; %}
\s+ {yy.ASI=false; /* skip whitespace */}
"//".* {/* skip comment */}
"#".* {/* skip comment */}
"/*"(.|\n)*?"*/" {/* 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';}

'"'("\\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';}

'@"'("\\"["bfvnrt/{esc}]|"\\u"[a-fA-F0-9]{4}|[^"{esc}])*'"' {yytext = yytext.substr(2,yyleng-3); return 'CPSTRING';}

/("/="({BSL}|{RCLASS}|[^[\\\/])*"/"({IDS})*) %{
  if(!!yy.inRegex) {
    var s = yy.lexer.matches[1];
    for(var i=0;i<s.length;++i) {
      yy.lexer.input();
    }
    yytext = s;
    return 'REGEXP_BODY';
  } else {
    yy.lexer.input(); yy.lexer.input();
    return 'DIVEQUAL';
  };
%}

/("/"({BSL}|{RCLASS}|[^[\\\/*])({BSL}|{RCLASS}|[^[\\\/])*"/"({IDS})*) %{
  if(!!yy.inRegex) {
    var s = yy.lexer.matches[1];
    for(var i=0;i<s.length;++i) {
      yy.lexer.input();
    }
    yytext = s;
    return 'REGEXP_BODY';
  } else {
    yy.lexer.input();
    return '/';
  };
%}


"{" %{ 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 '='}

"@import"\s"<"([^>]+)">" {yytext = yytext.substr(9,yyleng-10); return 'CPIMPORT_LIB'}
"@import"\s'"'([^"]+)'"' {yytext = yytext.substr(9,yyleng-10); return 'CPIMPORT'}
"@implementation" {return 'CPIMPLEMENTATION'}
"@end" {return 'CPEND'}
"@selector" {return 'CPSELECTOR'}
"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 'IDENT'}
"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'}

%%
Something went wrong with that request. Please try again.