[antlr-interest] ANTLR v4 progress

Kyle Ferrio kferrio at gmail.com
Thu May 27 15:45:10 PDT 2010


I think I agree with that for all the situations which come to mind
easily.  Using lexer modes to infer semantic context would be sugar
frosting  at best and an invitation to poor design at worst.  Point
taken.

Kyle


On 5/27/10, Terence Parr <Parrt at cs.usfca.edu> wrote:
> The lexer/parser  really shouldn't interact since they can operate totally
> independently. In most cases what you really want is a scannerless parser,
> which I think I can easily implement as well.
>
> Ter
>
> On May 26, 2010, at 7:07 PM, kferrio at gmail.com wrote:
>
>> Way cool!  Just curious...is the modal state variable automatically
>> accessible to the parser?  Perhaps on a subchannel synced with the token
>> stream?  Sorry to be tuning in late...always interested in new paths to
>> semiosis.  :)   Anyway...I need to take a look at girhub and think up a
>> fun use.
>>
>> Kyle
>>
>> Sent from my Verizon Wireless BlackBerry
>>
>> -----Original Message-----
>> From: Terence Parr <Parrt at cs.usfca.edu>
>> Date: Wed, 26 May 2010 16:18:28
>> To: antlr-interest at antlr.org interest<antlr-interest at antlr.org>
>> Subject: [antlr-interest] ANTLR v4 progress
>>
>> Just passing along an example HTML subset lexer/parser using ANTLR v4;
>> thanks to  debugging and moral support from Oliver Zeigermann, we got the
>> code generation and runtime support working sufficiently to use the
>> following grammars.   generate some really nice code indeed. You will note
>> that, except for the enhancement of the lexer modes, the grammars are
>> backward compatible with v3 :)
>>
>> I still have a long way to go, but it's looking more & more useful (only
>> does LL(1) code generation at this point).
>>
>> Ter
>> ---------------------------
>> lexer grammar HTMLLexer;
>>
>> TAG_START : '<' {pushMode(INSIDE);} ;
>>
>> COMMENT : '<!--' .* '-->' {skip();} ;
>>
>> TEXT : ~'<'+ ;
>>
>> mode INSIDE;
>>
>> TAG_STOP : '>' {popMode();} ;
>>
>> END_TAG : '/' ID '>' {popMode();} ;
>>
>> ID : ('A'..'Z'|'a'..'z'|'0'..'9'|'_'|'#')+ ;
>>
>> EQ : '=' ;
>>
>> STRING : '"' .* '"'
>>       ;
>>
>> WS : ' '+ {skip();} ;
>>
>> ------------------------
>>
>> parser grammar HTMLParser;
>>
>> options { tokenVocab=HTMLLexer; }
>>
>> file : ( TAG_START (starttag | endtag) | TEXT)+ EOF ;
>>
>> starttag : ID attr* TAG_STOP ;
>>
>> attr : ID (EQ (ID|STRING))? ;
>>
>> endtag
>> 	:	 END_TAG
>> 	;
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list