Closed Shorttail closed 10 years ago
On Wed, Dec 25, 2013 at 2:55 PM, Casper Faergemand <notifications@github.com
wrote:
Having tinkered with my own grammar for D, I came to realize that "Spacing" is a magical construct that overrides whatever Pegged use already for spacing.
Spacing is explained here:
Copying the one in the example grammar made all my testcases fail. After adding a few extra symbols from the D language specification, it worked. Specifically:
Space <- "\u0020" / "\u0009" / "\u000b" / "\u000c" / eol
Those are vertical space, tab, horizontal tab and form feed, whereas in the example grammar Space was simply space. I realize now that it's likely because the writer uses spaces exclusively.
Hmm, I thought the inner spacing parser already munched tabs and such. I'll add them, thanks for the head up.
Looking at pegged/peg.d
: it already contains space, tab, vertical tab and all end of line chars (\r
, \n
...). AFAICT, Pegged already does what you want, no?
This works: Spacing <- (Space / Comment)* Space <- "\u0020" / "\u0009" / "\u000b" / "\u000c" / eol
This fails all my testcases: Spacing <- (space / Comment)*
On Thu, Dec 26, 2013 at 10:15 PM, Casper Faergemand < notifications@github.com> wrote:
Spacing <- (Space / Comment)*
Space <- "\u0020" / "\u0009" / "\u000b" / "\u000c" / eol
This works.
Spacing <- (space / Comment)*
This fails all my testcases.
And with the built-in
spacing
instead?
Spacing <- (spacing / Comment)* 23/66 passed. It's all the ones with comments.
Spacing <- (Comment / spacing)* All passing.
Well, lesson learned. Your Dgrammar uses space before Comment, though I haven't tested if that is a problem. I'm guessing something inside spacing eats up bits and pieces of the comments.
Having tinkered with my own grammar for D, I came to realize that "Spacing" is a magical construct that overrides whatever Pegged use already for spacing. Copying the one in the example grammar made all my testcases fail. After adding a few extra symbols from the D language specification, it worked. Specifically:
Space <- "\u0020" / "\u0009" / "\u000b" / "\u000c" / eol
Those are vertical space, tab, horizontal tab and form feed, whereas in the example grammar Space was simply space. I realize now that it's likely because the writer uses spaces exclusively.