rr icon indicating copy to clipboard operation
rr copied to clipboard

Can't have close square brackets escaped inside ranges

Open mingodad opened this issue 3 years ago • 5 comments

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:
...]...

mingodad avatar Mar 24 '21 13:03 mingodad

nonsquarebra ::= [^\[\]]

You can rewrite it like this:

nonsquarebra ::= [^#x005B#x005D]

myCrack avatar Mar 24 '21 14:03 myCrack

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 /.../.

mingodad avatar Mar 24 '21 16:03 mingodad

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.

myCrack avatar Mar 24 '21 16:03 myCrack

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 avatar Mar 24 '21 18:03 mingodad

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

mingodad avatar Mar 25 '21 15:03 mingodad

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

GuntherRademacher avatar Jan 06 '23 16:01 GuntherRademacher