diff --git a/sources/zweic/Parser.scala b/sources/zweic/Parser.scala index 411e43c..1e8223d 100755 --- a/sources/zweic/Parser.scala +++ b/sources/zweic/Parser.scala @@ -368,23 +368,23 @@ private def factor(): Expr = { var name = chars; var rval:Expr = null; - token match { - case IDENT => nextToken; rval = Ident(Name(name)); - case NUMBER => nextToken; rval = IntLit(Integer.parseInt(name)); - case STRING => nextToken; rval = _string(name); - case TRUE => nextToken; rval = IntLit(1); - case FALSE => nextToken; rval = IntLit(0); - case THIS => nextToken; rval = Ident(Name("this")); - case NULLFACTOR => nextToken; rval = NullLit(); - case READINT => nextToken; rval = ReadInt(); - case READCHAR => nextToken; rval = ReadChar(); + rval = token match { + case IDENT => nextToken; Ident(Name(name)); + case NUMBER => nextToken; IntLit(Integer.parseInt(name)); + case STRING => nextToken; _string(name); + case TRUE => nextToken; IntLit(1); + case FALSE => nextToken; IntLit(0); + case THIS => nextToken; Ident(Name("this")); + case NULLFACTOR => nextToken; NullLit(); + case READINT => nextToken; ReadInt(); + case READCHAR => nextToken; ReadChar(); case LPAREN => - nextToken; rval = expression(); - rval.brackets = true; accept(RPAREN); - case LACCOLADE => rval = block(); + nextToken; var t = expression(); t.brackets = true; + accept(RPAREN); t; + case LACCOLADE => block(); case NEW => nextToken; accept(IDENT); - rval = New(Name(chars), params()); - case _ => error("Identifier, Number, String, 'true', 'false', 'this', 'null', 'readInt', 'readChar', '(Expression)', '{Block}' or 'new'"); + New(Name(chars), params()); + case _ => error("Identifier, Number, String, 'true', 'false', 'this', 'null', 'readInt', 'readChar', '(Expression)', '{Block}' or 'new'"); null; } while ( check(DOT) ) { @@ -405,17 +405,13 @@ */ private def expressions(): List[Expr] = { var rval:List[Expr] = Nil; - if ( token == IF || token == SUB || token == NOT - || token == IDENT || token == NUMBER - || token == STRING || token == TRUE - || token == FALSE || token == THIS - || token == NULLFACTOR || token == READINT - || token == READCHAR || token == LPAREN - || token == NEW || token == LACCOLADE ) { - rval = expression()::rval; - while ( check(PERIOD) ) { - rval = expression()::rval; - } + if ( IF :: SUB :: NOT :: IDENT :: NUMBER :: STRING :: TRUE :: FALSE :: THIS + :: NULLFACTOR :: READINT :: READCHAR :: LPAREN :: NEW :: LACCOLADE :: Nil + contains token) { + rval = expression() :: Nil; + while ( check(PERIOD) ) { + rval = expression() :: rval; + } } return rval.reverse; }