Lines Matching refs:lex

21     private Lex lex;
23 public Parser(Lex lex) {
24 this.lex = lex;
27 public boolean hasMore() { return lex.lookAhead() >= 0; }
46 if (lex.lookAhead() == Identifier && lex.lookAhead(1) == '(') {
53 if (lex.get() != Identifier)
54 throw new SyntaxError(lex);
60 name = lex.getString();
63 if (isConstructor || lex.lookAhead() == '(')
78 if (lex.lookAhead() == '=') {
79 lex.get();
83 int c = lex.get();
88 "only one field can be declared in one declaration", lex);
90 throw new SyntaxError(lex);
107 if (lex.get() != '(')
108 throw new SyntaxError(lex);
111 if (lex.lookAhead() != ')')
114 int t = lex.lookAhead();
116 lex.get();
121 lex.get(); // ')'
124 throw new SyntaxError(lex);
127 if (lex.lookAhead() == THROWS) {
128 lex.get();
131 if (lex.lookAhead() == ',')
132 lex.get();
148 if (lex.lookAhead() == ';')
149 lex.get();
169 t = lex.lookAhead();
173 list = new ASTList(new Keyword(lex.get()), list);
184 int t = lex.lookAhead();
186 lex.get(); // primitive type
208 if (lex.get() != Identifier)
209 throw new SyntaxError(lex);
211 String name = lex.getString();
240 int t = lex.lookAhead();
244 lex.get();
247 else if (t == Identifier && lex.lookAhead(1) == ':') {
248 lex.get(); // Identifier
249 String label = lex.getString();
250 lex.get(); // ':'
282 if (lex.get() != '{')
283 throw new SyntaxError(lex);
287 while (lex.lookAhead() != '}') {
293 lex.get(); // '}'
304 int t = lex.get(); // IF
308 if (lex.lookAhead() == ELSE) {
309 lex.get();
323 int t = lex.get(); // WHILE
332 int t = lex.get(); // DO
334 if (lex.get() != WHILE || lex.get() != '(')
335 throw new SyntaxError(lex);
338 if (lex.get() != ')' || lex.get() != ';')
339 throw new SyntaxError(lex);
350 int t = lex.get(); // FOR
354 if (lex.get() != '(')
355 throw new SyntaxError(lex);
357 if (lex.lookAhead() == ';') {
358 lex.get();
364 if (lex.lookAhead() == ';')
369 if (lex.get() != ';')
370 throw new CompileError("; is missing", lex);
372 if (lex.lookAhead() == ')')
377 if (lex.get() != ')')
378 throw new CompileError(") is missing", lex);
393 int t = lex.get(); // SWITCH
400 if (lex.get() != '{')
401 throw new SyntaxError(lex);
406 throw new CompileError("empty switch block", lex);
411 lex);
414 while (lex.lookAhead() != '}') {
427 lex.get(); // '}'
432 int t = lex.lookAhead();
436 lex.get();
443 if (lex.get() != ':')
444 throw new CompileError(": is missing", lex);
453 int t = lex.get(); // SYNCHRONIZED
454 if (lex.get() != '(')
455 throw new SyntaxError(lex);
458 if (lex.get() != ')')
459 throw new SyntaxError(lex);
471 lex.get(); // TRY
474 while (lex.lookAhead() == CATCH) {
475 lex.get(); // CATCH
476 if (lex.get() != '(')
477 throw new SyntaxError(lex);
482 throw new SyntaxError(lex);
484 if (lex.get() != ')')
485 throw new SyntaxError(lex);
492 if (lex.lookAhead() == FINALLY) {
493 lex.get(); // FINALLY
503 int t = lex.get(); // RETURN
505 if (lex.lookAhead() != ';')
508 if (lex.get() != ';')
509 throw new CompileError("; is missing", lex);
517 int t = lex.get(); // THROW
519 if (lex.get() != ';')
520 throw new CompileError("; is missing", lex);
538 int t = lex.get(); // CONTINUE
540 int t2 = lex.get();
542 s.setLeft(new Symbol(lex.getString()));
543 t2 = lex.get();
547 throw new CompileError("; is missing", lex);
565 int t = lex.lookAhead();
567 lex.get();
568 t = lex.lookAhead();
572 t = lex.get();
579 if (lex.lookAhead(i) == Identifier) {
592 if (lex.get() != ';')
593 throw new CompileError("; is missing", lex);
605 if (lex.lookAhead() == ',')
606 lex.get();
621 int t = lex.get();
625 throw new CompileError("; is missing", lex);
634 if (lex.get() != Identifier || d.getType() == VOID)
635 throw new SyntaxError(lex);
637 String name = lex.getString();
641 if (lex.lookAhead() == '=') {
642 lex.get();
654 if (lex.lookAhead() == '{')
666 lex.get(); // '{'
669 while (lex.lookAhead() == ',') {
670 lex.get();
675 if (lex.get() != '}')
676 throw new SyntaxError(lex);
684 if (lex.get() != '(')
685 throw new SyntaxError(lex);
688 if (lex.get() != ')')
689 throw new SyntaxError(lex);
699 if (!isAssignOp(lex.lookAhead()))
702 int t = lex.get();
719 if (lex.lookAhead() == '?') {
720 lex.get();
722 if (lex.get() != ':')
723 throw new CompileError(": is missing", lex);
776 int t = lex.lookAhead();
788 int t = lex.lookAhead();
790 lex.get(); // primitive type
804 int t = lex.get();
810 int t2 = lex.lookAhead();
858 switch (lex.lookAhead()) {
865 t = lex.get();
867 int t2 = lex.lookAhead();
872 lex.get();
873 return new IntConst(-lex.getLong(), t2);
876 lex.get();
877 return new DoubleConst(-lex.getDouble(), t2);
900 int t = lex.lookAhead(1);
902 lex.get(); // '('
903 lex.get(); // primitive type
905 if (lex.get() != ')')
906 throw new CompileError(") is missing", lex);
911 lex.get(); // '('
914 if (lex.get() != ')')
915 throw new CompileError(") is missing", lex);
926 while ((t = lex.lookAhead(i++)) == '[')
927 if (lex.lookAhead(i++) != ']')
930 return lex.lookAhead(i - 1) == ')';
938 int t = lex.lookAhead(i);
942 t = lex.lookAhead(i + 1);
952 while (lex.lookAhead(++i) == '.')
953 if (lex.lookAhead(++i) != Identifier)
956 while ((t = lex.lookAhead(i++)) == '[')
957 if (lex.lookAhead(i++) != ']')
967 while (lex.lookAhead() == '[') {
969 lex.get();
970 if (lex.get() != ']')
971 throw new CompileError("] is missing", lex);
982 if (lex.get() != Identifier)
983 throw new SyntaxError(lex);
985 list = ASTList.append(list, new Symbol(lex.getString()));
986 if (lex.lookAhead() == '.')
987 lex.get();
1012 int token = lex.lookAhead();
1017 lex.get();
1018 return new IntConst(lex.getLong(), token);
1021 lex.get();
1022 return new DoubleConst(lex.getDouble(), token);
1032 switch (lex.lookAhead()) {
1037 if (lex.lookAhead(1) == ']') {
1039 if (lex.get() != '.' || lex.get() != CLASS)
1040 throw new SyntaxError(lex);
1047 throw new SyntaxError(lex);
1054 t = lex.get();
1058 lex.get();
1059 t = lex.get();
1064 str = lex.getString();
1068 throw new CompileError("missing member name", lex);
1071 lex.get();
1072 t = lex.get();
1074 throw new CompileError("missing static member name", lex);
1076 str = lex.getString();
1167 throw new SyntaxError(lex);
1174 throw new SyntaxError(lex);
1205 throw new CompileError("bad static member access", lex);
1224 switch (t = lex.get()) {
1232 name = lex.getString();
1239 return new StringL(lex.getString());
1244 if (lex.get() == ')')
1247 throw new CompileError(") is missing", lex);
1251 if (lex.get() == '.' && lex.get() == CLASS)
1255 throw new SyntaxError(lex);
1265 int t = lex.lookAhead();
1267 lex.get();
1269 if (lex.lookAhead() == '{')
1276 t = lex.lookAhead();
1283 if (lex.lookAhead() == '{')
1290 throw new SyntaxError(lex);
1297 while (lex.lookAhead() == '[')
1306 lex.get(); // '['
1307 if (lex.lookAhead() == ']') {
1308 lex.get();
1313 if (lex.get() != ']')
1314 throw new CompileError("] is missing", lex);
1323 if (lex.get() != '(')
1324 throw new CompileError("( is missing", lex);
1327 if (lex.lookAhead() != ')')
1330 if (lex.lookAhead() == ',')
1331 lex.get();
1336 if (lex.get() != ')')
1337 throw new CompileError(") is missing", lex);