This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-31 19:38:40 +02:00
|
|
|
require "option_parser"
|
|
|
|
require "./src/spec"
|
|
|
|
|
|
|
|
def print_tree(tree, indent = 0)
|
|
|
|
indent.times { STDOUT << " " }
|
|
|
|
case tree
|
|
|
|
when Pegasus::Generated::TerminalTree
|
|
|
|
STDOUT << "Terminal: "
|
|
|
|
STDOUT.puts tree.string
|
|
|
|
when Pegasus::Generated::NonterminalTree
|
|
|
|
STDOUT << "Nonterminal: " << tree.name
|
|
|
|
STDOUT.puts
|
|
|
|
tree.children.each { |it| print_tree(it, indent + 1) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
recipe_file_name = "some-non-existant-file"
|
|
|
|
|
|
|
|
OptionParser.parse! do |parser|
|
|
|
|
parser.on "-f file", "--file file", "File to parse." do |f|
|
|
|
|
recipe_file_name = f
|
|
|
|
end
|
|
|
|
|
|
|
|
parser.on "-h", "--help", "Show this help" do
|
|
|
|
puts parser
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-08-02 17:59:33 +02:00
|
|
|
options = Hash(String,String).new
|
|
|
|
options["someoptionexample"] = "option"
|
|
|
|
|
|
|
|
specs = Specs.parse recipe_file_name, options
|
2019-07-31 19:38:40 +02:00
|
|
|
pp! specs
|