[Nice-commit] Nice/src/bossa/parser Parser.jj,1.248,1.249
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-07-28 14:40:43
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22973/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Conversion of some expression and statement classes in bossa.syntax to nice code. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.248 retrieving revision 1.249 diff -C2 -d -r1.248 -r1.249 *** Parser.jj 16 Jul 2004 10:01:33 -0000 1.248 --- Parser.jj 28 Jul 2004 14:40:34 -0000 1.249 *************** *** 877,881 **** makeLocation(first, last)); } else { ident = id; } ! Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); --- 877,881 ---- makeLocation(first, last)); } else { ident = id; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); *************** *** 1340,1344 **** ( ".." "." { return null; } // toplevel function in interface file | ! exp=Expression() ";" { code = new ReturnStmt(exp, /* fake */ true); } | {Statement res;} --- 1340,1344 ---- ( ".." "." { return null; } // toplevel function in interface file | ! exp=Expression() ";" { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } | {Statement res;} *************** *** 1751,1755 **** makeLocation(first, last)); } else { name = ident; } ! Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); --- 1751,1755 ---- makeLocation(first, last)); } else { name = ident; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); *************** *** 1761,1765 **** } ! FunExp funExp(): { List formals = new LinkedList(); --- 1761,1765 ---- } ! Expression funExp(): { List formals = new LinkedList(); *************** *** 1786,1793 **** body=RootShortStatement() | ! exp=Expression() { body = new ReturnStmt(exp); } ) { statements.add(body); ! return new FunExp(cst, formals, new Block(statements)); } } --- 1786,1793 ---- body=RootShortStatement() | ! exp=Expression() { body = bossa.syntax.dispatch.createReturnStmt(exp); } ) { statements.add(body); ! return bossa.syntax.dispatch.createFunExp(cst, formals, new Block(statements)); } } *************** *** 1846,1850 **** } { ! "[]" { return new LiteralArrayExp(null); } | "[" { exps = new LinkedList(); } --- 1846,1850 ---- } { ! "[]" { return bossa.syntax.dispatch.createLiteralArrayExp(null); } | "[" { exps = new LinkedList(); } *************** *** 1856,1860 **** ] "]" ! { return new LiteralArrayExp(exps); } } --- 1856,1860 ---- ] "]" ! { return bossa.syntax.dispatch.createLiteralArrayExp(exps); } } *************** *** 1938,1942 **** e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=AssignExp.create(e1,e2); } ] --- 1938,1942 ---- e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=bossa.syntax.dispatch.createAssignExp(e1,e2); } ] *************** *** 2169,2173 **** { ( t="++" {inc = true;} | t="--" ) res=PrimaryExpression() ! { return new IncrementExp(res, true, inc); } } --- 2169,2173 ---- { ( t="++" {inc = true;} | t="--" ) res=PrimaryExpression() ! { return bossa.syntax.dispatch.createIncrementExp(res, true, inc); } } *************** *** 2176,2181 **** { res=PrimaryExpression() ! [ "++" { res=new IncrementExp(res, false, true); } ! | "--" { res=new IncrementExp(res, false, false); } ] { return res; } --- 2176,2181 ---- { res=PrimaryExpression() ! [ "++" { res=bossa.syntax.dispatch.createIncrementExp(res, false, true); } ! | "--" { res=bossa.syntax.dispatch.createIncrementExp(res, false, false); } ] { return res; } *************** *** 2397,2401 **** } ! Statement Block() : { Token first, last; Statement s; List statements; } { --- 2397,2401 ---- } ! Block Block() : { Token first, last; Statement s; List statements; } { *************** *** 2407,2411 **** { last = getToken(0); ! Statement res = new Block(statements); res.setLocation(makeLocation(first, last)); return res; --- 2407,2411 ---- { last = getToken(0); ! Block res = new Block(statements); res.setLocation(makeLocation(first, last)); return res; *************** *** 2491,2495 **** last=")" "=" e=Expression() ";" ! { Expression exp = AssignExp.create(new TupleExp(parts), e); exp.setLocation(makeLocation(first,last)); return new ExpressionStmt(exp); } --- 2491,2495 ---- last=")" "=" e=Expression() ";" ! { Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts), e); exp.setLocation(makeLocation(first,last)); return new ExpressionStmt(exp); } *************** *** 2640,2646 **** { ( ! "++" { e1=new IncrementExp(e1, false, true); } | ! "--" { e1=new IncrementExp(e1, false, false); } | { Token op; Expression e2; --- 2640,2646 ---- { ( ! "++" { e1=bossa.syntax.dispatch.createIncrementExp(e1, false, true); } | ! "--" { e1=bossa.syntax.dispatch.createIncrementExp(e1, false, false); } | { Token op; Expression e2; *************** *** 2653,2657 **** e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=AssignExp.create(e1,e2); } ) --- 2653,2657 ---- e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=bossa.syntax.dispatch.createAssignExp(e1,e2); } ) *************** *** 2670,2677 **** s1=Statement() [ LOOKAHEAD(1) "else" s2=Statement() ] { ! ifExp = new IfExp(cond, new StatementExp(s1), ! (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); ! return new ExpressionStmt(ifExp); } } --- 2670,2675 ---- s1=Statement() [ LOOKAHEAD(1) "else" s2=Statement() ] { ! return bossa.syntax.dispatch.createIfStmt(cond, s1, s2, ! makeLocation(first, getToken(0))); } } *************** *** 2688,2695 **** s1=ShortStatement() [ LOOKAHEAD(1) "else" s2=ShortStatement() ] { ! ifExp = new IfExp(cond, new StatementExp(s1), ! (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); ! return new ExpressionStmt(ifExp); } } --- 2686,2691 ---- s1=ShortStatement() [ LOOKAHEAD(1) "else" s2=ShortStatement() ] { ! return bossa.syntax.dispatch.createIfStmt(cond, s1, s2, ! makeLocation(first, getToken(0))); } } *************** *** 2699,2703 **** { "while" "(" cond=Expression() ")" body=Statement() ! { return LoopStmt.whileLoop(cond,body); } } --- 2695,2699 ---- { "while" "(" cond=Expression() ")" body=Statement() ! { return bossa.syntax.dispatch.createWhileLoop(cond,body); } } *************** *** 2706,2714 **** { "do" body=Statement() "while" "(" cond=Expression() ")" ";" ! { return LoopStmt.doLoop(cond,body); } } Statement ForStatement() : ! { Statement update = null, loop = null, body, statexp; Expression cond = null; List init = new ArrayList(); --- 2702,2711 ---- { "do" body=Statement() "while" "(" cond=Expression() ")" ";" ! { return bossa.syntax.dispatch.createDoLoop(cond,body); } } Statement ForStatement() : ! { Block update = null; ! Statement loop = null, body, statexp; Expression cond = null; List init = new ArrayList(); *************** *** 2729,2733 **** body=Statement() { ! loop=LoopStmt.forLoop(cond,update,body); List l = new LinkedList(); l.addAll(init); --- 2726,2730 ---- body=Statement() { ! loop=bossa.syntax.dispatch.createForLoop(cond,update,body); List l = new LinkedList(); l.addAll(init); *************** *** 2749,2753 **** t=":" container=Expression() ")" body=Statement() ! { return LoopStmt.forInLoop(vartype,var,makeLocation(t),container,body); } } --- 2746,2750 ---- t=":" container=Expression() ")" body=Statement() ! { return bossa.syntax.dispatch.createForInLoop(vartype,var,makeLocation(t),container,body); } } *************** *** 2761,2765 **** } ! Statement StatementExpressionList() : { Statement s; List statements=new LinkedList(); } { --- 2758,2762 ---- } ! Block StatementExpressionList() : { Statement s; List statements=new LinkedList(); } { *************** *** 2774,2780 **** { "break" [ label=ident() ] ";" ! { if (label == null) return BreakStmt.instance; ! else return new BreakLabelStmt(label); ! } } --- 2771,2775 ---- { "break" [ label=ident() ] ";" ! { return bossa.syntax.dispatch.createBreakStmt(label); } } *************** *** 2783,2787 **** { "continue" [ label=ident() ] ";" ! { return ContinueStmt.make(label); } } --- 2778,2782 ---- { "continue" [ label=ident() ] ";" ! { return bossa.syntax.dispatch.createContinueStmt(label); } } *************** *** 2791,2795 **** t="return" [ val=Expression() ] ";" { ! Statement res = new ReturnStmt(val); res.setLocation(makeLocation(t)); return res; --- 2786,2790 ---- t="return" [ val=Expression() ] ";" { ! Statement res = bossa.syntax.dispatch.createReturnStmt(val); res.setLocation(makeLocation(t)); return res; |