[Nice-commit] Nice/src/bossa/parser Parser.jj,1.170,1.171
Brought to you by:
bonniot
From: <bo...@us...> - 2003-05-09 15:28:31
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1:/tmp/cvs-serv12083/src/bossa/parser Modified Files: Parser.jj Log Message: Accept arbitrarily nested tuple assignments. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.170 retrieving revision 1.171 diff -C2 -d -r1.170 -r1.171 *** Parser.jj 9 May 2003 13:17:03 -0000 1.170 --- Parser.jj 9 May 2003 15:28:29 -0000 1.171 *************** *** 2354,2365 **** ) | ! // There are two cases for tuples (declaring a variable or not). ! // Since it seems we cannot have a lookahead inside another we ! // repeat two instances with different lookaheads. ! LOOKAHEAD( "(" monotype() ident() "," ) ! res=LocalTupleDeclaration(statements) ! | ! // Second case (see above). ! LOOKAHEAD( "(" ident() "," ) res=LocalTupleDeclaration(statements) | --- 2354,2359 ---- ) | ! ! LOOKAHEAD( LocalTupleDeclarationLookahead() ) res=LocalTupleDeclaration(statements) | *************** *** 2477,2480 **** --- 2471,2502 ---- return new IdentExp(id); } + } + + void LocalTupleDeclarationLookahead() : {} + { + /* + It is impossible to match exactly the actual syntax of + tuple declarations, because it would require nested lookaheads. + However, since this is the only piece of syntax of the form + ( ... ) = ... + we just do an approximation in LocalTupleDeclarationContent. + The important part is to accept all legal tokens, and to + correctly parse "(" and ")", so we know the end of the tuple. + */ + + "(" LocalTupleDeclarationContent() ")" "=" + } + + void LocalTupleDeclarationContent() : { } + { + ( + "(" LocalTupleDeclarationContent() ")" + // Identifiers, either in types, or as a variable to assign to. + | <IDENT> + // All tokens that can be part of a monotype + // (exception "(" and ")" which are already handled, since they are + // be balanced in a monotype too). + | "<" | ">" | "," | "->" | "." | "?" | "!" | "[]" | "[?]" | "alike" + )+ } |