File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ def main
3030 profiler = RaccProfiler . new ( false )
3131
3232 parser = OptionParser . new
33- parser . banner = "Usage: #{ File . basename ( $0) } [options] < input> "
33+ parser . banner = "Usage: #{ File . basename ( $0) } [options] [ input] "
3434 parser . on ( '-o' , '--output-file=PATH' ,
3535 'output file name [<input>.tab.rb]' ) { |name |
3636 output = name
@@ -121,21 +121,24 @@ def main
121121 $stderr. puts parser . help
122122 exit 1
123123 end
124- if ARGV . empty?
125- $stderr. puts 'no input'
126- exit 1
127- end
128124 if ARGV . size > 1
129125 $stderr. puts 'too many input'
130126 exit 1
131127 end
132- input = ARGV [ 0 ]
128+
129+ input = ARGV [ 0 ] || "stdin"
130+
131+ if input == "stdin" && !output then
132+ $stderr. puts 'You must specify a path to read or use -o <path> for output.'
133+ exit 1
134+ end
133135
134136 begin
135137 $stderr. puts 'Parsing grammar file...' if verbose
136138 result = profiler . section ( 'parse' ) {
137139 parser = Racc ::GrammarFileParser . new ( debug_flags )
138- parser . parse ( File . read ( input ) , File . basename ( input ) )
140+ content = input == "stdin" ? ARGF . read : File . read ( input )
141+ parser . parse ( content , File . basename ( input ) )
139142 }
140143 if check_only
141144 $stderr. puts 'syntax ok'
You can’t perform that action at this time.
0 commit comments