w3c / cogai

for work by the Cognitive AI community group
Other
53 stars 24 forks source link

Chunk Grammar and railroad diagrams #9

Closed draggett closed 3 years ago

draggett commented 4 years ago

The ABNF grammar format is hard to understand, so it would make sense to include the much easier railroad diagrams for productions. The following were produced using Gunther Rademacher's https://bottlecaps.de/rr/ui online generator with the following grammar:

chunksDoc ::= ws (statement (sep statement) ws)? sep ::= ws (";" | #xA) ws / xA is linefeed or \n */ statement ::= link | rule | chunk link ::= name ws+ name ws+ name rule ::= chunklist ws "=>" ws chunklist chunklist ::= chunk ( ws ',' ws chunk ) chunk ::= type ws+ ID? ws "{" property "}" type ::= name ID ::= name property ::= ws name ws+ valuelist sep valuelist ::= value (ws "," ws valuelist) value ::= boolean | number | name | ISO8601 | string name ::= '@'? [a-zA-Z.-_:/]+ digit boolean ::= "true" | "false" number ::= integer | decimal | double integer ::= [+-]? digit+ decimal ::= [+-]? digit+ '.' digit+ double ::= [+-]? (digit+ '.' digit exp | '.' digit+ exp | digit+ exp) exp ::= [eE] [+-]? digit+ string ::= '"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR) '"' /* string literals exclude #x22=" #x5C=\ #xA=new line #xD=carriage return / ws ::= #x20 | #x9 | #xD | #xA /* #x20=space #x9=character tabulation #xD=carriage return #xA=new line / ISO8601 ::= year ("-" month ("-" day ("T" hour ":" minute second? timezone?)?)?)? /* a commonly used subset of the full ISO 8601 standard */ year ::= digit digit digit digit month ::= digit digit day ::= digit digit hour ::= digit digit minute ::= digit digit second ::= ":" digit digit ("." digit+)? timeszone ::= "Z" | ([+-] h h (":" m m)?) h ::= digit m ::= digit digit ::= [0-9]

See PNG diagrams in chunk-grammar.zip n.b. Github wouldn't accept the XHTML file with embedded SVG, and doesn't appear to accept SVG either, sigh.

tidoust commented 3 years ago

I'm closing this issue as the spec now integrates railroad diagrams. The update process is slightly convoluted (ABNF => EBNF => XHTML => HTML) but in practice one only needs to run npm run update-grammar.