Module: Ibex::Frontend::Regenerator

Defined in:
lib/ibex/frontend/regenerator.rb,
sig/ibex/frontend/regenerator.rbs

Overview

Builds the committed frontend parser from its canonical Ibex grammar.

Constant Summary collapse

GRAMMAR_PATH =

Signature:

  • String

Returns:

  • (String)
File.expand_path("grammar.y", File.dirname(__FILE__))
SHADOW_GRAMMAR_PATH =

Signature:

  • String

Returns:

  • (String)
File.expand_path("shadow_grammar.y", File.dirname(__FILE__))

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generateObject

RBS:

  • () -> String



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_shadowObject

Build the non-published parameterized/inline grammar used to verify that preview composition features can describe the production frontend without changing its observable AST.

RBS:

  • () -> String



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_pathObject

RBS:

  • () -> String



56
57
58
# File 'lib/ibex/frontend/regenerator.rb', line 56

def relative_grammar_path
  "lib/ibex/frontend/grammar.y"
end

.relative_shadow_grammar_pathObject

RBS:

  • () -> String



61
62
63
# File 'lib/ibex/frontend/regenerator.rb', line 61

def relative_shadow_grammar_path
  "lib/ibex/frontend/shadow_grammar.y"
end

Instance Method Details

#self?.generateString

RBS:

  • () -> String

Returns:

  • (String)


12
# File 'sig/ibex/frontend/regenerator.rbs', line 12

def self?.generate: () -> String

#self?.generate_shadowString

Build the non-published parameterized/inline grammar used to verify that preview composition features can describe the production frontend without changing its observable AST.

RBS:

  • () -> String

Returns:

  • (String)


18
# File 'sig/ibex/frontend/regenerator.rbs', line 18

def self?.generate_shadow: () -> String

#self?.relative_grammar_pathString

RBS:

  • () -> String

Returns:

  • (String)


21
# File 'sig/ibex/frontend/regenerator.rbs', line 21

def self?.relative_grammar_path: () -> String

#self?.relative_shadow_grammar_pathString

RBS:

  • () -> String

Returns:

  • (String)


24
# File 'sig/ibex/frontend/regenerator.rbs', line 24

def self?.relative_shadow_grammar_path: () -> String