[antlr-interest] C++ generated

mzukowski at yci.com mzukowski at yci.com
Fri Oct 3 12:48:32 PDT 2003


Can you make this into a small .g file to try out?  I thought lexer rules
always started with an upper case letter.

Monty

-----Original Message-----
From: jagad [mailto:jagad at enciety.com] 
Sent: Friday, October 03, 2003 11:58 AM
To: ANTLR Milis
Subject: [antlr-interest] C++ generated

Hi All,

in my grammars, I have:

rule1: qualID ((DOT Ident) | (LBRACK exprList RBRACK) | TOPI)*;
rule2: qualID ((DOT Ident) | (LBRACK exprList RBRACK) | TOPI)*;

"rule1" is used by another lex rule and "rule2" is not used (stand
alone). When I see the C++ generated code, rule1 generated as:

....<snip>....
try {      // for error handling
  qualID();
  { // ( ... )*
    for (;;) {
      switch ( LA(1)) {
      case DOT: 
      {
        {
          match(DOT);
          match(Ident);    <------- see this
        }
        break;
      }
      case LBRACK:
....<snip>....

But the rule2 is generated as follow:

....<snip>....
try {      // for error handling
  qualID();
  { // ( ... )*
    for (;;) {
      switch ( LA(1)) {
      case DOT: 
      {
        {
          match(DOT);
          Ident();   <---------- ????
        }
        break;
      }
      case LBRACK:
....<snip>....

My question is, how the rules with the same declaration is generate the
different code? is ANTLR do optimizing or something?

Thanks in Advance and Best Regards

jagad



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list