Hi list,

I am rewriting our old parser and I use antlr3 for that.
Since I have few problem to handle the '{' and to call the appropriate parser
depending on the context, I am wondering if fragment lexer rule + a parameter
could help me.
There are many situations, but I write here 3 cases :
... '->' '{' ... : I need to call a specific parser (#1)
... ':'  '{' ... : I need to call ainother specific parser (#2)
...      '{' ... : I need to do a simple Java treatment

I read few articles and the antlr book, and I saw that it was possible to do
give parameters to a fragment lexer rule. I am wondering if something like that
is OK :

ARROWLBRACE : '->' LBRACE[2] ;
...
<other rules with LBRACE[n]>
...
fragment
LBRACE[int lbtype] : '{'
  {
  switch(lbtype) {
  case 1:
    <Java code1>
  case 2:
    <Java code2>
  case 3:
    <Java code3>
    ...
  }
  }
  ;

But am I also allowed to write a parser rule containing a LBRACE[n] or is it
totally illegal ?
e.g. : 

myRule :
 ... LBRACE[1] ... -> ...
 |... ARROWLBRACE ... -> ... 
 ;

When attempting to do that, I have errors :
"token reference LBRACE may not have parameters"

Is there any good way to solve this type of problem ?

Thanks in advance,

JC

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to