[antlr-interest] (newbie) very basic grammar for simple text and integer

ali azimi aliaazimi at yahoo.com
Sat Aug 4 06:53:55 PDT 2007


Hi,
   
  Thank you very much in advance for reading this.
   
  I am trying to write a simple grammar which can parse something like:
   
  SIGNAL
  Newgame,Probe,Result,
  Endgame,Win,Lose,Score(Integer),Bump (144, 4665);
   
  Just a simple text and a double integer at the end.
   
  For this purpose I wrote the following which is a part of much larger grammar. It seems that I can not figure out how to write a simple grammar for text and integers which causes problem for the rest of the grammar.
   
  Is rule for space ok?
  Is rule for INT ok? (integer starts from 0)
   
  The grammar is:
   
  textDigit: 'text' Text DoubleInteger;
   
  fragment DoubleInteger: '(' INT ',' INT' )' ;
  fragment Special      :'+'|'-'|'!'|'/'|'>'|'8'|'('|')'|'"'|','|';'|'<'|'='|':'|'?'|'&'|'%'|'.'|'_';
  fragment Text         :(AlphaNumeric|Special|Space|Apostrophe)*          ;
  fragment AlphaNumeric :Uppercase|National|Lowercase|Decimaldigit;
  fragment Decimaldigit :'0'..'9' ;
  fragment National     :'#'|'@'|'"'|'$'|'['|']'|'{'|'}'|'^'|'~' ;
  fragment Lowercase    :'a'..'z' ;
  fragment Uppercase    :'A'..'Z' ;
  fragment INT          :('0'..'9')+;
  fragment Space       :(' ')+;
  fragment Apostrophe   :'\'';
   
  I appreciate a lot.
   
  Best regards,
   
  Al         

       
---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070804/6ce01edd/attachment.html 


More information about the antlr-interest mailing list