class ModelParser
options no_result_var token NUMBER BOOLEAN SYMBOL
rule
target: model model: { {} } | definition model { val[0].merge val[1] } definition: SYMBOL '->' rhs { {val[0] => val[2]} } rhs: value | '{' fmappings '}' { val[1] } fmappings: 'else' '->' value { {nil => val[2]} } | values '->' value fmappings { {val[0] => val[2]}.merge(val[3]) } values: value { val[0] } | value values { vs = val[1]; [val[0]] + (vs.is_a?(Array) ? vs : [vs]) } value: '(' '-' NUMBER ')' { -val[2] } | NUMBER | BOOLEAN | SYMBOL
end
—- header require_relative 'model_parser.rex' module Z3
—- inner def parse(input)
scan_str(input)
end
—- footer end