Module: Ibex::Frontend::Regenerator
- Defined in:
- lib/ibex/frontend/regenerator.rb
Overview
Builds the committed frontend parser from its canonical Ibex grammar.
Constant Summary collapse
- GRAMMAR_PATH =
: String
File.("grammar.y", File.dirname(__FILE__))
- SHADOW_GRAMMAR_PATH =
: String
File.("shadow_grammar.y", File.dirname(__FILE__))
Class Method Summary collapse
- .generate ⇒ Object
-
.generate_shadow ⇒ Object
Build the non-published parameterized/inline grammar used to verify that preview composition features can describe the production frontend without changing its observable AST.
- .relative_grammar_path ⇒ Object
- .relative_shadow_grammar_path ⇒ Object
Class Method Details
.generate ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/ibex/frontend/regenerator.rb', line 31 def generate source = File.read(GRAMMAR_PATH) ast = BootstrapParser.new(source, file: relative_grammar_path).parse grammar = Normalizer.new(ast).normalize automaton = LALR::Builder.new(grammar).build Codegen::Ruby.new( automaton, table: :compact, line_convert: false, runtime_require: nil ).generate end |
.generate_shadow ⇒ Object
Build the non-published parameterized/inline grammar used to verify that preview composition features can describe the production frontend without changing its observable AST.
45 46 47 48 49 50 51 52 53 |
# File 'lib/ibex/frontend/regenerator.rb', line 45 def generate_shadow source = File.read(SHADOW_GRAMMAR_PATH) ast = BootstrapParser.new(source, file: relative_shadow_grammar_path, mode: :extended).parse grammar = Normalizer.new(ast, mode: :extended).normalize automaton = LALR::Builder.new(grammar).build Codegen::Ruby.new( automaton, table: :compact, line_convert: false, runtime_require: nil ).generate end |
.relative_grammar_path ⇒ Object
56 57 58 |
# File 'lib/ibex/frontend/regenerator.rb', line 56 def relative_grammar_path "lib/ibex/frontend/grammar.y" end |
.relative_shadow_grammar_path ⇒ Object
61 62 63 |
# File 'lib/ibex/frontend/regenerator.rb', line 61 def relative_shadow_grammar_path "lib/ibex/frontend/shadow_grammar.y" end |