Closed OldhamMade closed 8 years ago
It seems as though the examples all use DOS line endings (CLRF). If you use unix line endings, the parser fails.
Hello!
It is correct that DOS line endings are required in the abnf files since 0.2 (as the README states). The change was made to make it compatible with how the RFC defines the rules:
A rule is defined by the following sequence: name = elements crlf
where
is the name of the rule, is one or more rule names or terminal specifications, and crlf
However, this does work for me:
$ iex -S mix
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (1.1.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> grammar = ABNF.load_file "test/resources/ipv4.abnf"
I'm using elixir 1.1.1 currently. Will try 1.2.0 and let you know.
Interactive Elixir (1.2.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> grammar = ABNF.load_file "test/resources/ipv4.abnf"
iex(2)> ABNF.apply grammar, "ipv4address", '192.168.0.10', %{}
%ABNF.CaptureResult{input: '192.168.0.10', rest: [],
state: %{ipv4address: '192.168.0.10'}, string_text: '192.168.0.10',
string_tokens: ['192', '.', '168', '.', '0', '.', '10'],
values: ["Your ip address is: 192.168.0.10"]}
So I confirm it works with 1.2.0 too.
Could you try specifying the complete path to the ipv4.abnf file? Perhaps it's taking an outdated ipv4 file as input?
Trying to parse the example
test/resources/ipv4.abnf
provided with the repository, I get this result.Unit tests run successfully.
Version info (running on OS X Mavericks 10.11.2):