diff --git a/sources/zweic/Parser.scala b/sources/zweic/Parser.scala index 1dbfa36..3e9eb46 100755 --- a/sources/zweic/Parser.scala +++ b/sources/zweic/Parser.scala @@ -58,7 +58,6 @@ false; override def nextToken: Unit = { - //Console.println(token); pushedBack match { case Some(Triple(p, c, t)) => token = t; @@ -71,17 +70,13 @@ def peekAhead: Token = pushedBack match { case Some(Triple(p, c, t)) => - //Console.println("peekAhead: old:"+t); return t; case _ => - //Console.println("peekAhead: new:"+token); - //Console.println("peekAhead: pb:"+pushedBack); val savedToken = token; val savedChars = chars; val savedPos = pos; nextToken; val rval = token; - //Console.println("peekAhead: pb:"+pushedBack); pushedBack = Some(Triple(pos, chars, token)); token = savedToken; chars = savedChars; @@ -122,10 +117,9 @@ accept(IDENT); } accept (LACCOLADE); - while (token != RACCOLADE) { + while ( !check(RACCOLADE) ) { member(); } - accept (RACCOLADE); return null; } @@ -135,7 +129,6 @@ * "(" [Formal {"," Formal}] ")" Block) */ private def member(): Tree = { - //Console.println("member: "+token); formal(); if (check (SEMICOLON)) { return null; @@ -149,9 +142,7 @@ formal(); } } - //Console.println("member: before accept(RPAREN):"+token); accept (RPAREN); - //Console.println("member: before block:"+token); block(); return null; } @@ -161,7 +152,6 @@ * Formal = Type ident */ private def formal(): Tree = { - //Console.println("formal: "+token); type1(); accept(IDENT); return null; @@ -171,7 +161,6 @@ * Block = "{" {Statements} ["return" Expression] "}" */ private def block(): Tree = { - //Console.println("block: "+token); accept (LACCOLADE); while (token != RETURN && token != RACCOLADE) { statement(); @@ -203,12 +192,9 @@ * | "printChar" "(" Expression ")" ";" */ private def statement(): Tree = { - //Console.println("statement: "+token); if (token == IDENT) { - //Console.println("statement: 1.ident: "+token); peekAhead match { case IDENT => - //Console.println("statement: peek-ident: "+token); //type definition and affection formal(); accept(EQUALS); @@ -216,7 +202,6 @@ accept(SEMICOLON); case EQUALS => - //Console.println("statement: peek-equals: "+token); //affection accept(IDENT); accept(EQUALS); @@ -224,7 +209,6 @@ accept(SEMICOLON); case _ => - //Console.println("statement: peek-_: "+token); //expression expression(); accept(SEMICOLON); @@ -237,11 +221,9 @@ expression(); accept(RPAREN); accept(LACCOLADE); - while ( token != RACCOLADE ) { - //Console.println("statment: while: loop: "+token); + while ( !check(RACCOLADE) ) { statement(); } - accept(RACCOLADE); } else if (token == NULLTYPE || token == INT) { //type definition and affection @@ -276,7 +258,6 @@ * Expression = "if" "(" Expression ")" Expression [ "else" Expression ] | CmpExpression */ private def expression(): Tree = { - //Console.println("expression: "+token); if ( check(IF) ) { accept(LPAREN); expression(); @@ -297,7 +278,6 @@ * MyCmpExpression = SumExpression [ CompOp SumExpression ] */ private def cmpExpression(): Tree = { - //Console.println("cmpExpression: "+token); sumExpression(); if ( token == EQ || token == NE || token == LT || token == GT || token == LE || token == GE ) { @@ -312,7 +292,6 @@ * MySumExpression = Term [ SumOp SumExpression ] */ private def sumExpression(): Tree = { - //Console.println("sumExpression: "+token); term(); if ( token == ADD || token == SUB || token == OR ) { sumOp(); @@ -326,7 +305,6 @@ * MyTerm = [ NegateOp ] Factor [ ProdOp Term ] */ private def term(): Tree = { - //Console.println("term: "+token); if ( token == SUB || token == NOT ) { nextToken; }