Pegged, From EBNF to PEG

Philippe Sigaud philippe.sigaud at gmail.com
Tue Mar 13 15:43:30 PDT 2012


On Tue, Mar 13, 2012 at 18:05, Alex Rønne Petersen <xtzgzorex at gmail.com> wrote:

>>> lowerCase <- [a-z]
>>> upperCase <- [A-Z]
>>> Identifier <- (lowerCase / upperCase) (lowerCase / upperCase)*
>>
>>
>> Why not:
>> Identifier <- [a-zA-Z]+
>
>
> That was an illustrative example from the Pegged docs. But yeah, you should
> just use a range; reads nicer.

The docs are for teaching PEG :) (btw, it's the docs describe C-like
identifiers, that's why I chose a longer approach)
It's always this 'tension', between inlining and refactoring.
[a-zA-Z]+ is shorter and more readable. But If you decide to extend
your grammar to UTF-32, it'd be easier to just change the 'letter'
rule.


More information about the Digitalmars-d-announce mailing list