[antlr-interest] possible bug?

Sam Harwell sharwell at pixelminegames.com
Tue Nov 18 08:05:44 PST 2008


You might try the following:

fragment IP : ;
fragment IPNET : ;

NUMBER
  : NumberFormat
    ( POINT NumberFormat POINT NumberFormat POINT NumberFormat {$type =
IP;}
      ( SLASH NumberFormat {$type = IPNET;}
      )?
    )?
  ;

NumberFormat
  : '0' | '1'..'9' DIGIT*
  ;

Then validate a proper IP either at the end of the number rule, or
possibly in the parser, so you can print an informative message about a
malformed IP.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of micha
Sent: Tuesday, November 18, 2008 6:54 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] possible bug?

the followinig lexer grammar:
 lexer grammar Lexbug;

 SLASH: '/';
 POINT: '.';

 fragment DIGIT: '0'..'9';
 fragment BYTE: DIGIT | '1'..'9' DIGIT | '1' DIGIT DIGIT | '2' '0'..'4'
 DIGIT | '25' '0'..'6';

 IP: BYTE POINT BYTE POINT BYTE POINT BYTE;
 NUMBER: '0' | '1'..'9' DIGIT*;


produces 13kb of java code and all works well.

If I add the definition:
 IPNET: IP SLASH NUMBER;

then I get 22MB output (!)

Is this o.k.? I didn't thought, that this rule requires so much code :-)

cheer
 Michael





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



More information about the antlr-interest mailing list