ranges in ebnf of eto

44 views
Skip to first unread message

Chris Anders

unread,
Jan 30, 2015, 1:12:01 PM1/30/15
to eto-...@googlegroups.com
can i use ranges in ebnf?
like: "a" - "z"

Curtis Wensley

unread,
Jan 30, 2015, 1:37:15 PM1/30/15
to eto-...@googlegroups.com
Yes, if you use the w3c style where [ ] means a character range instead of an optional section.  w3c uses cardinality flags after a terminal or section to denote zero or more (*), one or more (+), or optional (?).

e.g. you can do something like this to match a-z, A-Z, 0-9, and these characters: !@#%

MyTerm ::= [a-zA-Z0-9!@#%];

You can also inverse that by prefixing the sequence with ^, for example:

MyTerm ::= [^a-z]

You can define the specific options of the Ebnf parser to turn on EbnfStyle.CharacterSets, but is mutually exclusive with EbnfStyle.SquareBracketAsOptional.  EbnfStyle.SquareBracketAsOptional takes precedence if you define both flags.

Hope this helps!
Curtis.

Chris Anders

unread,
Jan 31, 2015, 4:29:26 AM1/31/15
to eto-...@googlegroups.com
it doesnt work: error parsing ebnf

with your production

Chris Anders

unread,
Jan 31, 2015, 4:37:49 AM1/31/15
to eto-...@googlegroups.com
it workd now but it doesnt match:
h ::= [a-z]

but your production gives formatexception: error parsing ebnf
Reply all
Reply to author
Forward
0 new messages