2 // jscript-lexer-parser.g: EcmaScript Grammar written on antlr.
5 // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
7 // (C) 2003, 2004, Cesar Lopez Nataren
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
37 namespace = "Microsoft.JScript";
44 class JScriptParser extends Parser;
46 defaultErrorHandler = false;
49 program returns [ScriptBlock prog]
50 { prog = new ScriptBlock (); }
51 : source_elements [prog.src_elems]
54 source_elements [Block elems]
55 : (source_element [elems, elems.parent])*
58 source_element [Block elems, AST parent]
60 : stm = statement [parent]
65 | stm = function_decl_or_expr [parent]
72 function_decl_or_expr [AST parent] returns [AST func]
75 bool is_func_exp = false;
76 FormalParameterList p = new FormalParameterList ();
79 : "function" (id:IDENTIFIER | { is_func_exp = true; } )
80 OPEN_PARENS (p = formal_param_list [parent] | ) CLOSE_PARENS
81 (COLON type_annot:IDENTIFIER | )
84 if (type_annot == null)
85 func = new FunctionExpression (parent, String.Empty, p,
88 func = new FunctionExpression (parent, String.Empty, p,
89 type_annot.getText (), null);
90 else if (type_annot == null)
91 func = new FunctionDeclaration (parent, id.getText (), p, null, null);
93 func = new FunctionDeclaration (parent, id.getText (), p,
94 type_annot.getText (), null);
97 body = function_body [func]
98 { ((FunctionDeclaration) func).Function.body = body; }
102 function_body [AST parent] returns [Block elems]
104 elems = new Block (parent);
106 : source_elements [elems]
109 formal_param_list [AST parent] returns [FormalParameterList p]
111 p = new FormalParameterList ();
114 : i:IDENTIFIER (COLON t1:IDENTIFIER { p.Add (i.getText (), t1.getText ()); }
115 | { p.Add (i.getText (), "Object"); }
117 (COMMA g:IDENTIFIER (COLON t2:IDENTIFIER { p.Add (g.getText (), t2.getText ()); }
118 | { p.Add (g.getText (), "Object"); }
127 statement [AST parent] returns [AST stm]
129 : stm = expr_stm [parent] SEMI_COLON
130 | stm = var_stm [parent]
132 | stm = if_stm [parent]
133 | stm = iteration_stm [parent]
134 | stm = continue_stm [parent]
135 | stm = break_stm [parent]
136 | stm = return_stm [parent]
137 | stm = with_stm [parent]
138 | stm = switch_stm [parent]
139 | stm = throw_stm [parent]
140 | stm = try_stm [parent]
141 | stm = block [new Block (parent), parent]
144 block [Block elems, AST parent] returns [AST _block]
148 elems.parent = parent;
151 (stm = statement [elems]
162 try_stm [AST parent] returns [Try t]
164 t = new Try (parent);
166 : "try" block [t.guarded_block, t]
167 ((catch_exp [ref t.catch_id, t.catch_block, t] (finally_exp [t.finally_block, t] | ) | ) | finally_exp [t.finally_block, t])
170 catch_exp [ref string id, Block catch_block, AST parent]
171 : "catch" OPEN_PARENS i:IDENTIFIER { id = i.getText (); } CLOSE_PARENS block [catch_block, parent]
174 finally_exp [Block elems, AST parent]
175 : "finally" block [elems, parent]
178 throw_stm [AST parent] returns [AST t]
183 : "throw" e = expr [parent] SEMI_COLON
189 switch_stm [AST parent] returns [Switch sw]
191 sw = new Switch (parent);
193 ArrayList [] clauses = null;
195 : "switch" OPEN_PARENS exp = expr [sw] CLOSE_PARENS clauses = case_block [sw]
200 sw.case_clauses = clauses [0];
201 sw.default_clauses = clauses [1];
202 sw.sec_case_clauses = clauses [2];
204 foreach (Clause cc in sw.case_clauses)
205 foreach (AST ast in cc.stm_list)
207 foreach (AST dc in sw.default_clauses)
209 foreach (Clause cc in sw.case_clauses)
210 foreach (AST ast in cc.stm_list)
215 case_block [AST parent] returns [ArrayList [] clauses]
217 clauses = new ArrayList [3];
218 ArrayList c1_clauses, def_clauses, c2_clauses;
219 c1_clauses = def_clauses = c2_clauses = null;
221 : OPEN_BRACE c1_clauses = case_clauses [parent] def_clauses = default_clause [parent] c2_clauses = case_clauses [parent] CLOSE_BRACE
223 clauses [0] = c1_clauses;
224 clauses [1] = def_clauses;
225 clauses [2] = c2_clauses;
229 default_clause [AST parent] returns [ArrayList def_clause]
230 : "default" COLON def_clause = statement_list [parent]
233 case_clauses [AST parent] returns [ArrayList clauses]
235 clauses = new ArrayList ();
236 Clause clause = null;
238 : (clause = case_clause [parent] { if (clause != null) clauses.Add (clause); })*
241 case_clause [AST parent] returns [Clause clause]
243 clause = new Clause (parent);
245 ArrayList stm_list = null;
247 : "case" exp = expr [parent] { clause.exp = exp; } COLON stm_list = statement_list [parent] { clause.stm_list = stm_list; }
250 with_stm [AST parent] returns [AST with]
256 : "with" OPEN_PARENS exp = expr [parent] CLOSE_PARENS stm = statement [null]
258 with = new With (parent, exp, stm);
262 return_stm [AST parent] returns [AST r]
267 : "return" (e = expr [parent] { r = new Return (parent, e); } | ) SEMI_COLON
271 break_stm [AST parent] returns [AST b]
275 : "break" ( id:IDENTIFIER
276 { ((Break) b).identifier = id.getText (); }
277 | { ((Break) b).identifier = String.Empty; } ) SEMI_COLON
280 continue_stm [AST parent] returns [AST cont]
282 cont = new Continue (parent);
284 : "continue" ( id:IDENTIFIER
285 { ((Continue) cont).identifier = id.getText (); }
286 | { ((Continue) cont).identifier = String.Empty; } ) SEMI_COLON
289 iteration_stm [AST parent] returns [AST iter]
296 : "do" stm = statement [iter] "while" OPEN_PARENS exprn = expr [iter] CLOSE_PARENS SEMI_COLON
298 iter = new DoWhile (parent, stm, exprn);
299 exprn.parent = stm.parent = iter;
301 | "while" OPEN_PARENS exprn = expr [iter] CLOSE_PARENS stm = statement [iter]
303 iter = new While (parent, exprn, stm);
304 exprn.parent = stm.parent = iter;
306 | "for" OPEN_PARENS exprs = inside_for [iter] CLOSE_PARENS stm = statement [iter]
308 iter = new For (parent, exprs, stm);
314 inside_for [AST parent] returns [AST [] exprs]
316 AST exp1, exp2, exp3;
318 exp1 = exp2 = exp3 = null;
319 VariableStatement v_stm = new VariableStatement ();
321 : (exp1 = expr [parent] | ) SEMI_COLON (exp2 = expr [parent] | ) SEMI_COLON (exp3 = expr [parent] | )
323 exprs = new AST [] {exp1, exp2, exp3};
325 | "var" (var_decl_list [v_stm, parent]
326 ( SEMI_COLON (exp2 = expr [parent] | ) SEMI_COLON (exp3 = expr [parent] | )
328 exprs = new AST [] {v_stm, exp2, exp3};
330 | IN exp3 = expr [parent]))
331 // FIXME: left_hand_side_expr in exp rule, missing
334 if_stm [AST parent] returns [AST if_stm]
337 AST cond, true_stm, false_stm;
338 cond = true_stm = false_stm = null;
340 : "if" OPEN_PARENS cond = expr [if_stm] CLOSE_PARENS true_stm = statement [if_stm]
341 (("else")=> "else" false_stm = statement [if_stm] | )
343 if_stm = new If (parent, cond, true_stm, false_stm);
344 cond.parent = true_stm.parent = if_stm;
345 if (false_stm != null)
346 false_stm.parent = if_stm;
354 var_stm [AST parent] returns [VariableStatement var_stm]
355 { var_stm = new VariableStatement (); }
356 : "var" var_decl_list [var_stm, parent] SEMI_COLON
359 var_decl_list [VariableStatement var_stm, AST parent]
360 { VariableDeclaration var_decln = null; }
361 : var_decln = var_decl [parent]
363 if (var_decln != null && var_stm != null)
364 var_stm.Add (var_decln);
366 (COMMA var_decln = var_decl [parent]
368 if (var_decln != null && var_stm != null)
369 var_stm.Add (var_decln);
375 var_decl [AST parent] returns [VariableDeclaration var_decl]
380 : id:IDENTIFIER (COLON type_annot:IDENTIFIER | )
381 (init = initializer [parent]
383 if (type_annot == null)
384 var_decl = new VariableDeclaration (parent, id.getText (), null , init);
386 var_decl = new VariableDeclaration (parent, id.getText (), type_annot.getText () , init);
390 if (type_annot == null)
391 var_decl = new VariableDeclaration (parent, id.getText (), null, null);
393 var_decl = new VariableDeclaration (parent, id.getText (), type_annot.getText (), null);
397 initializer [AST parent] returns [AST init]
399 : ASSIGN init = assignment_expr [parent]
402 expr_stm [AST parent] returns [AST e]
408 statement_list [AST parent] returns [ArrayList stms]
410 stms = new ArrayList ();
413 : (stm = statement [null] { if (stm != null) stms.Add (stm); })*
416 expr [AST parent] returns [Expression e]
418 e = new Expression (parent);
421 : a = assignment_expr [parent] { e.Add (a); }
422 (COMMA a = assignment_expr [parent] { e.Add (a); } )*
424 assignment_expr [AST parent] returns [AST assign_expr]
427 JSToken op = JSToken.None;
431 : ((left_hand_side_expr [parent] assignment_op)=>
432 left = left_hand_side_expr [parent] op = assignment_op right = assignment_expr [parent]
436 a = new Assign (parent, left, right, op, true);
438 a = new Assign (parent, left, right, op, false);
441 | assign_expr = cond_expr [parent]
445 member_expr [AST parent] returns [AST mem_exp]
449 : ( mem_exp = primary_expr [parent]
450 | "new" member_expr [parent] arguments [parent]
451 ) member_aux [parent]
454 member_aux [AST parent]
457 | OPEN_BRACKET expr [parent] CLOSE_BRACKET
458 ) member_aux [parent]
462 new_expr [AST parent] returns [AST new_exp]
467 : mem_exp = member_expr [parent] { new_exp = mem_exp; }
470 call_expr [AST parent] returns [Call func_call]
477 : member = member_expr [parent] args1 = arguments [parent] args2 = call_aux [parent]
479 func_call = new Call (parent, member, args1, args2);
483 call_aux [AST parent] returns [AST args]
489 | OPEN_BRACKET expr [parent] CLOSE_BRACKET
495 arguments [AST parent] returns [Args args]
497 Args tmp = new Args ();
500 : OPEN_PARENS (arguments_list [tmp, parent] { args = tmp; } | ) CLOSE_PARENS
503 arguments_list [Args args, AST parent]
507 : a = assignment_expr [parent] { args.Add (a); }
508 (COMMA a = assignment_expr [parent] { args.Add (a); })*
511 left_hand_side_expr [AST parent] returns [AST lhe]
516 : (call_expr [parent])=> call = call_expr [parent] { lhe = call; }
517 | lhe = new_expr [parent]
520 postfix_expr [AST parent] returns [AST post_expr]
523 JSToken op = JSToken.None;
526 : left = left_hand_side_expr [parent] ( INCREMENT { op = JSToken.Increment; }
527 | DECREMENT { op = JSToken.Decrement; }
530 if (op == JSToken.None)
533 post_expr = new PostOrPrefixOperator (parent, left, op);
537 unary_expr [AST parent] returns [AST unary_exprn]
540 JSToken op = JSToken.None;
543 : unary_exprn = postfix_expr [parent]
544 | op = unary_op u_expr = unary_expr [null]
546 unary_exprn = new Unary (parent, u_expr, op);
547 u_expr.parent = unary_exprn;
551 unary_op returns [JSToken unary_op]
552 { unary_op = JSToken.None; }
553 : "delete" { unary_op = JSToken.Delete; }
554 | "void" { unary_op = JSToken.Void; }
555 | "typeof" { unary_op = JSToken.Typeof; }
556 | INCREMENT { unary_op = JSToken.Increment; }
557 | DECREMENT { unary_op = JSToken.Decrement; }
558 | PLUS { unary_op = JSToken.Plus; }
559 | MINUS { unary_op = JSToken.Minus; }
560 | BITWISE_NOT { unary_op = JSToken.BitwiseNot; }
561 | LOGICAL_NOT { unary_op = JSToken.LogicalNot; }
564 multiplicative_expr [AST parent] returns [AST mult_expr]
570 : left = unary_expr [parent] right = multiplicative_aux [parent]
575 mult_expr = new Binary (parent, left, right, ((Binary) right).old_op);
579 multiplicative_aux [AST parent] returns [AST mult_aux]
582 JSToken mult_op = JSToken.None;
586 : (( MULT { mult_op = JSToken.Multiply; }
587 | DIVISION { mult_op = JSToken.Divide; }
588 | MODULE { mult_op = JSToken.Modulo; }
589 ) left = unary_expr [parent] right = multiplicative_aux [parent]
592 mult_aux = new Binary (parent, left, null, JSToken.None);
594 mult_aux = new Binary (parent, left, right, ((Binary) right).old_op);
595 ((Binary) mult_aux).old_op = mult_op;
600 additive_expr [AST parent] returns [AST add_expr]
606 : left = multiplicative_expr [parent] right = additive_aux [parent]
611 add_expr = new Binary (parent, left, right, ((Binary) right).old_op);
615 additive_aux [AST parent] returns [AST add_aux]
618 JSToken op = JSToken.None;
622 : (( PLUS { op = JSToken.Plus; }
623 | MINUS { op = JSToken.Minus; }
624 ) left = multiplicative_expr [parent] right = additive_aux [parent]
627 add_aux = new Binary (parent, left, null, JSToken.None);
629 add_aux = new Binary (parent, left, right, ((Binary) right).old_op);
630 ((Binary) add_aux).old_op = op;
635 shift_expr [AST parent] returns [AST shift_expr]
641 : left = additive_expr [parent] right = shift_aux [parent]
646 shift_expr = new Binary (parent, left, right, ((Binary) right).old_op);
650 shift_aux [AST parent] returns [AST shift_auxr]
653 JSToken op = JSToken.None;
657 : (op = shift_op left = additive_expr [parent] right = shift_aux [parent]
660 shift_auxr = new Binary (parent, left, null, JSToken.None);
662 shift_auxr = new Binary (parent, left, right, ((Binary) right).old_op);
664 ((Binary) shift_auxr).old_op = op;
669 shift_op returns [JSToken shift_op]
670 { shift_op = JSToken.None; }
671 : SHIFT_LEFT { shift_op = JSToken.LeftShift; }
672 | SHIFT_RIGHT { shift_op = JSToken.RightShift; }
673 | UNSIGNED_SHIFT_RIGHT { shift_op = JSToken.UnsignedRightShift; }
676 relational_expr [AST parent] returns [AST rel_expr]
680 Relational right = null;
682 : left = shift_expr [parent] right = relational_aux [parent]
687 rel_expr = new Relational (parent, left, right, right.old_op);
691 relational_aux [AST parent] returns [Relational rel_aux]
694 JSToken op = JSToken.None;
696 Relational right = null;
698 : (op = relational_op left = shift_expr [parent] right = relational_aux [parent]
701 rel_aux = new Relational (parent, left, null, JSToken.None);
703 rel_aux = new Relational (parent, left, right, right.old_op);
710 relational_op returns [JSToken rel_op]
711 { rel_op = JSToken.None; }
712 : LESS_THAN { rel_op = JSToken.LessThan; }
713 | GREATER_THAN { rel_op = JSToken.GreaterThan; }
714 | LESS_EQ { rel_op = JSToken.LessThanEqual; }
715 | GREATER_EQ { rel_op = JSToken.GreaterThanEqual; }
716 | INSTANCE_OF { rel_op = JSToken.InstanceOf; }
717 | IN { rel_op = JSToken.In; }
721 equality_expr [AST parent] returns [AST eq_expr]
727 : left = relational_expr [parent] right = equality_aux [parent]
732 eq_expr = new Equality (parent, left, right, ((Equality) right).old_op);
737 equality_aux [AST parent] returns [AST eq_aux]
742 JSToken op = JSToken.None;
744 : (op = equality_op left = relational_expr [parent] right = equality_aux [parent]
747 eq_aux = new Equality (parent, left, null, JSToken.None);
749 eq_aux = new Equality (parent, left, right, ((Equality) right).old_op);
750 ((Equality) eq_aux).old_op = op;
755 equality_op returns [JSToken eq_op]
756 { eq_op = JSToken.None; }
757 : EQ { eq_op = JSToken.Equal; }
758 | NEQ { eq_op = JSToken.NotEqual; }
759 | STRICT_EQ { eq_op = JSToken.StrictEqual; }
760 | STRICT_NEQ { eq_op = JSToken.StrictNotEqual; }
763 bitwise_and_expr [AST parent] returns [AST bit_and_expr]
771 : left = equality_expr [parent] right = bitwise_and_aux [parent]
776 bit_and_expr = new Binary (parent, left, right, JSToken.BitwiseAnd);
780 bitwise_and_aux [AST parent] returns [AST bit_and_aux]
786 : (BITWISE_AND left = equality_expr [parent] right = bitwise_and_aux [parent]
791 bit_and_aux = new Binary (parent, left, right, JSToken.BitwiseAnd);
797 bitwise_xor_expr [AST parent] returns [AST bit_xor_expr]
803 : left = bitwise_and_expr [parent] right = bitwise_xor_aux [parent]
808 bit_xor_expr = new Binary (parent, left, right, JSToken.BitwiseXor);
812 bitwise_xor_aux [AST parent] returns [AST bit_xor_aux]
818 : (BITWISE_XOR left = bitwise_and_expr [parent] right = bitwise_xor_aux [parent]
823 bit_xor_aux = new Binary (parent, left, right, JSToken.BitwiseXor);
828 bitwise_or_expr [AST parent] returns [AST bit_or_expr]
834 : left = bitwise_xor_expr [parent] right = bitwise_or_aux [parent]
839 bit_or_expr = new Binary (parent, left, right, JSToken.BitwiseOr);
843 bitwise_or_aux [AST parent] returns [AST bit_or_aux]
849 : (BITWISE_OR left = bitwise_xor_expr [parent] right = bitwise_or_aux [parent]
854 bit_or_aux = new Binary (parent, left, right, JSToken.BitwiseOr);
859 logical_and_expr [AST parent] returns [AST log_and_expr]
865 : left = bitwise_or_expr [parent] right = logical_and_aux [parent]
870 log_and_expr = new Binary (parent, left, right, JSToken.LogicalAnd);
874 logical_and_aux [AST parent] returns [AST log_and_aux]
880 : (LOGICAL_AND left = bitwise_or_expr [parent] right = logical_and_aux [parent]
885 log_and_aux = new Binary (parent, left, right, JSToken.LogicalAnd);
890 logical_or_expr [AST parent] returns [AST log_or_expr]
896 : left = logical_and_expr [parent] right = logical_or_aux [parent]
901 log_or_expr = new Binary (parent, left, right, JSToken.LogicalOr);
906 logical_or_aux [AST parent] returns [AST log_or_aux]
912 : (LOGICAL_OR left = logical_and_expr [parent] right = logical_or_aux [parent]
917 log_or_aux = new Binary (parent, left, right, JSToken.LogicalOr);
922 cond_expr [AST parent] returns [AST conditional]
926 AST trueExpr, falseExpr;
928 trueExpr = falseExpr = null;
930 : cond = logical_or_expr [parent]
931 (INTERR trueExpr = assignment_expr [parent]
932 COLON falseExpr = assignment_expr [parent]
934 if (trueExpr != null && falseExpr != null) {
935 Conditional c = new Conditional (parent, (AST) cond, trueExpr, falseExpr);
939 | { conditional = cond; } )
943 assignment_op returns [JSToken assign_op]
945 assign_op = JSToken.None;
947 : ASSIGN { assign_op = JSToken.Assign; }
948 | MULT_ASSIGN { assign_op = JSToken.MultiplyAssign; }
949 | DIV_ASSIGN { assign_op = JSToken.DivideAssign; }
950 | MOD_ASSIGN { assign_op = JSToken.ModuloAssign; }
951 | ADD_ASSIGN { assign_op = JSToken.PlusAssign; }
952 | SUB_ASSIGN { assign_op = JSToken.MinusAssign; }
953 | SHIFT_LEFT_ASSIGN { assign_op = JSToken.LeftShiftAssign; }
954 | SHIFT_RIGHT_ASSIGN { assign_op = JSToken.RightShiftAssign; }
955 | AND_ASSIGN { assign_op = JSToken.BitwiseAndAssign; }
956 | XOR_ASSIGN { assign_op = JSToken.BitwiseXorAssign; }
957 | OR_ASSIGN { assign_op = JSToken.BitwiseOrAssign; }
961 primary_expr [AST parent] returns [AST prim_exp]
967 : p:"this" { prim_exp = new This (); }
968 // | l = object_literal [parent] { prim_exp = l; }
971 Identifier ident = new Identifier (parent, id.getText ());
972 prim_exp = (AST) ident;
974 | l = literal [parent] { prim_exp = l; }
975 | l = array_literal [parent] { prim_exp = l; }
976 | OPEN_PARENS e = expr [parent] { prim_exp = e; } CLOSE_PARENS
979 // object_literal [AST parent] returns [ObjectLiteral obj_lit]
981 // obj_lit = new ObjectLiteral (parent);
983 // ObjectLiteralItem item = null;
984 // PropertyName pn = null;
987 // ((property_name COLON)=> pn = property_name COLON e = assignment_expr [obj_lit]
989 // item = new ObjectLiteralItem ();
990 // item.property_name = pn.Name;
992 // obj_lit.Add (item);
994 // (COMMA pn = property_name COLON e = assignment_expr [obj_lit]
996 // item = new ObjectLiteralItem ();
997 // item.property_name = pn.Name;
999 // obj_lit.Add (item);
1005 literal [AST parent] returns [AST l]
1012 BooleanLiteral bl = new BooleanLiteral (parent, true);
1017 BooleanLiteral bl = new BooleanLiteral (parent, false);
1022 StringLiteral str = new StringLiteral (parent, s.getText ());
1025 | l = numeric_literal [parent]
1028 property_name_and_value_list
1029 : (property_name COLON primary_expr [null])+
1032 property_name returns [PropertyName pn]
1033 { pn = new PropertyName (); }
1034 : (id:IDENTIFIER { pn.Name = id.getText (); }
1035 |st:STRING_LITERAL { pn.Name = st.getText (); }
1036 |numeric_literal [null] { pn.Name = string.Empty; }
1040 array_literal [AST parent] returns [ArrayLiteral array_lit]
1042 array_lit = new ArrayLiteral (parent);
1044 ASTList elems = ((ArrayLiteral) array_lit).elems;
1048 (e = primary_expr [array_lit]
1053 } (COMMA e = primary_expr [array_lit]
1064 numeric_literal [AST parent] returns [NumericLiteral num_lit]
1068 : d:DECIMAL_LITERAL { num_lit = new NumericLiteral (parent, System.Convert.ToSingle (d.getText ())); }
1069 | HEX_INTEGER_LITERAL
1077 | PARAGRAPH_SEPARATOR
1092 class JScriptLexer extends Lexer;
1095 charVocabulary = '\u0000'..'\uFFFE';
1096 testLiterals = false;
1101 INSTANCE_OF = "instanceof";
1104 DECIMAL_LITERAL: ('0' | ('1'..'9')('0'..'9')*) (DOT ('0'..'9')* | ) (('e' | 'E') (('+' | '-' | ) ('0'..'9')+) | )
1107 HEX_INTEGER_LITERAL: '0' ('x' | 'X') ('0'..'9' | 'a'..'f' | 'A'..'F')+
1111 : '"'! (~('"' | '\\' | '\u000A' | '\u000D' | '\u2028' | '\u2029'))* '"'! |
1112 '\''! (~('\'' | '\\' | '\u000A' | '\u000D' | '\u2028' | '\u2029'))*'\''!
1116 options { testLiterals = true; }
1117 : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9')*
1141 UNSIGNED_SHIFT_RIGHT: ">>>";
1158 SHIFT_LEFT_ASSIGN: "<<=";
1159 SHIFT_RIGHT_ASSIGN: ">>=";
1190 : "//" (~('\u000A' | '\u000D' | '\u2028' | '\u2029'))*
1191 { $setType (Token.SKIP); }
1197 generateAmbigWarnings=false;
1201 | '\r' '\n' { newline(); }
1202 | '\r' { newline(); }
1203 | '\n' { newline(); }
1207 { $setType (Token.SKIP); }
1211 // Line terminator tokens
1214 : '\u000A' { $setType (Token.SKIP); newline (); }
1218 : '\u000D' { $setType (Token.SKIP); newline ();}
1222 : '\u2028' { $setType (Token.SKIP); newline ();}
1226 : '\u2029' { $setType (Token.SKIP); newline ();}
1230 // White space tokens
1233 : '\u0009' { $setType (Token.SKIP); }
1237 : '\u000B' { $setType (Token.SKIP); }
1241 : '\u000C' { $setType (Token.SKIP); }
1245 : '\u0020' { $setType (Token.SKIP); }
1249 : '\u00A0' { $setType (Token.SKIP); }