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.



74
75
76
77
78
# File 'lib/racc/parserfilegenerator.rb', line 74

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

Instance Method Details

#generate_parserObject



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

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



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

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



257
258
259
260
# File 'lib/racc/parserfilegenerator.rb', line 257

def put_state_transition_table(f)
  @f = f
  state_transition_table
end