[antlr-interest] Newbie Help
Mike Gering
mgering at us.ibm.com
Wed Jan 14 11:33:15 PST 2009
Jim,
Thanks for the suggestion. But
programmatic_unit
: simple_name a b
;
a // line 12
: (STAR simple_name )+
(SLASH simple_name)*
| (SLASH simple_name)*
;
b
:
( (STAR)
INT)?
;
simple_name
: NAME_FRAG
((SPACE)? NAME_FRAG)*
;
Introduces additional warnings:
Foo.g:12: warning:nondeterminism between alts 1 and 2 of block upon
Foo.g:12: k==1:STAR
Foo.g:12: k==2:NAME_FRAG
Foo.g:13: warning:nondeterminism upon
Foo.g:13: k==1:STAR
Foo.g:13: k==2:NAME_FRAG
Foo.g:13: between alt 1 and exit branch of block
And it doesn't express what I need. The grammar has to accept these
examples:
a
a*b
a*b/c
a*b/c*2
a/c
a/c*2
This is a subset of a larger grammar, from DMTF DSP0004, that insists the
programmatic units value consists of named multiplicative factors followed
by named divided factors followed by constant multiplicative factors, e.g.
"byte", "second * 250 * 10^-9", "foot * foot * foot / minute", "second *
250 * 10^-9"
Mike
IBM
(919) 732-5020
From:
Jim Idle <jimi at temporal-wave.com>
To:
Cc:
antlr-interest at antlr.org
Date:
01/14/2009 01:39 PM
Subject:
Re: [antlr-interest] Newbie Help
Mike Gering wrote:
Gavin,
Thanks for the suggestion, but no value of k will work because the grammar
accepts an optional list of tokens between (STAR simple_name)* and "b".
For example:
x*x*x*y/y/y*z
should be accepted. The series of slash terms can be arbitrarily long or
absent.
I think that you want:
a
: (STAR simple_name )+ (SLASH simple_name)*
| (SLASH simple_name)*
;
If you can use ANTLR 3.1 instead you will find this a lot easier.
Jim
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090114/13b2f515/attachment.html
More information about the antlr-interest
mailing list