[Nice-commit] Nice/src/bossa/parser Parser.jj,1.150,1.151
Brought to you by:
bonniot
|
From: <bo...@us...> - 2003-03-14 14:10:51
|
Update of /cvsroot/nice/Nice/src/bossa/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv15699/src/bossa/parser
Modified Files:
Parser.jj
Log Message:
Allow nested tuples on the left side of a tuple assignment.
Index: Parser.jj
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v
retrieving revision 1.150
retrieving revision 1.151
diff -C2 -d -r1.150 -r1.151
*** Parser.jj 13 Mar 2003 23:19:43 -0000 1.150
--- Parser.jj 14 Mar 2003 14:10:48 -0000 1.151
***************
*** 2391,2419 ****
Statement LocalTupleDeclaration(List statements) :
{
- Monotype t = null;
- LocatedString id;
Expression e;
- LinkedList variables;
}
{
! "(" { variables = new LinkedList(); }
! [ LOOKAHEAD(monotype() ident()) t=monotype() ] id=ident()
! { variables.add(new IdentExp(id));
! if (t != null) {
! statements.add(new Block.LocalVariable(id,t,false,null));
! t = null;
! }
! }
! ( "," [ LOOKAHEAD(monotype() ident()) t=monotype() ] id=ident()
! { variables.add(new IdentExp(id));
! if (t != null) {
! statements.add(new Block.LocalVariable(id,t,false,null));
! t = null;
! }
! }
! )+
")"
"=" e=Expression() ";"
! { return new ExpressionStmt(AssignExp.create(new TupleExp(variables), e)); }
}
--- 2391,2422 ----
Statement LocalTupleDeclaration(List statements) :
{
Expression e;
}
{
! "(" { List parts = new LinkedList(); Expression part; }
! part = LocalTuplePart(statements) { parts.add(part); }
! ( "," part = LocalTuplePart(statements) { parts.add(part); } )+
")"
"=" e=Expression() ";"
! { return new ExpressionStmt(AssignExp.create(new TupleExp(parts), e)); }
! }
!
! Expression LocalTuplePart(List statements) :
! {}
! {
! LOOKAHEAD( "(" LocalTuplePart() "," )
! "(" { List parts = new LinkedList(); Expression part; }
! part = LocalTuplePart(statements) { parts.add(part); }
! ( "," part = LocalTuplePart(statements) { parts.add(part); } )+
! ")"
! { return new TupleExp(parts); }
! |
! { LocatedString id; Monotype type = null; }
! [ LOOKAHEAD(monotype() ident()) type = monotype() ] id = ident()
! {
! if (type != null)
! statements.add(new Block.LocalVariable(id, type, false, null));
! return new IdentExp(id);
! }
}
|