jrester / ebnf.cr Goto Github PK
View Code? Open in Web Editor NEWWork with (E)BNF and bison/YACC Grammar: Parsing, FIRST/FOLLOW set, CNF, Conversions, LR and LL parsing tables
License: MIT License
Work with (E)BNF and bison/YACC Grammar: Parsing, FIRST/FOLLOW set, CNF, Conversions, LR and LL parsing tables
License: MIT License
Tried running a couple of the code samples in the Parsing section, got the same error each time:
In lib\ebnf\src\ebnf\grammar\rule.cr:89:48
89 | def initialize(@atoms = Array(Atom).new, @action = nil)
^
Error: instance variable @action of EBNF::Bison::Rule was inferred to be Nil, but Nil alone provides no information
Minimal reproducer with Dockerfile in: https://github.com/lvh/yacc2bnf
Code:
require "ebnf"
grammar = <<-Grammar
root:
foo { puts "foo" }
| bar { puts "bar" }
foo:
A B
| B B
bar:
B A
| A B
Grammar
bison = EBNF::Bison.from grammar
bison.to_bnf
puts bison
Error:
Error in yacc2bnf.cr:18: instantiating 'EBNF::Grammar#to_bnf()'
bison.to_bnf
^~~~~~
in lib/ebnf/src/ebnf/to_bnf.cr:78: instantiating 'EBNF::BNF:Module#from_bison(EBNF::Grammar)'
when Type::Bison then BNF.from_bison dup
^~~~~~~~~~
in lib/ebnf/src/ebnf/to_bnf.cr:6: instantiating 'EBNF::Grammar#each_production()'
grammar.each_production do |production|
^~~~~~~~~~~~~~~
in lib/ebnf/src/ebnf/grammar/grammar.cr:169: instantiating 'Hash(String, EBNF::Production)#each_value()'
@productions.each_value { |production| yield production }
^~~~~~~~~~
in usr/lib/crystal/core/hash.cr:369: instantiating 'each()'
each do |key, value|
^~~~
in usr/lib/crystal/core/hash.cr:369: instantiating 'each()'
each do |key, value|
^~~~
in lib/ebnf/src/ebnf/grammar/grammar.cr:169: instantiating 'Hash(String, EBNF::Production)#each_value()'
@productions.each_value { |production| yield production }
^~~~~~~~~~
in lib/ebnf/src/ebnf/to_bnf.cr:6: instantiating 'EBNF::Grammar#each_production()'
grammar.each_production do |production|
^~~~~~~~~~~~~~~
in lib/ebnf/src/ebnf/to_bnf.cr:7: instantiating 'Array(EBNF::Rule)#each_with_index()'
production.rules.each_with_index do |rule, i|
^~~~~~~~~~~~~~~
in usr/lib/crystal/core/enumerable.cr:377: instantiating 'each()'
each do |elem|
^~~~
in usr/lib/crystal/core/indexable.cr:148: instantiating 'each_index()'
each_index do |i|
^~~~~~~~~~
in usr/lib/crystal/core/indexable.cr:148: instantiating 'each_index()'
each_index do |i|
^~~~~~~~~~
in usr/lib/crystal/core/enumerable.cr:377: instantiating 'each()'
each do |elem|
^~~~
in lib/ebnf/src/ebnf/to_bnf.cr:7: instantiating 'Array(EBNF::Rule)#each_with_index()'
production.rules.each_with_index do |rule, i|
^~~~~~~~~~~~~~~
in lib/ebnf/src/ebnf/to_bnf.cr:9: wrong number of arguments for 'EBNF::Production#[]=' (given 2, expected 1)
Overloads are:
- EBNF::Production#[]=(arg)
production[i] = Rule.new bison_rule.atoms
~/repos/bt/EBNF.cr/ asdf which crystal /Users/b/.asdf/installs/crystal/1.7.2/bin/crystal
~/repos/bt/EBNF.cr/ asdf which shards
/Users/b/.asdf/installs/crystal/1.7.2/embedded/bin/shards
~/repos/bt/EBNF.cr/ shards build --release --production
Dependencies are satisfied
Building: ebnf
Error target ebnf failed to compile:
Showing last frame. Use --error-trace for full trace.
In src/ebnf/grammar/rule.cr:89:48
89 | def initialize(@atoms = Array(Atom).new, @action = nil)
^
Error: instance variable @action of EBNF::Bison::Rule was inferred to be Nil, but Nil alone provides no information
I wonder that will this repo support Antlr Grammar to Bison Grammar Conveter future?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.