On Mon, May 28, 2012 at 11:42 PM, John Belmonte <j...@neggie.net> wrote: > 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 >
You're exactly right! Nice catch. I took this PEG from another github project (I hope I put the attribution somewhere?) and that was before Pegged accepted parameterized rules. I could indeed drastically factor the previous code.