Just in case someone is interested in the other approach outlined in the
change description (and to archive that solution for future generations):
// separate lexical state for *=, never actually used,
// only added for the effect to get a token constant for *=
<STARASSIGN_STATE>
TOKEN: {
<STARASSIGN: "*=">
}
JAVACODE boolean isSTARASSIGN() {
Token t1 = getToken(1), t2 = getToken(2);
return (t1.kind == STAR
&& t2.kind == ASSIGN
&& t2.specialToken == null
&& t1.beginLine == t2.beginLine
&& t1.endLine == t2.endLine
&& (t1.endColumn + 1) == t2.beginColumn);
}
void AssignmentOperator() #Operator : {Token t;}
{
(("=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" |
"^=" | "|=")
{jjtThis.setOperator(getToken(0).kind);})
|
(LOOKAHEAD({isSTARASSIGN()})
("*" "=")
{jjtThis.setOperator(STARASSIGN);})
}
On 3/30/2011 6:51 PM, P T Withington wrote:
Approved.
This seems like a reasonable solution to a messy problem.
On 2011-03-30, at 12:43, André Bargull wrote:
Change bargull-20110330-C9A by bargull@Bargull02 on 2011-03-30 18:26:50
in /home/anba/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Adjust parser to accept "*=" as untyped type with initializer
Bugs Fixed: LPP-9612 (Lexer needs to learn that `arg:*=default` is not `*=`
operator)
Technical Reviewer: ptw
QA Reviewer: (pending)
Details:
There are basically two ways to fix this bug:
- either remove "*=" as a single token
- or special case "*=" in TypeAndInitializer() and FormalParameter()
The first approach requires some quirks in the lexer, because we still like to create token constants for "*=" and at the same time
"*=" should no longer be parsed as a single token but as "*" and "=". Additionally AssignmentOperator() needs to
special case "*" "=" to create the "*=" operator, so this requires even more hacks...
Therefore I've taken the second approach, that means to handle "*=" in TypeAndInitializer() and
FormalParameter(), so the parser creates the same ast as for "*" "=".
Tests:
test case from bug report
Files:
M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/bargull-20110330-C9A.tar