[antlr-interest] Can subrules be set to 'n-to-m'?

Scott Stanchfield scott at javadude.com
Sat Mar 26 11:55:15 PST 2005


When I first started demoing ANTLR to the folks I worked with at FGM, all
the extra parens made it LESS readable.

The two folks I had writing the grammar kept writing

    foo+
    foo*

and asking me why antlr was complaining. To which I responded "you've got to
put the terms in parens" to which they responded "why?" to which I responded
"because Ter says so".


> On Mar 25, 2005, at 7:31 PM, Scott Stanchfield wrote:
> 
> > What about consistency with so many prior art examples 
> (like all the 
> > unix
> > regexs?)
> 
> I mean self-consistent not consistent so much with other tools. :)

Expressions like

  2 + 3
  (2 + 3)
  2 + 3 + 4
  (2 + 3) + 4
  ((2 + 3) + 4)

Are **all** self-consistent. The parens are just optional and cane be
included if the writer feels it helps clarify things.

Consistency is in the definition. If the definition says "parens are used to
group one or more terms", it's totally consistent to write

  foo+
  (foo)+
  (foo fee)+

C'mon guys. EVERYONE knows how parens work. EVERYONE knows that you can
write

  2 + 3
  (2 + 3)
  ((2 + 3))
  (((2 + 3)))

And it all means the same thing.

What is the problem here??? Why do you insist on making me waste keystrokes
and make the grammar LESS clear?

Expressions have been written this way for 30 or more years in the computer
field, and well longer than that in mathematics.


PEOPLE GET IT. THEY DON'T NEED TO BE FORCED TO ADD EXTRA SYNTAX.

(Another reason why I did the XML simplification and requested the variable
simplification -- why type what can easily be generated?)


> > This would make ANTLR much more approachable, IMHO.
> 
> "much"?  Probably not ;)

Based on the experience I've had introducing people to ANTLR, yes. They ALL
ask about why the parens are needed.

Think about how many people use regular expressions. 

  a+b*

Rather than

  (a)+(b)*


Why insist on redefining common usage of + and *???

-- Scott





More information about the antlr-interest mailing list