Closed ethindp closed 1 year ago
The original PEG syntax is described in the following Bryan Ford's web page, and I am able to open the PDF with Acrobat Reader or Preview.app on my iMac. Sorry that I can't give you any more help... https://bford.info/pub/lang/peg.pdf
@yhirose Would you mind duplicating the syntax in the README? I'm blind and though I'm able to read the PDF document, I don't feel like it's being represented properly to my assistive technology.
@ethindp, no problem. I just copied the "PEG formally describing its own ASCII syntax" from the Bryan Ford's paper. This explains the PEG grammar with the PEG grammar itself.
# Hierarchical syntax
Grammar <- Spacing Definition+ EndOfFile
Definition <- Identifier LEFTARROW Expression
Expression <- Sequence (SLASH Sequence)*
Sequence <- Prefix*
Prefix <- (AND / NOT)? Suffix
Suffix <- Primary (QUESTION / STAR / PLUS)?
Primary <- Identifier !LEFTARROW
/ OPEN Expression CLOSE
/ Literal / Class / DOT
# Lexical syntax
Identifier <- IdentStart IdentCont* Spacing
IdentStart <- [a-zA-Z_]
IdentCont <- IdentStart / [0-9]
Literal <- [’] (![’] Char)* [’] Spacing
/ ["] (!["] Char)* ["] Spacing
Class <- ’[’ (!’]’ Range)* ’]’ Spacing
Range <- Char ’-’ Char / Char
Char <- ’\\’ [nrt’"\[\]\\]
/ ’\\’ [0-2][0-7][0-7]
/ ’\\’ [0-7][0-7]?
/ !’\\’ .
LEFTARROW <- ’<-’ Spacing
SLASH <- ’/’ Spacing
AND <- ’&’ Spacing
NOT <- ’!’ Spacing
QUESTION <- ’?’ Spacing
STAR <- ’*’ Spacing
PLUS <- ’+’ Spacing
OPEN <- ’(’ Spacing
CLOSE <- ’)’ Spacing
DOT <- ’.’ Spacing
Spacing <- (Space / Comment)*
Comment <- ’#’ (!EndOfLine .)* EndOfLine
Space <- ’ ’ / ’\t’ / EndOfLine
EndOfLine <- ’\r\n’ / ’\n’ / ’\r’
EndOfFile <- !.
I think the following Wikipedia page explains the PEG grammar easier than the above formal expression. https://en.wikipedia.org/wiki/Parsing_expression_grammar
Hope this information helps!
I'm not sure how my browser circumvents this, but the document describing the PEG syntax is not valid. Adobe Acrobat can't open it, neither can pdftotext or the other tools I've tried. Would you mind describing the syntax in the READMe? Or maybe there's an undamaged copy of the document out there... Idk.