[antlr-interest] C++ generated

jagad jagad at enciety.com
Fri Oct 3 11:58:27 PDT 2003


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/ 




More information about the antlr-interest mailing list