I have a unit test for a parser of mine:

testLine
        self fail: 'Just a line.' rule: #lineBlank.            "passes"
        self parse: 'Just a line.' rule: #lineNonBlank.   "passes"
        self parse: 'Just a line.' rule: #line.                 "end of input
expected at 0"

Now the fun part:

line
        ^ lineBlank / lineNonBlank

For reference, here are the rest of the involved rules:

blank
        ^ #blank asParser

lineBlank
        ^ blank star

lineNonBlank
        ^ blank star , blank not , lineEnd negate plus

lineEnd
        ^ (Character lf asParser)
                / (Character cr asParser , Character lf asParser optional)

Insights ?

-- 
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Reply via email to