Skip to content

Commit

Permalink
Merge pull request #8 from nobu/stdin-mode
Browse files Browse the repository at this point in the history
Add stdin mode
  • Loading branch information
yui-knk authored May 15, 2023
2 parents 32a5492 + c511656 commit 50642eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/lrama/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ def run(argv)
end

if !grammar_file
puts "File should be specified\n"
exit 1
abort "File should be specified\n"
end

Report::Duration.enable if trace_opts[:time]

warning = Lrama::Warning.new
y = File.read(grammar_file)
if grammar_file == '-'
grammar_file = argv.shift or abort "File name for STDIN should be specified\n"
y = STDIN.read
else
y = File.read(grammar_file)
end
grammar = Lrama::Parser.new(y).parse
states = Lrama::States.new(grammar, warning, trace_state: (trace_opts[:automaton] || trace_opts[:closure]))
states.compute
Expand Down

0 comments on commit 50642eb

Please sign in to comment.