breck7 / scrollsdk

Build on top of Scroll.
https://sdk.scroll.pub
382 stars 17 forks source link

formal grammar #1

Closed daxim closed 7 years ago

daxim commented 7 years ago

Please provide a grammar of TN in ABNF.

breck7 commented 7 years ago

Thanks for the suggestion @daxim ! It's quite a short grammar and shouldn't be too hard to write it in ABNF. To write a perfect grammar in ABNF though (ensuring all the edge cases are handled correctly) might take me a few hours. For now, here's a rough grammar in ANTLR4 that I just wrote and tested. I'm sure there's at least a bug or two in there but gives you a rough idea of the grammar.

ANTLR4

/** The TreeNotation grammar. */
grammar TreeNotation;

plane : node+;

node: (xi|words|YI) words? YI?;

words: word SPACE? words?;

xi: SPACE+;
word: WORDCHAR+;

SPACE: ' ';
YI: '\n';
WORDCHAR: ~[ \n];
breck7 commented 7 years ago

Does that help at all @daxim or do you specifically need the grammar in ABNF notation?

If anyone has more experience in writing ABNF's and wants to take the lead, I'd be happy to assist and that might be the fastest way to get a bug-free one written.

daxim commented 7 years ago

That's sufficient for translation, thanks!

; uppercase rules names are defined in core
plane = 1*node
node = ( xi / words / LF ) [words] [LF]
words = word [SP] [words]
xi = 1*SP
word = 1*wordchar
; rule originally defined as "any char excluding SP or LF"
wordchar = %x00-09 / %x0B-1F / %x21-FF