Loading ...
Sorry, an error occurred while loading the content.
 

Re: [antlr-interest] Parsing an IP Address

Expand Messages
  • Ross Bencina
    ... The colon syntax cannot be used for non-terminals. I m not exactly sure what you re trying to do, but you might need something like: seg returns [
    Message 1 of 2 , Mar 31, 2003
      > ip
      > : i: seg DOT seg DOT seg DOT seg
      > {Console.Out.WriteLine(i.getText());}
      > ;
      >
      > I am getting a number of errors: one says that the type or
      > namespace 'i' cannot be found, and another says that the type or
      > namespace "lexer" cannot be found.

      The colon syntax cannot be used for non-terminals.

      I'm not exactly sure what you're trying to do, but you might need something
      like:

      seg returns [ RefToken result ]
      : s:IPSEG
      { result=s; }
      ;

      ip
      {
      RefToken i;
      }
      : i=seg DOT seg DOT seg DOT seg
      {Console.Out.WriteLine(i->getText());}
      ;

      I think RefToken is not the correct type, but you should be able to work it
      out by examining the generated source.

      Ross.
    Your message has been successfully submitted and would be delivered to recipients shortly.