Class: Racc::ParserFileGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/racc/parserfilegenerator.rb

Defined Under Namespace

Classes: Params

Instance Method Summary collapse

Constructor Details

#initialize(states, params) ⇒ ParserFileGenerator

Returns a new instance of ParserFileGenerator.



72
73
74
75
76
# File 'lib/racc/parserfilegenerator.rb', line 72

def initialize(states, params)
  @states = states
  @grammar = states.grammar
  @params = params
end

Instance Method Details

#generate_parserObject



78
79
80
81
82
83
84
85
86
87
# File 'lib/racc/parserfilegenerator.rb', line 78

def generate_parser
  string_io = StringIO.new

  init_line_conversion_system
  @f = string_io
  parser_file

  string_io.rewind
  string_io.read
end

#generate_parser_file(destpath) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/racc/parserfilegenerator.rb', line 89

def generate_parser_file(destpath)
  init_line_conversion_system
  File.open(destpath, 'w') {|f|
    @f = f
    parser_file
  }
  File.chmod 0755, destpath if @params.make_executable?
end

#put_state_transition_table(f) ⇒ Object



254
255
256
257
# File 'lib/racc/parserfilegenerator.rb', line 254

def put_state_transition_table(f)
  @f = f
  state_transition_table
end