[antlr-interest] Why these lex rules make the generated .c source file grow to over 40M size?

chain one chainone at gmail.com
Tue Jan 13 20:01:27 PST 2009


ENTITY_DECL
: 'BEGIN_ENTITY' ( options {greedy=false;} : . )* 'END_ENTITY' SEMI
;
PROCEDURE_DECL
: 'PROCEDURE' ( options {greedy=false;} : . )* 'END_PROCEDURE' SEMI
;

TYPE_DECL
: 'TYPE' ( options {greedy=false;} : . )* 'END_TYPE' SEMI
;
SUBTYPE_CONSTRAINT_DECL
: 'SUBTYPE_CONSTRAINT' ( options {greedy=false;} : . )*
'END_SUBTYPE_CONSTRAINT' SEMI
;

RULE_DECL
: 'RULE' ( options {greedy=false;} : . )* 'END_RULE' SEMI
;

CONSTANT_DECL
: 'CONSTANT' ( options {greedy=false;} : . )*  'END_CONSTANT'
;

REFERENCE_CLAUSE
: 'REFERENCE'  'FROM' ( options {greedy=false;} : . )*  SEMI
;
USE_CLAUSE
:  'USE' 'FROM' ( options {greedy=false;} : . )*  SEMI
;

COMMENT
       :       '(*'
               {
                       $channel=HIDDEN;
               }
               (       ~('('|'*')
                       |       ('(' ~'*') => '('
                       |       ('*' ~')') => '*'
                       |       COMMENT
               )*
               '*)'
       ;
LINECOMMENT
:
'--' ( ~('\n'|'\r') )*
{  $channel=HIDDEN; }
;

SEMI
: ';'
;


LPAREN
: '('
;

RPAREN
: ')'
;

LBRACK
: '['
;

RBRACK
: ']'
;

LCURLY
: '{'
;

RCURLY
: '}'
;

STRING
:
'\''
(~'\'')*
'\''
;

WS
: ( ' '
| '\f'
| '\t'
| ( '\r\n' // Evil Dos
| '\n\r' // Unknown
| '\n' // Unix
| '\r' // Macintosh
)
 )
{ $channel=HIDDEN; }
;

IDENT

: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
;



//==========================================
The size of this generated .c file is so so so large.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090114/c1ddd950/attachment.html 


More information about the antlr-interest mailing list