Skip to content

Parsing BNF? #15

@mperham

Description

@mperham

I'm trying to parse the BNF/EBNF found here:

https://gist.githubusercontent.com/springcomp/e72d09e3a8f06e8d711751c3d1ee160e/raw/c58887a2f6c6f41de7a66a472e7c708fa6f64429/JSON.ebnf

It appears to parse fine with a BNF Playground website I found but I get the following error when I use the ebnf gem:

require 'ebnf'

grammar = EBNF.parse(File.open("./json.ebnf"))
puts grammar.to_s
/Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf/parser.rb:304:in `rescue in initialize': ERROR [line: 1] syntax error, expecting "@terminals", "@pass", :LHS (found "<quoted_string> ::= ") (SyntaxError)
	from /Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf/parser.rb:267:in `initialize'
	from /Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf/base.rb:125:in `new'
	from /Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf/base.rb:125:in `initialize'
	from /Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf.rb:29:in `new'
	from /Users/mperham/.gem/ruby/3.3.5/gems/ebnf-2.5.0/lib/ebnf.rb:29:in `parse'
	from lib/jsonebnf.rb:3:in `<main>'

Any tips?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions