Lexer and parser generators using CTFE

John Belmonte john at neggie.net
Mon May 28 14:42:26 PDT 2012


On Monday, 28 May 2012 at 12:27:09 UTC, Philippe Sigaud wrote:
> I played with this idea with my own Pegged
> (https://github.com/PhilippeSigaud/Pegged), but I wasn't quite
> convinced by the result, exactly for the reason above. Also, 
> when
> looking at real-world Spirit examples, I was a bit disappointed 
> by the
> resulting syntax: it's not *that* readable for complicated
> expressions. In fact, that's exactly why I decided to follow 
> the DSL
> road with Pegged, so as to obtain exactly the PEG syntax, with 
> the
> real operators and their standard precedence.

Fair enough.  I did notice the following in the markdown PEG 
though which could benefit from first class patterns:


# Parsers for different kinds of block-level HTML content.
# This is repetitive due to constraints of PEG grammar.

HtmlBlockOpenAddress <- '<' Spnl ("address" / "ADDRESS") Spnl 
HtmlAttribute* '>'
HtmlBlockCloseAddress <- '<' Spnl '/' ("address" / "ADDRESS") 
Spnl '>'
HtmlBlockAddress <- HtmlBlockOpenAddress (HtmlBlockAddress /
    !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress

HtmlBlockOpenBlockquote <- '<' Spnl ("blockquote" / "BLOCKQUOTE") 
Spnl
    HtmlAttribute* '>'
HtmlBlockCloseBlockquote <- '<' Spnl '/' ("blockquote" / 
"BLOCKQUOTE") Spnl '>'
HtmlBlockBlockquote <- HtmlBlockOpenBlockquote 
(HtmlBlockBlockquote /
    !HtmlBlockCloseBlockquote .)* HtmlBlockCloseBlockquote

.
.
.



More information about the Digitalmars-d mailing list