[antlr-interest] How to Parse a datastream of tokens and values

Weiler-Thiessen, David, SASKATOON, Engineering David.Weiler-Thiessen at purina.nestle.com
Mon Oct 31 10:24:28 PDT 2011


Hi 

 

I am trying to parse a string that is a collection of tokens and values.   For example:

PRCLINTON

 

Where PR is my token, and CLINTON is the value for the token.

 

I have started a simple grammar, see below, but it won't parse the sample above.

 

message              :               productionReceipt

                ;

                

productionReceipt

                :               PR VALUE

                ;

                

PR           :               'PR'

                ;

                

VALUE  :               ('a'..'z'|'A'..'Z')+

                ;

 

 

What am I doing wrong?  I get a MisMatchedTokenException in ANTLRWorks.

David Weiler-Thiessen 
Nestlé Purina PetCare 
phone: 306-933-0232 
cell: 306-291-9770 

This e-mail, its electronic document attachments, and the contents of its website linkages may contain confidential information. This information is intended solely for use by the individual or entity to whom it is addressed. If you have received this information in error, please notify the sender immediately and promptly destroy the material and any accompanying attachments from your system.



More information about the antlr-interest mailing list