You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Hierarchical syntax
Grammar <- _Spacing Definition+ _EndOfFile
Definition <- Identifier LEFTARROW Expression SEMI #&${ACCEPT}
Expression <- Sequence ( _SLASH Sequence )*
Sequence <- Prefix* HOLE?
Prefix <- AND HOLE
/ AND Suffix
/ NOT Suffix
/ Suffix
Suffix <- Primary (STARSTAR / PLUSPLUS) Primary
/ Primary (QUESTION
/ STAR
/ PLUS)
/ Primary
Primary <- Super
/ Identifier !LEFTARROW
/ OPEN Expression CLOSE
/ Literal
/ Class
/ DOT
/ BEGIN
/ END
Super <- 'super.' Identifier
# 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 <- '\\' [abefnrtv'"\[\]\\`$]
/ '\\x' [0-9a-fA-F][0-9a-fA-F]
/ '\\' '-'
/ !'\\' .
LEFTARROW <- '<-' _Spacing
_SLASH <- '/' _Spacing #${_ => SKIP};
SEMI <- ';' _Spacing
AND <- '&' _Spacing
NOT <- '~' _Spacing
QUESTION <- '?' _Spacing
STAR <- '*' _Spacing
PLUS <- '+' _Spacing
OPEN <- '(' _Spacing
CLOSE <- ')' _Spacing
DOT <- '.' _Spacing
#_Spacing {I} <- (Space / Comment)* # this line is for chpeg
~_Spacing {I} <- (Space / Comment)* # this line is for cpp-peglib
Comment <- '#' (!EndOfLine .)* EndOfLine
Space <- ' ' / '\t' / EndOfLine
EndOfLine <- '\r\n' / '\n' / '\r'
_EndOfFile <- !.
HOLE_LITERAL <- Literal / [`] < (![`] Char )* > [`] _Spacing
HOLE <- "${" (!'}' ( HOLE_LITERAL / .))* "}" _Spacing
BEGIN <- '<' _Spacing
END <- '>' _Spacing
PLUSPLUS <- '++' _Spacing
STARSTAR <- '**' _Spacing
And with a variant of that I could do a basic conversion of jessica to a peg format that can be used at https://www.bottlecaps.de/convert/ to be converted and generate a navigable railroad diagram.
Copy and paste the grammar shown bellow on https://www.bottlecaps.de/convert/ on the Input grammar: textarea and then click the Convert button then click the View Diagram button (that will appear after the conversion) to view the navigable railroad diagram.
@mingodad wow, this looks like great work! What do you think we should add to this repository? Would you be interesting in submitting a PR? I would happily review, thanks!
Looking through the code I think that adding an option to export the grammar to a format that can be recognized by https://www.bottlecaps.de/rr/ui to generate a navigable railroad diagram (https://en.wikipedia.org/wiki/Syntax_diagram) would make it easier to develop/debug/document
jessica
.For example I manually created a grammar compatible with chpeg / cpp-peglib that can parse
pegquasi
grammars on their playgrounds (https://chrishixon.github.io/chpeg/playground/ , https://yhirose.github.io/cpp-peglib/) :And with a variant of that I could do a basic conversion of
jessica
to a peg format that can be used at https://www.bottlecaps.de/convert/ to be converted and generate a navigable railroad diagram.Copy and paste the grammar shown bellow on https://www.bottlecaps.de/convert/ on the
Input grammar:
textarea and then click theConvert
button then click theView Diagram
button (that will appear after the conversion) to view the navigable railroad diagram.The text was updated successfully, but these errors were encountered: