Markdown Extra Spec: Parsing Section

John MacFarlane jgm at berkeley.edu
Tue May 13 02:20:13 EDT 2008



> If we're going this way, there's going to be a learning curve: for

> me, and for everyone trying to understand the syntax. I'd prefer to

> avoid forcing people to learn a new language only to understand the

> specification.


PS. Here's all you have to learn in order to write or read a PEG grammar.

A B C A followed by B followed by C
A | B A or B (ordered choice)
A+ one or more As
A* zero or more As
A? optional A
!A not followed by A
&A followed by A (but does not consume A)
(A B) grouping
. matches any character
'x' matches the character 'x'
"string" matches the string "string"
[a-z] matches a character from 'a' to 'z'

English could be used to specify how a semantic value is to be
constructed for each matching rule. This part would be implemented
differently in different languages, but the basic PEG grammar would be
the same.

John



More information about the Markdown-Discuss mailing list