Author: dda
Date: 2007-12-17 20:02:35 -0800 (Mon, 17 Dec 2007)
New Revision: 7583
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
Log:
Change 20071217-dda-v by [EMAIL PROTECTED] on 2007-12-17 22:56:41 EST
in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
for http://svn.openlaszlo.org/openlaszlo/branches/devildog
Summary: More accurate parsing of varargs syntax.
New Features: none
Bugs Fixed: LPP-5273
Technical Reviewer: ptw (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)
Documentation: none
Release Notes: none
Details:
This fixes the grammar to require that the '...rest' syntax,
if it appears at all in a formal argument declaration, appears
as the last argument.
Tests:
Tried some simple tests like:
function f1(x,...y) { }
function f2(...x) { }
function f3(...x,y) { }
to verify that the first two pass and the last one fails.
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
---
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
2007-12-18 04:02:07 UTC (rev 7582)
+++
openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
2007-12-18 04:02:35 UTC (rev 7583)
@@ -876,16 +876,26 @@
void FormalParameters() : {}
{
- FormalParameter() ("," FormalParameter())*
+ FormalParameter() (LOOKAHEAD(2) "," FormalParameter())* [","
FormalRestParameter()]
+| FormalRestParameter()
}
-void FormalParameter() #void : {boolean ellipsis = false; ASTIdentifier id;
ASTIdentifier.Type type;}
+void FormalRestParameter() #void : {ASTIdentifier id;}
{
- ["..." { ellipsis = true; }]
- id = Identifier() { id.setEllipsis(ellipsis); }
- [":" type = TypeIdentifier() { id.setType(type); }]
+ "..." id = FormalParameterIdentifier() { id.setEllipsis(true); }
}
+void FormalParameter() #void : {ASTIdentifier id;}
+{
+ id = FormalParameterIdentifier() { id.setEllipsis(false); }
+}
+
+ASTIdentifier FormalParameterIdentifier() #void : {ASTIdentifier id;
ASTIdentifier.Type type;}
+{
+ (id = Identifier() [":" type = TypeIdentifier() { id.setType(type); }])
+ { return id; }
+}
+
// Program structuring/
SimpleNode Program() #Program : {}
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins