[antlr-interest] Protocol message recognition - an amateur grammar question

Alex Lujan alex at apption.com
Wed Jan 12 08:02:11 PST 2011


I am trying Antlr v3 for message recognition, which must comply to a custom
define protocol.

I find myself unable to express the following rule (written in a
non-standard notation):

data: count number{count.value}

What I am expecting to find in the input is a numerical value (which Ive
labeled count), followed by as many numerical values as the value of count.

Examples of valid input:

3 10 12 15
2 6 9

Examples of invalid input:

3 10 12
2 4 5 6


This seems like a trivial message protocol situation, so I'm hoping this is
a solved problem.

Ive gone through The Definitive Antlr Reference, and can't find information
on quantifiers that would help me solve this issue.

Ideas? guidance?

Thanks very much in advance.

-- 
Alejandro Lujan


More information about the antlr-interest mailing list