GuntherRademacher / rr

RR - Railroad Diagram Generator
Apache License 2.0
467 stars 51 forks source link

Can't have close square brackets escaped inside ranges #6

Closed mingodad closed 1 year ago

mingodad commented 3 years ago

Testing a bash grammar I found that rr doesn't accept close square bracket escaped inside ranges (open square brackets it's OK):

nonsquarebra ::=  [^\[\]]

Output:

lexical analysis failed
while expecting [Whitespace, NCName, StringLiteral, CharCode, '/*ws:explicit*/', '/*ws:definition*/', DocComment, EOF, EquivalenceLookAhead, '$', '&', '(', ')', '*', '+', '-', '.', '/', '<?', '<?ENCORE?>', '<?TOKENS?>', '?', '[', '[^', '|']
at line 1, column 25:
...]...
myCrack commented 3 years ago

nonsquarebra ::= [^\[\]]

You can rewrite it like this:

nonsquarebra ::= [^#x005B#x005D]
mingodad commented 3 years ago

Thank you for reply ! Would be nice if rr had an option to relax/accept common escaped sequences \t\r\n\s\S\w\W... or even regular expressions like /.../.

myCrack commented 3 years ago

Would be nice if rr had an option to relax/accept common escaped sequences \t\r\n\s\S\w\W... or even regular expressions like /.../.

RR use ebnf defined by w3c, so i think it is a bad idea.

mingodad commented 3 years ago

That's why I said "Would be nice if rr had an option to relax/accept common escaped sequences" meaning the user would need to check this in the Options tab.

mingodad commented 3 years ago

Also I did converted (naively) several (64) grammars from tree-sitter to the EBNF supported by this project here https://github.com/mingodad/plgh, would be nice to have a link to then in https://www.bottlecaps.de/rr/ui

tree-sitter-abnf.ebnf
tree-sitter-agda.ebnf
tree-sitter-bash.ebnf
tree-sitter-beancount.ebnf
tree-sitter-carp.ebnf
tree-sitter-c.ebnf
tree-sitter-clojure.ebnf
tree-sitter-cpp.ebnf
tree-sitter-c-sharp.ebnf
tree-sitter-css.ebnf
tree-sitter-dart.ebnf
tree-sitter-elm.ebnf
tree-sitter-embedded-template.ebnf
tree-sitter-eno.ebnf
tree-sitter-erlang.ebnf
tree-sitter-fennel.ebnf
tree-sitter-fortran.ebnf
tree-sitter-go.ebnf
tree-sitter-graphql.ebnf
tree-sitter-haskel.ebnf
tree-sitter-html.ebnf
tree-sitter-janet.ebnf
tree-sitter-java.ebnf
tree-sitter-javascript.ebnf
tree-sitter-jsdoc.ebnf
tree-sitter-julia.ebnf
tree-sitter-kotlin.ebnf
tree-sitter-lbnf.ebnf
tree-sitter-lean.ebnf
tree-sitter-ledger.ebnf
tree-sitter-lua.ebnf
tree-sitter-markdown.ebnf
tree-sitter-menhir.ebnf
tree-sitter-minizinc.ebnf
tree-sitter-nim.ebnf
tree-sitter-nix.ebnf
tree-sitter-perl.ebnf
tree-sitter-php.ebnf
tree-sitter-powershell.ebnf
tree-sitter-prolog.ebnf
tree-sitter-python.ebnf
tree-sitter-ql.ebnf
tree-sitter-reason.ebnf
tree-sitter-r.ebnf
tree-sitter-regex.ebnf
tree-sitter-ruby.ebnf
tree-sitter-rust.ebnf
tree-sitter-scala.ebnf
tree-sitter-sexp.ebnf
tree-sitter-sml.ebnf
tree-sitter-sourcepawn.ebnf
tree-sitter-sparql.ebnf
tree-sitter-stan.ebnf
tree-sitter-svelte.ebnf
tree-sitter-swift.ebnf
tree-sitter-systemrdl.ebnf
tree-sitter-teal.ebnf
tree-sitter-toml.ebnf
tree-sitter-turtle.ebnf
tree-sitter-verilog.ebnf
tree-sitter-vhdl.ebnf
tree-sitter-vue.ebnf
tree-sitter-wasm-wast.ebnf
tree-sitter-yaml.ebnf
tree-sitter-zig.ebnf
GuntherRademacher commented 1 year ago

There are no plans to extend the grammar syntax. Please use the notation as already pointed out by @myCrack above.