Grammar takes in input string instead of file name
This commit is contained in:
parent
e4370cac62
commit
03b2e87186
@ -21,7 +21,7 @@ module Imbecile
|
||||
|
||||
def run(input_file, output_file)
|
||||
begin
|
||||
grammar = Grammar.new(input_file)
|
||||
grammar = Grammar.new(File.read(input_file))
|
||||
rescue Error => e
|
||||
$stderr.puts e.message
|
||||
return 2
|
||||
|
@ -7,10 +7,10 @@ module Imbecile
|
||||
# @return [String, nil] Class name.
|
||||
attr_reader :classname
|
||||
|
||||
def initialize(input_file)
|
||||
def initialize(input)
|
||||
@tokens = {}
|
||||
@rules = {}
|
||||
File.read(input_file).each_line.each_with_index do |line, line_index|
|
||||
input.each_line.each_with_index do |line, line_index|
|
||||
line = line.chomp
|
||||
line_number = line_index + 1
|
||||
if line =~ /^\s*#/
|
||||
|
Loading…
x
Reference in New Issue
Block a user