jtmoulia / neotomex

A PEG parser/transformer with a pleasant Elixir DSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unicode sequences

wstucco opened this issue · comments

What is the best way to use unicode escape sequences when defining rules?
I'm having a problem using them, for example if I write this simple rule


define :test, "[\x{000C}\x{0020}]"

it works, but if I add


define :test, "[\x{000C}\x{0020}\x{200A}]"

I get this error

** (MatchError) no match of right hand side value: {" ", "]"}
    lib/neotomex/grammar.ex:325: Neotomex.Grammar.match/3
    lib/neotomex/grammar.ex:409: Neotomex.Grammar.match_sequence/5
    lib/neotomex/grammar.ex:427: Neotomex.Grammar.match_priorities/4
    lib/neotomex/grammar.ex:332: Neotomex.Grammar.match/3
    lib/neotomex/grammar.ex:409: Neotomex.Grammar.match_sequence/5
    lib/neotomex/grammar.ex:427: Neotomex.Grammar.match_priorities/4
    lib/neotomex/grammar.ex:332: Neotomex.Grammar.match/3
    lib/neotomex/grammar.ex:409: Neotomex.Grammar.match_sequence/5

And if I quote the , I get this error

** (CaseClauseError) no case clause matching: {:ok, {:sequence, []}, "[\\x{000C}\\x{0020}\\x{200A}]"}
    lib/neotomex/exgrammar.ex:182: Neotomex.ExGrammar.parse_expression/1
    lib/neotomex/exgrammar.ex:153: Neotomex.ExGrammar."MACRO-define"/4
    expanding macro: Neotomex.ExGrammar.define/2
    lib/coffeescript.ex:39: Coffeescript (module)

Thanks for the solid report, @wstucco. I've pushed a fix and uploaded a new release to hex: 0.1.4. Let me know if you have more issues.

Thank you for the quick fix!