<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.18.3">
</HEAD>
<BODY>
On Tue, 2008-10-14 at 14:59 +0200, Mark Langezaal wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Uhh, subtitles please...
Do you mean this is a kind of a bug, but there is an easy workaround by
removing the brackets?
</PRE>
</BLOCKQUOTE>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
>> // Input: 1 + 2
>> // Generated AST: ^(+ 1 2)
>> okExpr
>> : NUM (('+'|'-')^ NUM)*
</PRE>
</BLOCKQUOTE>
<BR>
<BR>
basiaclly, I think you want:<BR>
<BR>
NUM ((('+')^|('-')^) NUM)*<BR>
<BR>
You can also do:<BR>
<BR>
NUM (arithOp^ NUM)*;<BR>
<BR>
arithOp : '+' | '-' ;<BR>
<BR>
<BR>
Though I personally would get rid of all the literals in the parser grammar and replace them with lexer tokens.<BR>
<BR>
Jim
</BODY>
</HTML>