[antlr-interest] Need help for grammar of TL1 (a language use d in North America in Telecom)

mzukowski at yci.com mzukowski at yci.com
Fri Oct 3 08:33:21 PDT 2003


You've got some serious ambiguities there.  I would recommend maybe using
lexer states or a parser filter as I've outlined at
http://www.codetransform.com/filterexample.html

Also read Ter's lecture on lexers.  Actually read them all, it's worth it.
Should be prominently available from the antlr.org home page.

Monty

-----Original Message-----
From: ilkerpasa135 [mailto:ilkerpasa135 at yahoo.com] 
Sent: Thursday, October 02, 2003 4:17 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Need help for grammar of TL1 (a language used in
North America in Telecom)

I'm new to antlr. And trying to learn antlr and prepare the grammar 
for TL1, a language used in North America for all Telecom equipment. 
Hence when I get it, it could be an interesting addition to antlr 
grammars.

Of course since I'm a newbei, when I run the following grammar I get 
many nondeterminism warnings, basically all over the place.

Past couple of days (not full time tough), I went through antlr 
tutorials, documents, etc , but obviously I haven't gotten it and 
need help. Hence any help is appreciated.

Here is what the TL1 command structure is like;
 VERB-modifier1-modifier2 : TID:AID:CTAG: : NAME=VALUE,NAME=VALUE ;
 VERB-modifier1-modifier2 : TID:AID:CTAG: : VALUE,VALUE ;
 Following are some TL1 command examples;
   ENT-EQPT-OC3:TID1:1-1-#-#-3:ctag123::attrib1=123,attrib2=456;
   ENT-EQPT-OC1:TID1:1-1-#-#-3:ctag123::123,456;


Here is the grammar that I have;

class TL1Parser extends Parser;
options { buildAST=true; }

// first just get TL1command grammar working
//tl1Message       : tl1Command | tl1Acknow | tl1Response | tl1Auto;
tl1Message       : tl1Command;

tl1Command       : (command_code DOUBL^ staging_blocks (DOUBL^ 
payload_blocks)?) SEMI!;

command_code     : VERB (DASH^ modifier1 (DASH^ modifier2)?)?;
modifier1        : NAME;
modifier2        : NAME;

staging_blocks   : TID DOUBL^ AID DOUBL^ CTAG (DOUBL^ general_block)?;
// general_block could be improved
general_block    : NAME;

payload_blocks   : data_block_list (DOUBL^ data_block_list)*;
data_block_list  : data_block (COMMA^ data_block)*;
data_block       : data_block_positional | data_block_named;
data_block_positional : VALUE (COMMA^ VALUE)*;
data_block_named : (NAME EQUAL^ VALUE) (COMMA^ (NAME EQUAL^ VALUE))*;



class TL1Lexer extends Lexer;

AID   : ('a'..'z'|'A'..'Z'|'0'..'9'|'.'|'-'|'_'|'/'|'#')+;
CTAG  : ('a'..'z'|'A'..'Z'|'0'..'9')+;
NAME  : ('a'..'z'|'A'..'Z'|'0'..'9')+;
TID   : ('a'..'z'|'A'..'Z'|'0'..'9'|'.'|'-'|'_'|'/')+;
VALUE : ('a'..'z'|'A'..'Z'|'0'..'9')+;
VERB  : ('a'..'z'|'A'..'Z')+;

COMMA : ',';
DASH  : '-';
DOUBL : ':';
EQUAL : '=';
SEMI  : ';';

WS    : (' ' | '\t'
         | '\r' '\n' { newline(); }
         | '\n'      { newline(); }
        ) 
          { $setType(Token.SKIP); };



 

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