1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
8 * Parses a stream of lexed tokens into a tree of CompiledFunctionImpl's.
10 * There are three kinds of things we parse: blocks, statements, and
13 * - Expressions are a special type of statement that evaluates to a
14 * value (for example, "break" is not an expression, * but "3+2"
15 * is). Some tokens sequences start expressions (for * example,
16 * literal numbers) and others continue an expression which * has
17 * already been begun (for example, '+'). Finally, some *
18 * expressions are valid targets for an assignment operation; after
19 * * each of these expressions, continueExprAfterAssignable() is
20 * called * to check for an assignment operation.
22 * - A statement ends with a semicolon and does not return a value.
24 * - A block is a single statement or a sequence of statements
25 * surrounded by curly braces.
27 * Each parsing method saves the parserLine before doing its actual
28 * work and restores it afterwards. This ensures that parsing a
29 * subexpression does not modify the line number until a token
30 * *after* the subexpression has been consumed by the parent
33 * Technically it would be a better design for this class to build an
34 * intermediate parse tree and use that to emit bytecode. Here's the
37 * Advantages of building a parse tree:
38 * - easier to apply optimizations
39 * - would let us handle more sophisticated languages than JavaScript
41 * Advantages of leaving out the parse tree
42 * - faster compilation
43 * - less load on the garbage collector
44 * - much simpler code, easier to understand
47 * Fortunately JS is such a simple language that we can get away with
48 * the half-assed approach and still produce a working, complete
51 * The bytecode language emitted doesn't really cause any appreciable
52 * semantic loss, and is itself a parseable language very similar to
53 * Forth or a postfix variant of LISP. This means that the bytecode
54 * can be transformed into a parse tree, which can be manipulated.
55 * So if we ever want to add an optimizer, it could easily be done by
56 * producing a parse tree from the bytecode, optimizing that tree,
57 * and then re-emitting the bytecode. The parse tree node class
58 * would also be much simpler since the bytecode language has so few
61 * Actually, the above paragraph is slightly inaccurate -- there are
62 * places where we push a value and then perform an arbitrary number
63 * of operations using it before popping it; this doesn't parse well.
64 * But these cases are clearly marked and easy to change if we do
65 * need to move to a parse tree format.
67 class Parser extends Lexer implements ByteCodes {
70 // Constructors //////////////////////////////////////////////////////
72 public Parser(Reader r, String sourceName, int line) throws IOException { super(r, sourceName, line); }
75 public static void main(String[] s) throws Exception {
76 CompiledFunctionImpl block = new JS.CompiledFunction("stdin", 0, new InputStreamReader(System.in), null);
77 if (block == null) return;
78 System.out.println(block);
82 // Statics ////////////////////////////////////////////////////////////
84 static byte[] precedence = new byte[MAX_TOKEN + 1];
85 static boolean[] isRightAssociative = new boolean[MAX_TOKEN + 1];
87 isRightAssociative[ASSIGN] =
88 isRightAssociative[ASSIGN_BITOR] =
89 isRightAssociative[ASSIGN_BITXOR] =
90 isRightAssociative[ASSIGN_BITAND] =
91 isRightAssociative[ASSIGN_LSH] =
92 isRightAssociative[ASSIGN_RSH] =
93 isRightAssociative[ASSIGN_URSH] =
94 isRightAssociative[ASSIGN_ADD] =
95 isRightAssociative[ASSIGN_SUB] =
96 isRightAssociative[ASSIGN_MUL] =
97 isRightAssociative[ASSIGN_DIV] =
98 isRightAssociative[ASSIGN_MOD] = true;
101 precedence[ASSIGN_BITOR] =
102 precedence[ASSIGN_BITXOR] =
103 precedence[ASSIGN_BITAND] =
104 precedence[ASSIGN_LSH] =
105 precedence[ASSIGN_RSH] =
106 precedence[ASSIGN_URSH] =
107 precedence[ASSIGN_ADD] =
108 precedence[ASSIGN_SUB] =
109 precedence[ASSIGN_MUL] =
110 precedence[ASSIGN_DIV] =
111 precedence[ASSIGN_MOD] = 1;
112 precedence[HOOK] = 2;
113 precedence[COMMA] = 3;
114 precedence[OR] = precedence[AND] = precedence[BANG] = 4;
115 precedence[GT] = precedence[GE] = 5;
116 precedence[BITOR] = 6;
117 precedence[BITXOR] = 7;
118 precedence[BITAND] = 8;
119 precedence[EQ] = precedence[NE] = 9;
120 precedence[LT] = precedence[LE] = precedence[TYPEOF] = 10;
121 precedence[SHEQ] = precedence[SHNE] = 11;
122 precedence[LSH] = precedence[RSH] = precedence[URSH] = 12;
123 precedence[ADD] = precedence[SUB] = 13;
124 precedence[MUL] = precedence[DIV] = precedence[MOD] = 14;
125 precedence[BITNOT] = 15;
126 precedence[INC] = precedence[DEC] = 16;
128 precedence[DOT] = precedence[LB] = 18;
132 // Parsing Logic /////////////////////////////////////////////////////////
134 /** gets a token and throws an exception if it is not <tt>code</tt> */
135 private void consume(int code) throws IOException {
136 if (getToken() != code) throw pe("expected " + codeToString[code] + ", got " + (op == -1 ? "EOF" : codeToString[op]));
140 * Parse the largest possible expression containing no operators
141 * of precedence below <tt>minPrecedence</tt> and append the
142 * bytecodes for that expression to <tt>appendTo</tt>; the
143 * appended bytecodes MUST grow the stack by exactly one element.
145 private void startExpr(CompiledFunctionImpl appendTo, int minPrecedence) throws IOException {
146 int saveParserLine = parserLine;
147 _startExpr(appendTo, minPrecedence);
148 parserLine = saveParserLine;
150 private void _startExpr(CompiledFunctionImpl appendTo, int minPrecedence) throws IOException {
151 int tok = getToken();
152 CompiledFunctionImpl b = appendTo;
155 case -1: throw pe("expected expression");
157 // all of these simply push values onto the stack
158 case NUMBER: b.add(parserLine, LITERAL, number); break;
159 case STRING: b.add(parserLine, LITERAL, string); break;
160 case THIS: b.add(parserLine, TOPSCOPE, null); break;
161 case NULL: b.add(parserLine, LITERAL, null); break;
162 case TRUE: case FALSE: b.add(parserLine, LITERAL, new Boolean(tok == TRUE)); break;
165 b.add(parserLine, ARRAY, new Integer(0)); // push an array onto the stack
166 int size0 = b.size();
168 if (peekToken() != RB)
169 while(true) { // iterate over the initialization values
171 b.add(parserLine, LITERAL, new Integer(i++)); // push the index in the array to place it into
172 if (peekToken() == COMMA || peekToken() == RB)
173 b.add(parserLine, LITERAL, null); // for stuff like [1,,2,]
175 startExpr(b, -1); // push the value onto the stack
176 b.add(parserLine, PUT); // put it into the array
177 b.add(parserLine, POP); // discard the value remaining on the stack
178 if (peekToken() == RB) break;
181 b.set(size0 - 1, new Integer(i)); // back at the ARRAY instruction, write the size of the array
185 case SUB: { // negative literal (like "3 * -1")
187 b.add(parserLine, LITERAL, new Double(number.doubleValue() * -1));
190 case LP: { // grouping (not calling)
195 case INC: case DEC: { // prefix (not postfix)
196 startExpr(b, precedence[tok]);
197 int prev = b.size() - 1;
198 if (b.get(prev) == GET && b.getArg(prev) != null)
199 b.set(prev, LITERAL, b.getArg(prev));
200 else if(b.get(prev) == GET)
203 throw pe("prefixed increment/decrement can only be performed on a valid assignment target");
204 b.add(parserLine, tok, Boolean.TRUE);
207 case BANG: case BITNOT: case TYPEOF: {
208 startExpr(b, precedence[tok]);
209 b.add(parserLine, tok);
212 case LC: { // object constructor
213 b.add(parserLine, OBJECT, null); // put an object on the stack
214 if (peekToken() != RC)
216 if (peekToken() != NAME && peekToken() != STRING)
217 throw pe("expected NAME or STRING");
219 b.add(parserLine, LITERAL, string); // grab the key
221 startExpr(b, -1); // grab the value
222 b.add(parserLine, PUT); // put the value into the object
223 b.add(parserLine, POP); // discard the remaining value
224 if (peekToken() == RC) break;
226 if (peekToken() == RC) break; // we permit {,,} -- I'm not sure if ECMA does
232 b.add(parserLine, TOPSCOPE);
233 b.add(parserLine, LITERAL, string);
234 continueExprAfterAssignable(b);
240 CompiledFunctionImpl b2 = new JS.CompiledFunction(sourceName, parserLine, null, null);
241 b.add(parserLine, NEWFUNCTION, b2);
243 // function prelude; arguments array is already on the stack
244 b2.add(parserLine, TOPSCOPE);
245 b2.add(parserLine, SWAP);
246 b2.add(parserLine, DECLARE, "arguments"); // declare arguments (equivalent to 'var arguments;')
247 b2.add(parserLine, SWAP); // set this.arguments and leave the value on the stack
248 b2.add(parserLine, PUT);
250 while(peekToken() != RP) { // run through the list of argument names
251 if (peekToken() == NAME) {
252 consume(NAME); // a named argument
253 String varName = string;
255 b2.add(parserLine, DUP); // dup the args array
256 b2.add(parserLine, GET, new Integer(numArgs)); // retrieve it from the arguments array
257 b2.add(parserLine, TOPSCOPE);
258 b2.add(parserLine, SWAP);
259 b2.add(parserLine, DECLARE, varName); // declare the name
260 b2.add(parserLine, SWAP);
261 b2.add(parserLine, PUT);
262 b2.add(parserLine, POP); // pop the value
263 b2.add(parserLine, POP); // pop the scope
265 if (peekToken() == RP) break;
271 b2.add(parserLine, POP); // pop off the arguments array
272 b2.add(parserLine, POP); // pop off TOPSCOPE
274 if(peekToken() != LC)
275 throw pe("Functions must have a block surrounded by curly brackets");
277 parseBlock(b2, null); // the function body
279 if(b2.get(b2.size()-1) != RETURN) {
280 b2.add(parserLine, LITERAL, null); // in case we "fall out the bottom", return NULL
281 b2.add(parserLine, RETURN);
286 default: throw pe("expected expression, found " + codeToString[tok] + ", which cannot start an expression");
289 // attempt to continue the expression
290 continueExpr(b, minPrecedence);
295 * Assuming that a complete assignable (lvalue) has just been
296 * parsed and the object and key are on the stack,
297 * <tt>continueExprAfterAssignable</tt> will attempt to parse an
298 * expression that modifies the assignable. This method always
299 * decreases the stack depth by exactly one element.
301 private void continueExprAfterAssignable(CompiledFunctionImpl b) throws IOException {
302 int saveParserLine = parserLine;
303 _continueExprAfterAssignable(b);
304 parserLine = saveParserLine;
306 private void _continueExprAfterAssignable(CompiledFunctionImpl b) throws IOException {
307 if (b == null) throw new Error("got null b; this should never happen");
308 int tok = getToken();
310 case ASSIGN_BITOR: case ASSIGN_BITXOR: case ASSIGN_BITAND: case ASSIGN_LSH: case ASSIGN_RSH: case ASSIGN_URSH:
311 case ASSIGN_ADD: case ASSIGN_SUB: case ASSIGN_MUL: case ASSIGN_DIV: case ASSIGN_MOD: {
312 b.add(parserLine, GET_PRESERVE);
314 b.add(parserLine, tok - 1);
315 b.add(parserLine, PUT);
316 b.add(parserLine, SWAP);
317 b.add(parserLine, POP);
320 case INC: case DEC: { // postfix
321 b.add(parserLine, GET_PRESERVE);
322 b.add(parserLine, LITERAL, new Integer(1));
323 b.add(parserLine, tok == INC ? ADD : SUB);
324 b.add(parserLine, PUT);
325 b.add(parserLine, SWAP);
326 b.add(parserLine, POP);
327 b.add(parserLine, LITERAL, new Integer(1));
328 b.add(parserLine, tok == INC ? SUB : ADD);
333 b.add(parserLine, PUT);
334 b.add(parserLine, SWAP);
335 b.add(parserLine, POP);
339 int n = parseArgs(b);
340 b.add(parserLine,CALLMETHOD,new Integer(n));
345 if(b.get(b.size()-1) == LITERAL && b.getArg(b.size()-1) != null)
346 b.set(b.size()-1,GET,b.getArg(b.size()-1));
348 b.add(parserLine, GET);
356 * Assuming that a complete expression has just been parsed,
357 * <tt>continueExpr</tt> will attempt to extend this expression by
358 * parsing additional tokens and appending additional bytecodes.
360 * No operators with precedence less than <tt>minPrecedence</tt>
363 * If any bytecodes are appended, they will not alter the stack
366 private void continueExpr(CompiledFunctionImpl b, int minPrecedence) throws IOException {
367 int saveParserLine = parserLine;
368 _continueExpr(b, minPrecedence);
369 parserLine = saveParserLine;
371 private void _continueExpr(CompiledFunctionImpl b, int minPrecedence) throws IOException {
372 if (b == null) throw new Error("got null b; this should never happen");
373 int tok = getToken();
374 if (tok == -1) return;
375 if (minPrecedence != -1 && (precedence[tok] < minPrecedence || (precedence[tok] == minPrecedence && !isRightAssociative[tok]))) {
381 case LP: { // invocation (not grouping)
382 int n = parseArgs(b);
383 b.add(parserLine, CALL, new Integer(n));
386 case BITOR: case BITXOR: case BITAND: case SHEQ: case SHNE: case LSH:
387 case RSH: case URSH: case ADD: case MUL: case DIV: case MOD:
388 case GT: case GE: case EQ: case NE: case LT: case LE: case SUB: {
389 startExpr(b, precedence[tok]);
390 b.add(parserLine, tok);
394 b.add(parserLine, tok == AND ? b.JF : b.JT, new Integer(0)); // test to see if we can short-circuit
396 startExpr(b, precedence[tok]); // otherwise check the second value
397 b.add(parserLine, JMP, new Integer(2)); // leave the second value on the stack and jump to the end
398 b.add(parserLine, LITERAL, tok == AND ?
399 new Boolean(false) : new Boolean(true)); // target of the short-circuit jump is here
400 b.set(size - 1, new Integer(b.size() - size)); // write the target of the short-circuit jump
405 b.add(parserLine, LITERAL, string);
406 continueExprAfterAssignable(b);
409 case LB: { // subscripting (not array constructor)
412 continueExprAfterAssignable(b);
416 b.add(parserLine, JF, new Integer(0)); // jump to the if-false expression
418 startExpr(b, -1); // write the if-true expression
419 b.add(parserLine, JMP, new Integer(0)); // if true, jump *over* the if-false expression
420 b.set(size - 1, new Integer(b.size() - size + 1)); // now we know where the target of the jump is
423 startExpr(b, -1); // write the if-false expression
424 b.set(size - 1, new Integer(b.size() - size + 1)); // this is the end; jump to here
433 continueExpr(b, minPrecedence); // try to continue the expression
436 // parse a set of comma separated function arguments, assume LP has already been consumed
437 private int parseArgs(CompiledFunctionImpl b) throws IOException {
439 while(peekToken() != RP) {
441 if (peekToken() != COMMA) {
443 if (peekToken() == RP) break;
451 /** Parse a block of statements which must be surrounded by LC..RC. */
452 void parseBlock(CompiledFunctionImpl b) throws IOException { parseBlock(b, null); }
453 void parseBlock(CompiledFunctionImpl b, String label) throws IOException {
454 int saveParserLine = parserLine;
455 _parseBlock(b, label);
456 parserLine = saveParserLine;
458 void _parseBlock(CompiledFunctionImpl b, String label) throws IOException {
459 if (peekToken() == -1) return;
460 else if (peekToken() != LC) parseStatement(b, null);
463 while(peekToken() != RC && peekToken() != -1) parseStatement(b, null);
468 /** Parse a single statement, consuming the RC or SEMI which terminates it. */
469 void parseStatement(CompiledFunctionImpl b, String label) throws IOException {
470 int saveParserLine = parserLine;
471 _parseStatement(b, label);
472 parserLine = saveParserLine;
474 void _parseStatement(CompiledFunctionImpl b, String label) throws IOException {
475 int tok = peekToken();
476 if (tok == -1) return;
477 switch(tok = getToken()) {
479 case THROW: case ASSERT: case RETURN: {
480 if (tok == RETURN && peekToken() == SEMI)
481 b.add(parserLine, LITERAL, null);
484 b.add(parserLine, tok);
488 case BREAK: case CONTINUE: {
489 if (peekToken() == NAME) consume(NAME);
490 b.add(parserLine, tok, string);
495 b.add(parserLine, TOPSCOPE); // push the current scope
498 b.add(parserLine, DECLARE, string); // declare it
499 if (peekToken() == ASSIGN) { // if there is an '=' after the variable name
502 b.add(parserLine, PUT); // assign it
503 b.add(parserLine, POP); // clean the stack
505 b.add(parserLine, POP); // pop the string pushed by declare
507 if (peekToken() != COMMA) break;
510 b.add(parserLine, POP); // pop off the topscope
511 if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
519 b.add(parserLine, JF, new Integer(0)); // if false, jump to the else-block
521 parseStatement(b, null);
523 if (peekToken() == ELSE) {
525 b.add(parserLine, JMP, new Integer(0)); // if we took the true-block, jump over the else-block
526 b.set(size - 1, new Integer(b.size() - size + 1));
528 parseStatement(b, null);
530 b.set(size - 1, new Integer(b.size() - size + 1)); // regardless of which branch we took, b[size] needs to point here
535 if (label != null) b.add(parserLine, LABEL, label);
536 b.add(parserLine, LOOP);
538 b.add(parserLine, POP); // discard the first-iteration indicator
540 b.add(parserLine, JT, new Integer(2)); // if the while() clause is true, jump over the BREAK
541 b.add(parserLine, BREAK);
543 parseStatement(b, null);
544 b.add(parserLine, CONTINUE); // if we fall out of the end, definately continue
545 b.set(size - 1, new Integer(b.size() - size + 1)); // end of the loop
550 if (label != null) b.add(parserLine, LABEL, label);
551 b.add(parserLine, LOOP);
552 int size0 = b.size();
557 if (peekToken() == CASE) { // we compile CASE statements like a bunch of if..else's
559 b.add(parserLine, DUP); // duplicate the switch() value; we'll consume one copy
562 b.add(parserLine, EQ); // check if we should do this case-block
563 b.add(parserLine, JF, new Integer(0)); // if not, jump to the next one
565 while(peekToken() != CASE && peekToken() != DEFAULT && peekToken() != RC) parseStatement(b, null);
566 b.set(size - 1, new Integer(1 + b.size() - size));
567 } else if (peekToken() == DEFAULT) {
570 while(peekToken() != CASE && peekToken() != DEFAULT && peekToken() != RC) parseStatement(b, null);
571 } else if (peekToken() == RC) {
573 b.add(parserLine, BREAK); // break out of the loop if we 'fall through'
576 throw pe("expected CASE, DEFAULT, or RC; got " + codeToString[peekToken()]);
578 b.set(size0 - 1, new Integer(b.size() - size0 + 1)); // end of the loop
583 if (label != null) b.add(parserLine, LABEL, label);
584 b.add(parserLine, LOOP);
586 parseStatement(b, null);
590 b.add(parserLine, JT, new Integer(2)); // check the while() clause; jump over the BREAK if true
591 b.add(parserLine, BREAK);
592 b.add(parserLine, CONTINUE);
595 b.set(size - 1, new Integer(b.size() - size + 1)); // end of the loop; write this location to the LOOP instruction
600 b.add(parserLine, TRY); // try bytecode causes a TryMarker to be pushed
601 int tryInsn = b.size() - 1;
602 // parse the expression to be TRYed
603 parseStatement(b, null);
604 // pop the try marker. this is pushed when the TRY bytecode is executed
605 b.add(parserLine, POP);
606 // jump forward to the end of the catch block, start of the finally block
607 b.add(parserLine, JMP);
608 int successJMPInsn = b.size() - 1;
610 if (peekToken() != CATCH && peekToken() != FINALLY)
611 throw pe("try without catch or finally");
613 int catchJMPDistance = -1;
614 if (peekToken() == CATCH) {
615 catchJMPDistance = b.size() - tryInsn;
620 exceptionVar = string;
622 b.add(parserLine, TOPSCOPE); // the exception is on top of the stack; put it to the chosen name
623 b.add(parserLine, SWAP);
624 b.add(parserLine, LITERAL,exceptionVar);
625 b.add(parserLine, SWAP);
626 b.add(parserLine, PUT);
627 b.add(parserLine, POP);
628 b.add(parserLine, POP);
629 parseStatement(b, null);
630 // pop the try and catch markers
631 b.add(parserLine,POP);
632 b.add(parserLine,POP);
635 // jump here if no exception was thrown
636 b.set(successJMPInsn, new Integer(b.size() - successJMPInsn));
638 int finallyJMPDistance = -1;
639 if (peekToken() == FINALLY) {
640 b.add(parserLine, LITERAL, null); // null FinallyData
641 finallyJMPDistance = b.size() - tryInsn;
643 parseStatement(b, null);
644 b.add(parserLine,FINALLY_DONE);
647 // setup the TRY arguments
648 b.set(tryInsn, new int[] { catchJMPDistance, finallyJMPDistance });
657 boolean hadVar = false; // if it's a for..in, we ignore the VAR
658 if (tok == VAR) { hadVar = true; tok = getToken(); }
659 String varName = string;
660 boolean forIn = peekToken() == IN; // determine if this is a for..in loop or not
661 pushBackToken(tok, varName);
664 b.add(parserLine, NEWSCOPE); // for-loops always create new scopes
665 b.add(parserLine, LITERAL, varName); // declare the new variable
666 b.add(parserLine, DECLARE);
668 b.add(parserLine, LOOP); // we actually only add this to ensure that BREAK works
669 b.add(parserLine, POP); // discard the first-iteration indicator
674 b.add(parserLine, PUSHKEYS); // push the keys as an array; check the length
675 b.add(parserLine, LITERAL, "length");
676 b.add(parserLine, GET);
679 b.add(parserLine, LITERAL, new Integer(1)); // decrement the length
680 b.add(parserLine, SUB);
681 b.add(parserLine, DUP);
682 b.add(parserLine, LITERAL, new Integer(0)); // see if we've exhausted all the elements
683 b.add(parserLine, LT);
684 b.add(parserLine, JF, new Integer(2));
685 b.add(parserLine, BREAK); // if we have, then BREAK
686 b.add(parserLine, GET_PRESERVE); // get the key out of the keys array
687 b.add(parserLine, LITERAL, varName);
688 b.add(parserLine, PUT); // write it to this[varName]
689 parseStatement(b, null); // do some stuff
690 b.add(parserLine, CONTINUE); // continue if we fall out the bottom
692 b.set(size - 1, new Integer(b.size() - size + 1)); // BREAK to here
693 b.add(parserLine, OLDSCOPE); // restore the scope
696 if (hadVar) pushBackToken(VAR, null); // yeah, this actually matters
697 b.add(parserLine, NEWSCOPE); // grab a fresh scope
699 parseStatement(b, null); // initializer
700 CompiledFunctionImpl e2 = // we need to put the incrementor before the test
701 new JS.CompiledFunction(sourceName, parserLine, null, null); // so we save the test here
702 if (peekToken() != SEMI)
705 e2.add(parserLine, b.LITERAL, Boolean.TRUE); // handle the for(foo;;foo) case
707 if (label != null) b.add(parserLine, LABEL, label);
708 b.add(parserLine, LOOP);
709 int size2 = b.size();
711 b.add(parserLine, JT, new Integer(0)); // if we're on the first iteration, jump over the incrementor
713 if (peekToken() != RP) { // do the increment thing
715 b.add(parserLine, POP);
717 b.set(size - 1, new Integer(b.size() - size + 1));
720 b.paste(e2); // ok, *now* test if we're done yet
721 b.add(parserLine, JT, new Integer(2)); // break out if we don't meet the test
722 b.add(parserLine, BREAK);
723 parseStatement(b, null);
724 b.add(parserLine, CONTINUE); // if we fall out the bottom, CONTINUE
725 b.set(size2 - 1, new Integer(b.size() - size2 + 1)); // end of the loop
727 b.add(parserLine, OLDSCOPE); // get our scope back
732 case NAME: { // either a label or an identifier; this is the one place we're not LL(1)
733 String possiblyTheLabel = string;
734 if (peekToken() == COLON) { // label
736 parseStatement(b, possiblyTheLabel);
738 } else { // expression
739 pushBackToken(NAME, possiblyTheLabel);
741 b.add(parserLine, POP);
742 if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
747 case SEMI: return; // yep, the null statement is valid
749 case LC: { // blocks are statements too
751 b.add(parserLine, NEWSCOPE);
752 parseBlock(b, label);
753 b.add(parserLine, OLDSCOPE);
757 default: { // hope that it's an expression
760 b.add(parserLine, POP);
761 if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
768 // ParserException //////////////////////////////////////////////////////////////////////
769 private IOException pe(String s) { return new IOException(sourceName + ":" + parserLine + " " + s); }