221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/ibex/cli.rb', line 221
def call(invocation)
arguments = invocation.arguments
if arguments == ["--help"]
invocation.stdout.puts("Usage: ibex validate-ir FILE")
return 0
end
raise Ibex::Error, "(cli):1:1: validate-ir requires exactly one IR file" unless arguments.length == 1
value = IR::Validator.validate(File.read(arguments.fetch(0)))
kind = if value.is_a?(IR::Grammar)
"grammar"
elsif value.is_a?(IR::Lexer)
"lexer"
else
"automaton"
end
invocation.stdout.puts("valid current #{kind} IR")
0
end
|