Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABNF parsing doesn't work #11

Closed
AaronLasseigne opened this issue Feb 18, 2022 · 1 comment
Closed

ABNF parsing doesn't work #11

AaronLasseigne opened this issue Feb 18, 2022 · 1 comment
Labels

Comments

@AaronLasseigne
Copy link
Contributor

Describe the bug
Parsing ABNF files does not work.

To reproduce
The following uses the latest version of the library and opens examples/abnf/examples/postal-address.abnf from this repo.

> pry
[1] pry(main)> require 'ebnf'
=> true
[2] pry(main)> grammar = EBNF.parse(File.open('postal-address.abnf', format: :abnf))
SyntaxError: ERROR [line: 1] syntax error, expecting "@terminals", "@pass", :LHS (found "postal-address   = n")
from /Users/aaronlasseigne/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ebnf-2.3.0/lib/ebnf/parser.rb:302:in `rescue in initialize'
Caused by EBNF::PEG::Parser::Error: ERROR [line: 1] syntax error, expecting "@terminals", "@pass", :LHS (found "postal-address   = n")
from /Users/aaronlasseigne/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/ebnf-2.3.0/lib/ebnf/peg/parser.rb:253:in `parse'

Expected behavior
Parsing ABNF files works.

@AaronLasseigne
Copy link
Contributor Author

I just noticed the example in the README is wrong. See: https://github.com/dryruby/ebnf#parsing-an-abnf-grammar

- grammar = EBNF.parse(File.open('./etc/abnf.abnf', format: :abnf))
+ grammar = EBNF.parse(File.open('./etc/abnf.abnf'), format: :abnf)

It works as expected. Looks like the README just needs a tweak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant