diff --git a/lib/puppet/pops/evaluator/evaluator_impl.rb b/lib/puppet/pops/evaluator/evaluator_impl.rb index 3b551c821..6f7429da0 100644 --- a/lib/puppet/pops/evaluator/evaluator_impl.rb +++ b/lib/puppet/pops/evaluator/evaluator_impl.rb @@ -1,1066 +1,1104 @@ require 'rgen/ecore/ecore' require 'puppet/pops/evaluator/compare_operator' require 'puppet/pops/evaluator/relationship_operator' require 'puppet/pops/evaluator/access_operator' require 'puppet/pops/evaluator/closure' require 'puppet/pops/evaluator/external_syntax_support' # This implementation of {Puppet::Pops::Evaluator} performs evaluation using the puppet 3.x runtime system # in a manner largely compatible with Puppet 3.x, but adds new features and introduces constraints. # # The evaluation uses _polymorphic dispatch_ which works by dispatching to the first found method named after # the class or one of its super-classes. The EvaluatorImpl itself mainly deals with evaluation (it currently # also handles assignment), and it uses a delegation pattern to more specialized handlers of some operators # that in turn use polymorphic dispatch; this to not clutter EvaluatorImpl with too much responsibility). # # Since a pattern is used, only the main entry points are fully documented. The parameters _o_ and _scope_ are # the same in all the polymorphic methods, (the type of the parameter _o_ is reflected in the method's name; # either the actual class, or one of its super classes). The _scope_ parameter is always the scope in which # the evaluation takes place. If nothing else is mentioned, the return is always the result of evaluation. # # See {Puppet::Pops::Visitable} and {Puppet::Pops::Visitor} for more information about # polymorphic calling. # class Puppet::Pops::Evaluator::EvaluatorImpl include Puppet::Pops::Utils # Provides access to the Puppet 3.x runtime (scope, etc.) # This separation has been made to make it easier to later migrate the evaluator to an improved runtime. # include Puppet::Pops::Evaluator::Runtime3Support include Puppet::Pops::Evaluator::ExternalSyntaxSupport # This constant is not defined as Float::INFINITY in Ruby 1.8.7 (but is available in later version # Refactor when support is dropped for Ruby 1.8.7. # INFINITY = 1.0 / 0.0 # Reference to Issues name space makes it easier to refer to issues # (Issues are shared with the validator). # Issues = Puppet::Pops::Issues def initialize @@eval_visitor ||= Puppet::Pops::Visitor.new(self, "eval", 1, 1) @@lvalue_visitor ||= Puppet::Pops::Visitor.new(self, "lvalue", 1, 1) @@assign_visitor ||= Puppet::Pops::Visitor.new(self, "assign", 3, 3) @@string_visitor ||= Puppet::Pops::Visitor.new(self, "string", 1, 1) @@type_calculator ||= Puppet::Pops::Types::TypeCalculator.new() @@type_parser ||= Puppet::Pops::Types::TypeParser.new() @@compare_operator ||= Puppet::Pops::Evaluator::CompareOperator.new() @@relationship_operator ||= Puppet::Pops::Evaluator::RelationshipOperator.new() # Initialize the runtime module Puppet::Pops::Evaluator::Runtime3Support.instance_method(:initialize).bind(self).call() end # @api private def type_calculator @@type_calculator end # Polymorphic evaluate - calls eval_TYPE # # ## Polymorphic evaluate # Polymorphic evaluate calls a method on the format eval_TYPE where classname is the last # part of the class of the given _target_. A search is performed starting with the actual class, continuing # with each of the _target_ class's super classes until a matching method is found. # # # Description # Evaluates the given _target_ object in the given scope, optionally passing a block which will be # called with the result of the evaluation. # # @overload evaluate(target, scope, {|result| block}) # @param target [Object] evaluation target - see methods on the pattern assign_TYPE for actual supported types. # @param scope [Object] the runtime specific scope class where evaluation should take place # @return [Object] the result of the evaluation # # @api # def evaluate(target, scope) begin @@eval_visitor.visit_this_1(self, target, scope) rescue Puppet::Pops::SemanticError => e # a raised issue may not know the semantic target fail(e.issue, e.semantic || target, e.options, e) rescue StandardError => e if e.is_a? Puppet::ParseError # ParseError's are supposed to be fully configured with location information raise e end fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e) end end # Polymorphic assign - calls assign_TYPE # # ## Polymorphic assign # Polymorphic assign calls a method on the format assign_TYPE where TYPE is the last # part of the class of the given _target_. A search is performed starting with the actual class, continuing # with each of the _target_ class's super classes until a matching method is found. # # # Description # Assigns the given _value_ to the given _target_. The additional argument _o_ is the instruction that # produced the target/value tuple and it is used to set the origin of the result. # @param target [Object] assignment target - see methods on the pattern assign_TYPE for actual supported types. # @param value [Object] the value to assign to `target` # @param o [Puppet::Pops::Model::PopsObject] originating instruction # @param scope [Object] the runtime specific scope where evaluation should take place # # @api # def assign(target, value, o, scope) @@assign_visitor.visit_this_3(self, target, value, o, scope) end def lvalue(o, scope) @@lvalue_visitor.visit_this_1(self, o, scope) end def string(o, scope) @@string_visitor.visit_this_1(self, o, scope) end # Call a closure matching arguments by name - Can only be called with a Closure (for now), may be refactored later # to also handle other types of calls (function calls are also handled by CallNamedFunction and CallMethod, they # could create similar objects to Closure, wait until other types of defines are instantiated - they may behave # as special cases of calls - i.e. 'new'). # # Call by name supports a "spill_over" mode where extra arguments in the given args_hash are introduced # as variables in the resulting scope. # # @raise ArgumentError, if there are to many or too few arguments # @raise ArgumentError, if given closure is not a Puppet::Pops::Evaluator::Closure # def call_by_name(closure, args_hash, scope, spill_over = false) raise ArgumentError, "Can only call a Lambda" unless closure.is_a?(Puppet::Pops::Evaluator::Closure) pblock = closure.model parameters = pblock.parameters || [] if !spill_over && args_hash.size > parameters.size raise ArgumentError, "Too many arguments: #{args_hash.size} for #{parameters.size}" end # associate values with parameters scope_hash = {} parameters.each do |p| scope_hash[p.name] = args_hash[p.name] || evaluate(p.value, scope) end missing = scope_hash.reduce([]) {|memo, entry| memo << entry[0] if entry[1].nil?; memo } unless missing.empty? optional = parameters.count { |p| !p.value.nil? } raise ArgumentError, "Too few arguments; no value given for required parameters #{missing.join(" ,")}" end if spill_over # all args from given hash should be used, nil entries replaced by default values should win scope_hash = args_hash.merge(scope_hash) end # Store the evaluated name => value associations in a new inner/local/ephemeral scope # (This is made complicated due to the fact that the implementation of scope is overloaded with # functionality and an inner ephemeral scope must be used (as opposed to just pushing a local scope # on a scope "stack"). # Ensure variable exists with nil value if error occurs. # Some ruby implementations does not like creating variable on return result = nil begin scope_memo = get_scope_nesting_level(scope) # change to create local scope_from - cannot give it file and line - that is the place of the call, not # "here" create_local_scope_from(scope_hash, scope) result = evaluate(pblock.body, scope) ensure set_scope_nesting_level(scope, scope_memo) end result end # Call a closure - Can only be called with a Closure (for now), may be refactored later # to also handle other types of calls (function calls are also handled by CallNamedFunction and CallMethod, they # could create similar objects to Closure, wait until other types of defines are instantiated - they may behave # as special cases of calls - i.e. 'new') # # @raise ArgumentError, if there are to many or too few arguments # @raise ArgumentError, if given closure is not a Puppet::Pops::Evaluator::Closure # def call(closure, args, scope) raise ArgumentError, "Can only call a Lambda" unless closure.is_a?(Puppet::Pops::Evaluator::Closure) pblock = closure.model parameters = pblock.parameters || [] raise ArgumentError, "Too many arguments: #{args.size} for #{parameters.size}" unless args.size <= parameters.size # associate values with parameters merged = parameters.zip(args) # calculate missing arguments missing = parameters.slice(args.size, parameters.size - args.size).select {|p| p.value.nil? } unless missing.empty? optional = parameters.count { |p| !p.value.nil? } raise ArgumentError, "Too few arguments; #{args.size} for #{optional > 0 ? ' min ' : ''}#{parameters.size - optional}" end evaluated = merged.collect do |m| # m can be one of # m = [Parameter{name => "name", value => nil], "given"] # | [Parameter{name => "name", value => Expression}, "given"] # # "given" is always an optional entry. If a parameter was provided then # the entry will be in the array, otherwise the m array will be a # single element. given_argument = m[1] argument_name = m[0].name default_expression = m[0].value value = if default_expression evaluate(default_expression, scope) else given_argument end [argument_name, value] end # Store the evaluated name => value associations in a new inner/local/ephemeral scope # (This is made complicated due to the fact that the implementation of scope is overloaded with # functionality and an inner ephemeral scope must be used (as opposed to just pushing a local scope # on a scope "stack"). # Ensure variable exists with nil value if error occurs. # Some ruby implementations does not like creating variable on return result = nil begin scope_memo = get_scope_nesting_level(scope) # change to create local scope_from - cannot give it file and line - that is the place of the call, not # "here" create_local_scope_from(Hash[evaluated], scope) result = evaluate(pblock.body, scope) ensure set_scope_nesting_level(scope, scope_memo) end result end protected def lvalue_VariableExpression(o, scope) # evaluate the name evaluate(o.expr, scope) end # Catches all illegal lvalues # def lvalue_Object(o, scope) fail(Issues::ILLEGAL_ASSIGNMENT, o) end # Assign value to named variable. # The '$' sign is never part of the name. # @example In Puppet DSL # $name = value # @param name [String] name of variable without $ # @param value [Object] value to assign to the variable # @param o [Puppet::Pops::Model::PopsObject] originating instruction # @param scope [Object] the runtime specific scope where evaluation should take place # @return [value] # def assign_String(name, value, o, scope) if name =~ /::/ fail(Issues::CROSS_SCOPE_ASSIGNMENT, o.left_expr, {:name => name}) end set_variable(name, value, o, scope) value end def assign_Numeric(n, value, o, scope) fail(Issues::ILLEGAL_NUMERIC_ASSIGNMENT, o.left_expr, {:varname => n.to_s}) end # Catches all illegal assignment (e.g. 1 = 2, {'a'=>1} = 2, etc) # def assign_Object(name, value, o, scope) fail(Issues::ILLEGAL_ASSIGNMENT, o) end def eval_Factory(o, scope) evaluate(o.current, scope) end # Evaluates any object not evaluated to something else to itself. def eval_Object o, scope o end # Allows nil to be used as a Nop. # Evaluates to nil # TODO: What is the difference between literal undef, nil, and nop? # def eval_NilClass(o, scope) nil end # Evaluates Nop to nil. # TODO: or is this the same as :undef # TODO: is this even needed as a separate instruction when there is a literal undef? def eval_Nop(o, scope) nil end # Captures all LiteralValues not handled elsewhere. # def eval_LiteralValue(o, scope) o.value end def eval_LiteralDefault(o, scope) :default end def eval_LiteralUndef(o, scope) :undef # TODO: or just use nil for this? end # A QualifiedReference (i.e. a capitalized qualified name such as Foo, or Foo::Bar) evaluates to a PType # def eval_QualifiedReference(o, scope) @@type_parser.interpret(o) end def eval_NotExpression(o, scope) ! is_true?(evaluate(o.expr, scope)) end def eval_UnaryMinusExpression(o, scope) - coerce_numeric(evaluate(o.expr, scope), o, scope) end + def eval_UnfoldExpression(o, scope) + candidate = evaluate(o.expr, scope) + case candidate + when Array + candidate + when Hash + candidate.to_a + else + # turns anything else into an array (so result can be unfolded) + [candidate] + end + end + # Abstract evaluation, returns array [left, right] with the evaluated result of left_expr and # right_expr # @return > array with result of evaluating left and right expressions # def eval_BinaryExpression o, scope [ evaluate(o.left_expr, scope), evaluate(o.right_expr, scope) ] end # Evaluates assignment with operators =, +=, -= and # # @example Puppet DSL # $a = 1 # $a += 1 # $a -= 1 # def eval_AssignmentExpression(o, scope) name = lvalue(o.left_expr, scope) value = evaluate(o.right_expr, scope) case o.operator when :'=' # regular assignment assign(name, value, o, scope) when :'+=' # if value does not exist and strict is on, looking it up fails, else it is nil or :undef existing_value = get_variable_value(name, o, scope) begin if existing_value.nil? || existing_value == :undef assign(name, value, o, scope) else # Delegate to calculate function to deal with check of LHS, and perform ´+´ as arithmetic or concatenation the # same way as ArithmeticExpression performs `+`. assign(name, calculate(existing_value, value, :'+', o.left_expr, o.right_expr, scope), o, scope) end rescue ArgumentError => e fail(Issues::APPEND_FAILED, o, {:message => e.message}) end when :'-=' # If an attempt is made to delete values from something that does not exists, the value is :undef (it is guaranteed to not # include any values the user wants deleted anyway :-) # # if value does not exist and strict is on, looking it up fails, else it is nil or :undef existing_value = get_variable_value(name, o, scope) begin if existing_value.nil? || existing_value == :undef assign(name, :undef, o, scope) else # Delegate to delete function to deal with check of LHS, and perform deletion assign(name, delete(get_variable_value(name, o, scope), value), o, scope) end rescue ArgumentError => e fail(Issues::APPEND_FAILED, o, {:message => e.message}, e) end else fail(Issues::UNSUPPORTED_OPERATOR, o, {:operator => o.operator}) end value end ARITHMETIC_OPERATORS = [:'+', :'-', :'*', :'/', :'%', :'<<', :'>>'] COLLECTION_OPERATORS = [:'+', :'-', :'<<'] # Handles binary expression where lhs and rhs are array/hash or numeric and operator is +, - , *, % / << >> # def eval_ArithmeticExpression(o, scope) left, right = eval_BinaryExpression(o, scope) begin result = calculate(left, right, o.operator, o.left_expr, o.right_expr, scope) rescue ArgumentError => e fail(Issues::RUNTIME_ERROR, o, {:detail => e.message}, e) end result end # Handles binary expression where lhs and rhs are array/hash or numeric and operator is +, - , *, % / << >> # def calculate(left, right, operator, left_o, right_o, scope) unless ARITHMETIC_OPERATORS.include?(operator) fail(Issues::UNSUPPORTED_OPERATOR, left_o.eContainer, {:operator => o.operator}) end if (left.is_a?(Array) || left.is_a?(Hash)) && COLLECTION_OPERATORS.include?(operator) # Handle operation on collections case operator when :'+' concatenate(left, right) when :'-' delete(left, right) when :'<<' unless left.is_a?(Array) fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left}) end left + [right] end else # Handle operation on numeric left = coerce_numeric(left, left_o, scope) right = coerce_numeric(right, right_o, scope) begin if operator == :'%' && (left.is_a?(Float) || right.is_a?(Float)) # Deny users the fun of seeing severe rounding errors and confusing results fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left}) end result = left.send(operator, right) rescue NoMethodError => e fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left}) rescue ZeroDivisionError => e fail(Issues::DIV_BY_ZERO, right_o) end if result == INFINITY || result == -INFINITY fail(Issues::RESULT_IS_INFINITY, left_o, {:operator => operator}) end result end end def eval_EppExpression(o, scope) scope["@epp"] = [] evaluate(o.body, scope) result = scope["@epp"].join('') result end def eval_RenderStringExpression(o, scope) scope["@epp"] << o.value.dup nil end def eval_RenderExpression(o, scope) scope["@epp"] << string(evaluate(o.expr, scope), scope) nil end # Evaluates Puppet DSL ->, ~>, <-, and <~ def eval_RelationshipExpression(o, scope) # First level evaluation, reduction to basic data types or puppet types, the relationship operator then translates this # to the final set of references (turning strings into references, which can not naturally be done by the main evaluator since # all strings should not be turned into references. # real = eval_BinaryExpression(o, scope) @@relationship_operator.evaluate(real, o, scope) end # Evaluates x[key, key, ...] # def eval_AccessExpression(o, scope) left = evaluate(o.left_expr, scope) keys = o.keys.nil? ? [] : o.keys.collect {|key| evaluate(key, scope) } Puppet::Pops::Evaluator::AccessOperator.new(o).access(left, scope, *keys) end # Evaluates <, <=, >, >=, and == # def eval_ComparisonExpression o, scope left, right = eval_BinaryExpression o, scope begin # Left is a type if left.is_a?(Puppet::Pops::Types::PAbstractType) case o.operator when :'==' @@type_calculator.equals(left,right) when :'!=' !@@type_calculator.equals(left,right) when :'<' # left can be assigned to right, but they are not equal @@type_calculator.assignable?(right, left) && ! @@type_calculator.equals(left,right) when :'<=' # left can be assigned to right @@type_calculator.assignable?(right, left) when :'>' # right can be assigned to left, but they are not equal @@type_calculator.assignable?(left,right) && ! @@type_calculator.equals(left,right) when :'>=' # right can be assigned to left @@type_calculator.assignable?(left, right) else fail(Issues::UNSUPPORTED_OPERATOR, o, {:operator => o.operator}) end else case o.operator when :'==' @@compare_operator.equals(left,right) when :'!=' ! @@compare_operator.equals(left,right) when :'<' @@compare_operator.compare(left,right) < 0 when :'<=' @@compare_operator.compare(left,right) <= 0 when :'>' @@compare_operator.compare(left,right) > 0 when :'>=' @@compare_operator.compare(left,right) >= 0 else fail(Issues::UNSUPPORTED_OPERATOR, o, {:operator => o.operator}) end end rescue ArgumentError => e fail(Issues::COMPARISON_NOT_POSSIBLE, o, { :operator => o.operator, :left_value => left, :right_value => right, :detail => e.message}, e) end end # Evaluates matching expressions with type, string or regexp rhs expression. # If RHS is a type, the =~ matches compatible (instance? of) type. # # @example # x =~ /abc.*/ # @example # x =~ "abc.*/" # @example # y = "abc" # x =~ "${y}.*" # @example # [1,2,3] =~ Array[Integer[1,10]] # # Note that a string is not instance? of Regexp, only Regular expressions are. # The Pattern type should instead be used as it is specified as subtype of String. # # @return [Boolean] if a match was made or not. Also sets $0..$n to matchdata in current scope. # def eval_MatchExpression o, scope left, pattern = eval_BinaryExpression o, scope # matches RHS types as instance of for all types except a parameterized Regexp[R] if pattern.is_a?(Puppet::Pops::Types::PAbstractType) # evaluate as instance? of type check matched = @@type_calculator.instance?(pattern, left) # convert match result to Boolean true, or false return o.operator == :'=~' ? !!matched : !matched end begin pattern = Regexp.new(pattern) unless pattern.is_a?(Regexp) rescue StandardError => e fail(Issues::MATCH_NOT_REGEXP, o.right_expr, {:detail => e.message}, e) end unless left.is_a?(String) fail(Issues::MATCH_NOT_STRING, o.left_expr, {:left_value => left}) end matched = pattern.match(left) # nil, or MatchData set_match_data(matched, o, scope) # creates ephemeral # convert match result to Boolean true, or false o.operator == :'=~' ? !!matched : !matched end # Evaluates Puppet DSL `in` expression # def eval_InExpression o, scope left, right = eval_BinaryExpression o, scope @@compare_operator.include?(right, left) end # @example # $a and $b # b is only evaluated if a is true # def eval_AndExpression o, scope is_true?(evaluate(o.left_expr, scope)) ? is_true?(evaluate(o.right_expr, scope)) : false end # @example # a or b # b is only evaluated if a is false # def eval_OrExpression o, scope is_true?(evaluate(o.left_expr, scope)) ? true : is_true?(evaluate(o.right_expr, scope)) end # Evaluates each entry of the literal list and creates a new Array + # Supports unfolding of entries # @return [Array] with the evaluated content # def eval_LiteralList o, scope - o.values.collect {|expr| evaluate(expr, scope)} + unfold([], o.values, scope) end # Evaluates each entry of the literal hash and creates a new Hash. # @return [Hash] with the evaluated content # def eval_LiteralHash o, scope h = Hash.new o.entries.each {|entry| h[ evaluate(entry.key, scope)]= evaluate(entry.value, scope)} h end # Evaluates all statements and produces the last evaluated value # def eval_BlockExpression o, scope r = nil o.statements.each {|s| r = evaluate(s, scope)} r end # Performs optimized search over case option values, lazily evaluating each # until there is a match. If no match is found, the case expression's default expression # is evaluated (it may be nil or Nop if there is no default, thus producing nil). # If an option matches, the result of evaluating that option is returned. # @return [Object, nil] what a matched option returns, or nil if nothing matched. # def eval_CaseExpression(o, scope) # memo scope level before evaluating test - don't want a match in the case test to leak $n match vars # to expressions after the case expression. # with_guarded_scope(scope) do test = evaluate(o.test, scope) result = nil the_default = nil if o.options.find do |co| # the first case option that matches if co.values.find do |c| the_default = co.then_expr if c.is_a? Puppet::Pops::Model::LiteralDefault is_match?(test, evaluate(c, scope), c, scope) end result = evaluate(co.then_expr, scope) true # the option was picked end end result # an option was picked, and produced a result else evaluate(the_default, scope) # evaluate the default (should be a nop/nil) if there is no default). end end end # Evaluates a CollectExpression by transforming it into a 3x AST::Collection and then evaluating that. # This is done because of the complex API between compiler, indirector, backends, and difference between # collecting virtual resources and exported resources. # def eval_CollectExpression o, scope # The Collect Expression and its contained query expressions are implemented in such a way in # 3x that it is almost impossible to do anything about them (the AST objects are lazily evaluated, # and the built structure consists of both higher order functions and arrays with query expressions # that are either used as a predicate filter, or given to an indirection terminus (such as the Puppet DB # resource terminus). Unfortunately, the 3x implementation has many inconsistencies that the implementation # below carries forward. # collect_3x = Puppet::Pops::Model::AstTransformer.new().transform(o) collected = collect_3x.evaluate(scope) # the 3x returns an instance of Parser::Collector (but it is only registered with the compiler at this # point and does not contain any valuable information (like the result) # Dilemma: If this object is returned, it is a first class value in the Puppet Language and we # need to be able to perform operations on it. We can forbid it from leaking by making CollectExpression # a non R-value. This makes it possible for the evaluator logic to make use of the Collector. collected end def eval_ParenthesizedExpression(o, scope) evaluate(o.expr, scope) end # This evaluates classes, nodes and resource type definitions to nil, since 3x: # instantiates them, and evaluates their parameters and body. This is achieved by # providing bridge AST classes in Puppet::Parser::AST::PopsBridge that bridges a # Pops Program and a Pops Expression. # # Since all Definitions are handled "out of band", they are treated as a no-op when # evaluated. # def eval_Definition(o, scope) nil end def eval_Program(o, scope) evaluate(o.body, scope) end # Produces Array[PObjectType], an array of resource references # def eval_ResourceExpression(o, scope) exported = o.exported virtual = o.virtual type_name = evaluate(o.type_name, scope) o.bodies.map do |body| titles = [evaluate(body.title, scope)].flatten evaluated_parameters = body.operations.map {|op| evaluate(op, scope) } create_resources(o, scope, virtual, exported, type_name, titles, evaluated_parameters) end.flatten.compact end def eval_ResourceOverrideExpression(o, scope) evaluated_resources = evaluate(o.resources, scope) evaluated_parameters = o.operations.map { |op| evaluate(op, scope) } create_resource_overrides(o, scope, [evaluated_resources].flatten, evaluated_parameters) evaluated_resources end # Produces 3x array of parameters def eval_AttributeOperation(o, scope) create_resource_parameter(o, scope, o.attribute_name, evaluate(o.value_expr, scope), o.operator) end # Sets default parameter values for a type, produces the type # def eval_ResourceDefaultsExpression(o, scope) type_name = o.type_ref.value # a QualifiedName's string value evaluated_parameters = o.operations.map {|op| evaluate(op, scope) } create_resource_defaults(o, scope, type_name, evaluated_parameters) # Produce the type evaluate(o.type_ref, scope) end # Evaluates function call by name. # def eval_CallNamedFunctionExpression(o, scope) # The functor expression is not evaluated, it is not possible to select the function to call # via an expression like $a() case o.functor_expr when Puppet::Pops::Model::QualifiedName # ok when Puppet::Pops::Model::RenderStringExpression # helpful to point out this easy to make Epp error fail(Issues::ILLEGAL_EPP_PARAMETERS, o) else fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o}) end name = o.functor_expr.value - evaluated_arguments = o.arguments.collect {|arg| evaluate(arg, scope) } + + evaluated_arguments = unfold([], o.arguments, scope) + # wrap lambda in a callable block if it is present evaluated_arguments << Puppet::Pops::Evaluator::Closure.new(self, o.lambda, scope) if o.lambda call_function(name, evaluated_arguments, o, scope) end # Evaluation of CallMethodExpression handles a NamedAccessExpression functor (receiver.function_name) # def eval_CallMethodExpression(o, scope) unless o.functor_expr.is_a? Puppet::Pops::Model::NamedAccessExpression fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function accessor', :container => o}) end receiver = evaluate(o.functor_expr.left_expr, scope) name = o.functor_expr.right_expr unless name.is_a? Puppet::Pops::Model::QualifiedName fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o}) end name = name.value # the string function name - evaluated_arguments = [receiver] + (o.arguments || []).collect {|arg| evaluate(arg, scope) } + + evaluated_arguments = unfold([receiver], o.arguments || [], scope) + + # wrap lambda in a callable block if it is present evaluated_arguments << Puppet::Pops::Evaluator::Closure.new(self, o.lambda, scope) if o.lambda call_function(name, evaluated_arguments, o, scope) end # @example # $x ? { 10 => true, 20 => false, default => 0 } # def eval_SelectorExpression o, scope # memo scope level before evaluating test - don't want a match in the case test to leak $n match vars # to expressions after the selector expression. # with_guarded_scope(scope) do test = evaluate(o.left_expr, scope) selected = o.selectors.find do |s| candidate = evaluate(s.matching_expr, scope) candidate == :default || is_match?(test, candidate, s.matching_expr, scope) end if selected evaluate(selected.value_expr, scope) else nil end end end # SubLocatable is simply an expression that holds location information def eval_SubLocatedExpression o, scope evaluate(o.expr, scope) end # Evaluates Puppet DSL Heredoc def eval_HeredocExpression o, scope result = evaluate(o.text_expr, scope) assert_external_syntax(scope, result, o.syntax, o.text_expr) result end # Evaluates Puppet DSL `if` def eval_IfExpression o, scope with_guarded_scope(scope) do if is_true?(evaluate(o.test, scope)) evaluate(o.then_expr, scope) else evaluate(o.else_expr, scope) end end end # Evaluates Puppet DSL `unless` def eval_UnlessExpression o, scope with_guarded_scope(scope) do unless is_true?(evaluate(o.test, scope)) evaluate(o.then_expr, scope) else evaluate(o.else_expr, scope) end end end # Evaluates a variable (getting its value) # The evaluator is lenient; any expression producing a String is used as a name # of a variable. # def eval_VariableExpression o, scope # Evaluator is not too fussy about what constitutes a name as long as the result # is a String and a valid variable name # name = evaluate(o.expr, scope) # Should be caught by validation, but make this explicit here as well, or mysterious evaluation issues # may occur. case name when String when Numeric else fail(Issues::ILLEGAL_VARIABLE_EXPRESSION, o.expr) end # TODO: Check for valid variable name (Task for validator) # TODO: semantics of undefined variable in scope, this just returns what scope does == value or nil get_variable_value(name, o, scope) end # Evaluates double quoted strings that may contain interpolation # def eval_ConcatenatedString o, scope o.segments.collect {|expr| string(evaluate(expr, scope), scope)}.join end # If the wrapped expression is a QualifiedName, it is taken as the name of a variable in scope. # Note that this is different from the 3.x implementation, where an initial qualified name # is accepted. (e.g. `"---${var + 1}---"` is legal. This implementation requires such concrete # syntax to be expressed in a model as `(TextExpression (+ (Variable var) 1)` - i.e. moving the decision to # the parser. # # Semantics; the result of an expression is turned into a string, nil is silently transformed to empty # string. # @return [String] the interpolated result # def eval_TextExpression o, scope if o.expr.is_a?(Puppet::Pops::Model::QualifiedName) # TODO: formalize, when scope returns nil, vs error string(get_variable_value(o.expr.value, o, scope), scope) else string(evaluate(o.expr, scope), scope) end end def string_Object(o, scope) o.to_s end def string_Symbol(o, scope) case o when :undef '' else o.to_s end end def string_Array(o, scope) ['[', o.map {|e| string(e, scope)}.join(', '), ']'].join() end def string_Hash(o, scope) ['{', o.map {|k,v| string(k, scope) + " => " + string(v, scope)}.join(', '), '}'].join() end def string_Regexp(o, scope) ['/', o.source, '/'].join() end def string_PAbstractType(o, scope) @@type_calculator.string(o) end # Produces concatenation / merge of x and y. # # When x is an Array, y of type produces: # # * Array => concatenation `[1,2], [3,4] => [1,2,3,4]` # * Hash => concatenation of hash as array `[key, value, key, value, ...]` # * any other => concatenation of single value # # When x is a Hash, y of type produces: # # * Array => merge of array interpreted as `[key, value, key, value,...]` # * Hash => a merge, where entries in `y` overrides # * any other => error # # When x is something else, wrap it in an array first. # # When x is nil, an empty array is used instead. # # @note to concatenate an Array, nest the array - i.e. `[1,2], [[2,3]]` # # @overload concatenate(obj_x, obj_y) # @param obj_x [Object] object to wrap in an array and concatenate to; see other overloaded methods for return type # @param ary_y [Object] array to concatenate at end of `ary_x` # @return [Object] wraps obj_x in array before using other overloaded option based on type of obj_y # @overload concatenate(ary_x, ary_y) # @param ary_x [Array] array to concatenate to # @param ary_y [Array] array to concatenate at end of `ary_x` # @return [Array] new array with `ary_x` + `ary_y` # @overload concatenate(ary_x, hsh_y) # @param ary_x [Array] array to concatenate to # @param hsh_y [Hash] converted to array form, and concatenated to array # @return [Array] new array with `ary_x` + `hsh_y` converted to array # @overload concatenate (ary_x, obj_y) # @param ary_x [Array] array to concatenate to # @param obj_y [Object] non array or hash object to add to array # @return [Array] new array with `ary_x` + `obj_y` added as last entry # @overload concatenate(hsh_x, ary_y) # @param hsh_x [Hash] the hash to merge with # @param ary_y [Array] array interpreted as even numbered sequence of key, value merged with `hsh_x` # @return [Hash] new hash with `hsh_x` merged with `ary_y` interpreted as hash in array form # @overload concatenate(hsh_x, hsh_y) # @param hsh_x [Hash] the hash to merge to # @param hsh_y [Hash] hash merged with `hsh_x` # @return [Hash] new hash with `hsh_x` merged with `hsh_y` # @raise [ArgumentError] when `xxx_x` is neither an Array nor a Hash # @raise [ArgumentError] when `xxx_x` is a Hash, and `xxx_y` is neither Array nor Hash. # def concatenate(x, y) x = [x] unless x.is_a?(Array) || x.is_a?(Hash) case x when Array y = case y when Array then y when Hash then y.to_a else [y] end x + y # new array with concatenation when Hash y = case y when Hash then y when Array # Hash[[a, 1, b, 2]] => {} # Hash[a,1,b,2] => {a => 1, b => 2} # Hash[[a,1], [b,2]] => {[a,1] => [b,2]} # Hash[[[a,1], [b,2]]] => {a => 1, b => 2} # Use type calcultor to determine if array is Array[Array[?]], and if so use second form # of call t = @@type_calculator.infer(y) if t.element_type.is_a? Puppet::Pops::Types::PArrayType Hash[y] else Hash[*y] end else raise ArgumentError.new("Can only append Array or Hash to a Hash") end x.merge y # new hash with overwrite else raise ArgumentError.new("Can only append to an Array or a Hash.") end end # Produces the result x \ y (set difference) # When `x` is an Array, `y` is transformed to an array and then all matching elements removed from x. # When `x` is a Hash, all contained keys are removed from x as listed in `y` if it is an Array, or all its keys if it is a Hash. # The difference is returned. The given `x` and `y` are not modified by this operation. # @raise [ArgumentError] when `x` is neither an Array nor a Hash # def delete(x, y) result = x.dup case x when Array y = case y when Array then y when Hash then y.to_a else [y] end y.each {|e| result.delete(e) } when Hash y = case y when Array then y when Hash then y.keys else [y] end y.each {|e| result.delete(e) } else raise ArgumentError.new("Can only delete from an Array or Hash.") end result end # Implementation of case option matching. # # This is the type of matching performed in a case option, using == for every type # of value except regular expression where a match is performed. # def is_match? left, right, o, scope if right.is_a?(Regexp) return false unless left.is_a? String matched = right.match(left) set_match_data(matched, o, scope) # creates or clears ephemeral !!matched # convert to boolean elsif right.is_a?(Puppet::Pops::Types::PAbstractType) # right is a type and left is not - check if left is an instance of the given type # (The reverse is not terribly meaningful - computing which of the case options that first produces # an instance of a given type). # @@type_calculator.instance?(right, left) else # Handle equality the same way as the language '==' operator (case insensitive etc.) @@compare_operator.equals(left,right) end end def with_guarded_scope(scope) scope_memo = get_scope_nesting_level(scope) begin yield ensure set_scope_nesting_level(scope, scope_memo) end end + # Maps the expression in the given array to their product except for UnfoldExpressions which are first unfolded. + # The result is added to the given result Array. + # @param result [Array] Where to add the result (may contain information to add to) + # @param array [Array[Puppet::Pops::Model::Expression] the expressions to map + # @param scope [Puppet::Parser::Scope] the scope to evaluate in + # @return [Array] the given result array with content added from the operation + # + def unfold(result, array, scope) + array.each do |x| + if x.is_a?(Puppet::Pops::Model::UnfoldExpression) + result.concat(evaluate(x, scope)) + else + result << evaluate(x, scope) + end + end + result + end + private :unfold + end diff --git a/lib/puppet/pops/model/factory.rb b/lib/puppet/pops/model/factory.rb index 43eab49a3..64e6c03d1 100644 --- a/lib/puppet/pops/model/factory.rb +++ b/lib/puppet/pops/model/factory.rb @@ -1,978 +1,982 @@ # Factory is a helper class that makes construction of a Pops Model # much more convenient. It can be viewed as a small internal DSL for model # constructions. # For usage see tests using the factory. # # @todo All those uppercase methods ... they look bad in one way, but stand out nicely in the grammar... # decide if they should change into lower case names (some of the are lower case)... # class Puppet::Pops::Model::Factory Model = Puppet::Pops::Model attr_accessor :current alias_method :model, :current # Shared build_visitor, since there are many instances of Factory being used @@build_visitor = Puppet::Pops::Visitor.new(self, "build") @@interpolation_visitor = Puppet::Pops::Visitor.new(self, "interpolate") # Initialize a factory with a single object, or a class with arguments applied to build of # created instance # def initialize o, *args @current = case o when Model::PopsObject o when Puppet::Pops::Model::Factory o.current else build(o, *args) end end # Polymorphic build def build(o, *args) begin @@build_visitor.visit_this(self, o, *args) rescue =>e # debug here when in trouble... raise e end end # Polymorphic interpolate def interpolate() begin @@interpolation_visitor.visit_this_0(self, current) rescue =>e # debug here when in trouble... raise e end end # Building of Model classes def build_ArithmeticExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end def build_AssignmentExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end def build_AttributeOperation(o, name, op, value) o.operator = op o.attribute_name = name.to_s # BOOLEAN is allowed in the grammar o.value_expr = build(value) o end def build_AccessExpression(o, left, *keys) o.left_expr = to_ops(left) keys.each {|expr| o.addKeys(to_ops(expr)) } o end def build_BinaryExpression(o, left, right) o.left_expr = to_ops(left) o.right_expr = to_ops(right) o end def build_BlockExpression(o, *args) args.each {|expr| o.addStatements(to_ops(expr)) } o end def build_CollectExpression(o, type_expr, query_expr, attribute_operations) o.type_expr = to_ops(type_expr) o.query = build(query_expr) attribute_operations.each {|op| o.addOperations(build(op)) } o end def build_ComparisonExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end def build_ConcatenatedString(o, *args) args.each {|expr| o.addSegments(build(expr)) } o end def build_CreateTypeExpression(o, name, super_name = nil) o.name = name o.super_name = super_name o end def build_CreateEnumExpression(o, *args) o.name = args.slice(0) if args.size == 2 o.values = build(args.last) o end def build_CreateAttributeExpression(o, name, datatype_expr) o.name = name o.type = to_ops(datatype_expr) o end def build_HeredocExpression(o, name, expr) o.syntax = name o.text_expr = build(expr) o end # @param name [String] a valid classname # @param parameters [Array] may be empty # @param parent_class_name [String, nil] a valid classname referencing a parent class, optional. # @param body [Array, Expression, nil] expression that constitute the body # @return [Model::HostClassDefinition] configured from the parameters # def build_HostClassDefinition(o, name, parameters, parent_class_name, body) build_NamedDefinition(o, name, parameters, body) o.parent_class = parent_class_name if parent_class_name o end def build_ResourceOverrideExpression(o, resources, attribute_operations) o.resources = build(resources) attribute_operations.each {|ao| o.addOperations(build(ao)) } o end def build_KeyedEntry(o, k, v) o.key = to_ops(k) o.value = to_ops(v) o end def build_LiteralHash(o, *keyed_entries) keyed_entries.each {|entry| o.addEntries build(entry) } o end def build_LiteralList(o, *values) values.each {|v| o.addValues build(v) } o end def build_LiteralFloat(o, val) o.value = val o end def build_LiteralInteger(o, val, radix) o.value = val o.radix = radix o end def build_IfExpression(o, t, ift, els) o.test = build(t) o.then_expr = build(ift) o.else_expr= build(els) o end def build_MatchExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end # Builds body :) from different kinds of input # @overload f_build_body(nothing) # @param nothing [nil] unchanged, produces nil # @overload f_build_body(array) # @param array [Array] turns into a BlockExpression # @overload f_build_body(expr) # @param expr [Expression] produces the given expression # @overload f_build_body(obj) # @param obj [Object] produces the result of calling #build with body as argument def f_build_body(body) case body when NilClass nil when Array Puppet::Pops::Model::Factory.new(Model::BlockExpression, *body) else build(body) end end def build_LambdaExpression(o, parameters, body) parameters.each {|p| o.addParameters(build(p)) } b = f_build_body(body) o.body = to_ops(b) if b o end def build_NamedDefinition(o, name, parameters, body) parameters.each {|p| o.addParameters(build(p)) } b = f_build_body(body) o.body = b.current if b o.name = name o end # @param o [Model::NodeDefinition] # @param hosts [Array] host matches # @param parent [Expression] parent node matcher # @param body [Object] see {#f_build_body} def build_NodeDefinition(o, hosts, parent, body) hosts.each {|h| o.addHost_matches(build(h)) } o.parent = build(parent) if parent # no nop here b = f_build_body(body) o.body = b.current if b o end def build_Parameter(o, name, expr) o.name = name o.value = build(expr) if expr # don't build a nil/nop o end def build_QualifiedReference(o, name) o.value = name.to_s.downcase o end def build_RelationshipExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end def build_ResourceExpression(o, type_name, bodies) o.type_name = build(type_name) bodies.each {|b| o.addBodies(build(b)) } o end def build_RenderStringExpression(o, string) o.value = string; o end def build_ResourceBody(o, title_expression, attribute_operations) o.title = build(title_expression) attribute_operations.each {|ao| o.addOperations(build(ao)) } o end def build_ResourceDefaultsExpression(o, type_ref, attribute_operations) o.type_ref = build(type_ref) attribute_operations.each {|ao| o.addOperations(build(ao)) } o end def build_SelectorExpression(o, left, *selectors) o.left_expr = to_ops(left) selectors.each {|s| o.addSelectors(build(s)) } o end # Builds a SubLocatedExpression - this wraps the expression in a sublocation configured # from the given token # A SubLocated holds its own locator that is used for subexpressions holding positions relative # to what it describes. # def build_SubLocatedExpression(o, token, expression) o.expr = build(expression) o.offset = token.offset o.length = token.length locator = token.locator o.locator = locator o.leading_line_count = locator.leading_line_count o.leading_line_offset = locator.leading_line_offset # Index is held in sublocator's parent locator - needed to be able to reconstruct o.line_offsets = locator.locator.line_index o end def build_SelectorEntry(o, matching, value) o.matching_expr = build(matching) o.value_expr = build(value) o end def build_QueryExpression(o, expr) ops = to_ops(expr) o.expr = ops unless Puppet::Pops::Model::Factory.nop? ops o end def build_UnaryExpression(o, expr) ops = to_ops(expr) o.expr = ops unless Puppet::Pops::Model::Factory.nop? ops o end def build_Program(o, body, definitions, locator) o.body = to_ops(body) # non containment definitions.each { |d| o.addDefinitions(d) } o.source_ref = locator.file o.source_text = locator.string o.line_offsets = locator.line_index o.locator = locator o end def build_QualifiedName(o, name) o.value = name.to_s o end # Puppet::Pops::Model::Factory helpers def f_build_unary(klazz, expr) Puppet::Pops::Model::Factory.new(build(klazz.new, expr)) end def f_build_binary_op(klazz, op, left, right) Puppet::Pops::Model::Factory.new(build(klazz.new, op, left, right)) end def f_build_binary(klazz, left, right) Puppet::Pops::Model::Factory.new(build(klazz.new, left, right)) end def f_build_vararg(klazz, left, *arg) Puppet::Pops::Model::Factory.new(build(klazz.new, left, *arg)) end def f_arithmetic(op, r) f_build_binary_op(Model::ArithmeticExpression, op, current, r) end def f_comparison(op, r) f_build_binary_op(Model::ComparisonExpression, op, current, r) end def f_match(op, r) f_build_binary_op(Model::MatchExpression, op, current, r) end # Operator helpers def in(r) f_build_binary(Model::InExpression, current, r); end def or(r) f_build_binary(Model::OrExpression, current, r); end def and(r) f_build_binary(Model::AndExpression, current, r); end def not(); f_build_unary(Model::NotExpression, self); end def minus(); f_build_unary(Model::UnaryMinusExpression, self); end + def unfold(); f_build_unary(Model::UnfoldExpression, self); end + def text(); f_build_unary(Model::TextExpression, self); end def var(); f_build_unary(Model::VariableExpression, self); end def [](*r); f_build_vararg(Model::AccessExpression, current, *r); end def dot r; f_build_binary(Model::NamedAccessExpression, current, r); end def + r; f_arithmetic(:+, r); end def - r; f_arithmetic(:-, r); end def / r; f_arithmetic(:/, r); end def * r; f_arithmetic(:*, r); end def % r; f_arithmetic(:%, r); end def << r; f_arithmetic(:<<, r); end def >> r; f_arithmetic(:>>, r); end def < r; f_comparison(:<, r); end def <= r; f_comparison(:<=, r); end def > r; f_comparison(:>, r); end def >= r; f_comparison(:>=, r); end def == r; f_comparison(:==, r); end def ne r; f_comparison(:'!=', r); end def =~ r; f_match(:'=~', r); end def mne r; f_match(:'!~', r); end def paren(); f_build_unary(Model::ParenthesizedExpression, current); end def relop op, r f_build_binary_op(Model::RelationshipExpression, op.to_sym, current, r) end def select *args Puppet::Pops::Model::Factory.new(build(Model::SelectorExpression, current, *args)) end # For CaseExpression, setting the default for an already build CaseExpression def default r current.addOptions(Puppet::Pops::Model::Factory.WHEN(:default, r).current) self end def lambda=(lambda) current.lambda = lambda.current self end # Assignment = def set(r) f_build_binary_op(Model::AssignmentExpression, :'=', current, r) end # Assignment += def plus_set(r) f_build_binary_op(Model::AssignmentExpression, :'+=', current, r) end # Assignment -= def minus_set(r) f_build_binary_op(Model::AssignmentExpression, :'-=', current, r) end def attributes(*args) args.each {|a| current.addAttributes(build(a)) } self end # Catch all delegation to current def method_missing(meth, *args, &block) if current.respond_to?(meth) current.send(meth, *args, &block) else super end end def respond_to?(meth, include_all=false) current.respond_to?(meth, include_all) || super end def self.record_position(o, start_locatable, end_locateable) new(o).record_position(start_locatable, end_locateable) end # Records the position (start -> end) and computes the resulting length. # def record_position(start_locatable, end_locatable) from = start_locatable.is_a?(Puppet::Pops::Model::Factory) ? start_locatable.current : start_locatable to = end_locatable.is_a?(Puppet::Pops::Model::Factory) ? end_locatable.current : end_locatable to = from if to.nil? || to.offset.nil? o = current # record information directly in the Model::Positioned object o.offset = from.offset o.length ||= to.offset - from.offset + to.length self end # @return [Puppet::Pops::Adapters::SourcePosAdapter] with location information def loc() Puppet::Pops::Adapters::SourcePosAdapter.adapt(current) end # Returns symbolic information about an expected share of a resource expression given the LHS of a resource expr. # # * `name { }` => `:resource`, create a resource of the given type # * `Name { }` => ':defaults`, set defaults for the referenced type # * `Name[] { }` => `:override`, overrides instances referenced by LHS # * _any other_ => ':error', all other are considered illegal # def self.resource_shape(expr) expr = expr.current if expr.is_a?(Puppet::Pops::Model::Factory) case expr when Model::QualifiedName :resource when Model::QualifiedReference :defaults when Model::AccessExpression :override when 'class' :class else :error end end # Factory starting points def self.literal(o); new(o); end def self.minus(o); new(o).minus; end + def self.unfold(o); new(o).unfold; end + def self.var(o); new(o).var; end def self.block(*args); new(Model::BlockExpression, *args); end def self.string(*args); new(Model::ConcatenatedString, *args); end def self.text(o); new(o).text; end def self.IF(test_e,then_e,else_e); new(Model::IfExpression, test_e, then_e, else_e); end def self.UNLESS(test_e,then_e,else_e); new(Model::UnlessExpression, test_e, then_e, else_e); end def self.CASE(test_e,*options); new(Model::CaseExpression, test_e, *options); end def self.WHEN(values_list, block); new(Model::CaseOption, values_list, block); end def self.MAP(match, value); new(Model::SelectorEntry, match, value); end def self.TYPE(name, super_name=nil); new(Model::CreateTypeExpression, name, super_name); end def self.ATTR(name, type_expr=nil); new(Model::CreateAttributeExpression, name, type_expr); end def self.ENUM(*args); new(Model::CreateEnumExpression, *args); end def self.KEY_ENTRY(key, val); new(Model::KeyedEntry, key, val); end def self.HASH(entries); new(Model::LiteralHash, *entries); end # TODO_HEREDOC def self.HEREDOC(name, expr); new(Model::HeredocExpression, name, expr); end def self.SUBLOCATE(token, expr) new(Model::SubLocatedExpression, token, expr); end def self.LIST(entries); new(Model::LiteralList, *entries); end def self.PARAM(name, expr=nil); new(Model::Parameter, name, expr); end def self.NODE(hosts, parent, body); new(Model::NodeDefinition, hosts, parent, body); end # Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which # case it is returned. # def self.fqn(o) o = o.current if o.is_a?(Puppet::Pops::Model::Factory) o = new(Model::QualifiedName, o) unless o.is_a? Model::QualifiedName o end # Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which # case it is returned. # def self.fqr(o) o = o.current if o.is_a?(Puppet::Pops::Model::Factory) o = new(Model::QualifiedReference, o) unless o.is_a? Model::QualifiedReference o end def self.TEXT(expr) new(Model::TextExpression, new(expr).interpolate) end # TODO_EPP def self.RENDER_STRING(o) new(Model::RenderStringExpression, o) end def self.RENDER_EXPR(expr) new(Model::RenderExpression, expr) end def self.EPP(parameters, body) see_scope = false params = parameters if parameters.nil? params = [] see_scope = true end LAMBDA(params, new(Model::EppExpression, see_scope, body)) end # TODO: This is the same a fqn factory method, don't know if callers to fqn and QNAME can live with the # same result or not yet - refactor into one method when decided. # def self.QNAME(name) new(Model::QualifiedName, name) end def self.NUMBER(name_or_numeric) if n_radix = Puppet::Pops::Utils.to_n_with_radix(name_or_numeric) val, radix = n_radix if val.is_a?(Float) new(Model::LiteralFloat, val) else new(Model::LiteralInteger, val, radix) end else # Bad number should already have been caught by lexer - this should never happen raise ArgumentError, "Internal Error, NUMBER token does not contain a valid number, #{name_or_numeric}" end end # Convert input string to either a qualified name, a LiteralInteger with radix, or a LiteralFloat # def self.QNAME_OR_NUMBER(name) if n_radix = Puppet::Pops::Utils.to_n_with_radix(name) val, radix = n_radix if val.is_a?(Float) new(Model::LiteralFloat, val) else new(Model::LiteralInteger, val, radix) end else new(Model::QualifiedName, name) end end def self.QREF(name) new(Model::QualifiedReference, name) end def self.VIRTUAL_QUERY(query_expr) new(Model::VirtualQuery, query_expr) end def self.EXPORTED_QUERY(query_expr) new(Model::ExportedQuery, query_expr) end def self.ATTRIBUTE_OP(name, op, expr) new(Model::AttributeOperation, name, op, expr) end def self.CALL_NAMED(name, rval_required, argument_list) unless name.kind_of?(Model::PopsObject) name = Puppet::Pops::Model::Factory.fqn(name) unless name.is_a?(Puppet::Pops::Model::Factory) end new(Model::CallNamedFunctionExpression, name, rval_required, *argument_list) end def self.CALL_METHOD(functor, argument_list) new(Model::CallMethodExpression, functor, true, nil, *argument_list) end def self.COLLECT(type_expr, query_expr, attribute_operations) new(Model::CollectExpression, type_expr, query_expr, attribute_operations) end def self.NAMED_ACCESS(type_name, bodies) new(Model::NamedAccessExpression, type_name, bodies) end def self.RESOURCE(type_name, bodies) new(Model::ResourceExpression, type_name, bodies) end def self.RESOURCE_DEFAULTS(type_name, attribute_operations) new(Model::ResourceDefaultsExpression, type_name, attribute_operations) end def self.RESOURCE_OVERRIDE(resource_ref, attribute_operations) new(Model::ResourceOverrideExpression, resource_ref, attribute_operations) end def self.RESOURCE_BODY(resource_title, attribute_operations) new(Model::ResourceBody, resource_title, attribute_operations) end def self.PROGRAM(body, definitions, locator) new(Model::Program, body, definitions, locator) end # Builds a BlockExpression if args size > 1, else the single expression/value in args def self.block_or_expression(*args) if args.size > 1 new(Model::BlockExpression, *args) else new(args[0]) end end def self.HOSTCLASS(name, parameters, parent, body) new(Model::HostClassDefinition, name, parameters, parent, body) end def self.DEFINITION(name, parameters, body) new(Model::ResourceTypeDefinition, name, parameters, body) end def self.LAMBDA(parameters, body) new(Model::LambdaExpression, parameters, body) end def self.nop? o o.nil? || o.is_a?(Puppet::Pops::Model::Nop) end STATEMENT_CALLS = { 'require' => true, 'realize' => true, 'include' => true, 'contain' => true, 'debug' => true, 'info' => true, 'notice' => true, 'warning' => true, 'error' => true, 'fail' => true, 'import' => true # discontinued, but transform it to make it call error reporting function } # Returns true if the given name is a "statement keyword" (require, include, contain, # error, notice, info, debug # def name_is_statement(name) STATEMENT_CALLS[name] end # Transforms an array of expressions containing literal name expressions to calls if followed by an # expression, or expression list. # def self.transform_calls(expressions) expressions.reduce([]) do |memo, expr| expr = expr.current if expr.is_a?(Puppet::Pops::Model::Factory) name = memo[-1] if name.is_a?(Model::QualifiedName) && STATEMENT_CALLS[name.value] the_call = Puppet::Pops::Model::Factory.CALL_NAMED(name, false, expr.is_a?(Array) ? expr : [expr]) # last positioned is last arg if there are several record_position(the_call, name, expr.is_a?(Array) ? expr[-1] : expr) memo[-1] = the_call if expr.is_a?(Model::CallNamedFunctionExpression) # Patch statement function call to expression style # This is needed because it is first parsed as a "statement" and the requirement changes as it becomes # an argument to the name to call transform above. expr.rval_required = true end else memo << expr if expr.is_a?(Model::CallNamedFunctionExpression) # Patch rvalue expression function call to statement style. # This is not really required but done to be AST model compliant expr.rval_required = false end end memo end end # Transforms a left expression followed by an untitled resource (in the form of attribute_operations) # @param left [Factory, Expression] the lhs followed what may be a hash def self.transform_resource_wo_title(left, attribute_ops) return nil unless attribute_ops.is_a? Array # return nil if attribute_ops.find { |ao| ao.operator == :'+>' } keyed_entries = attribute_ops.map do |ao| return nil if ao.operator == :'+>' KEY_ENTRY(ao.attribute_name, ao.value_expr) end result = block_or_expression(*transform_calls([left, HASH(keyed_entries)])) result end # Building model equivalences of Ruby objects # Allows passing regular ruby objects to the factory to produce instructions # that when evaluated produce the same thing. def build_String(o) x = Model::LiteralString.new x.value = o; x end def build_NilClass(o) x = Model::Nop.new x end def build_TrueClass(o) x = Model::LiteralBoolean.new x.value = o x end def build_FalseClass(o) x = Model::LiteralBoolean.new x.value = o x end def build_Fixnum(o) x = Model::LiteralInteger.new x.value = o; x end def build_Float(o) x = Model::LiteralFloat.new x.value = o; x end def build_Regexp(o) x = Model::LiteralRegularExpression.new x.value = o; x end def build_EppExpression(o, see_scope, body) o.see_scope = see_scope b = f_build_body(body) o.body = b.current if b o end # If building a factory, simply unwrap the model oject contained in the factory. def build_Factory(o) o.current end # Creates a String literal, unless the symbol is one of the special :undef, or :default # which instead creates a LiterlUndef, or a LiteralDefault. def build_Symbol(o) case o when :undef Model::LiteralUndef.new when :default Model::LiteralDefault.new else build_String(o.to_s) end end # Creates a LiteralList instruction from an Array, where the entries are built. def build_Array(o) x = Model::LiteralList.new o.each { |v| x.addValues(build(v)) } x end # Create a LiteralHash instruction from a hash, where keys and values are built # The hash entries are added in sorted order based on key.to_s # def build_Hash(o) x = Model::LiteralHash.new (o.sort_by {|k,v| k.to_s}).each {|k,v| x.addEntries(build(Model::KeyedEntry.new, k, v)) } x end # @param rval_required [Boolean] if the call must produce a value def build_CallExpression(o, functor, rval_required, *args) o.functor_expr = to_ops(functor) o.rval_required = rval_required args.each {|x| o.addArguments(to_ops(x)) } o end def build_CallMethodExpression(o, functor, rval_required, lambda, *args) build_CallExpression(o, functor, rval_required, *args) o.lambda = lambda o end def build_CaseExpression(o, test, *args) o.test = build(test) args.each {|opt| o.addOptions(build(opt)) } o end def build_CaseOption(o, value_list, then_expr) value_list = [value_list] unless value_list.is_a? Array value_list.each { |v| o.addValues(build(v)) } b = f_build_body(then_expr) o.then_expr = to_ops(b) if b o end # Build a Class by creating an instance of it, and then calling build on the created instance # with the given arguments def build_Class(o, *args) build(o.new(), *args) end def interpolate_Factory(o) interpolate(o.current) end def interpolate_LiteralInteger(o) # convert number to a variable self.class.new(o).var end def interpolate_Object(o) o end def interpolate_QualifiedName(o) self.class.new(o).var end # rewrite left expression to variable if it is name, number, and recurse if it is an access expression # this is for interpolation support in new lexer (${NAME}, ${NAME[}}, ${NUMBER}, ${NUMBER[]} - all # other expressions requires variables to be preceded with $ # def interpolate_AccessExpression(o) if is_interop_rewriteable?(o.left_expr) o.left_expr = to_ops(self.class.new(o.left_expr).interpolate) end o end def interpolate_NamedAccessExpression(o) if is_interop_rewriteable?(o.left_expr) o.left_expr = to_ops(self.class.new(o.left_expr).interpolate) end o end # Rewrite method calls on the form ${x.each ...} to ${$x.each} def interpolate_CallMethodExpression(o) if is_interop_rewriteable?(o.functor_expr) o.functor_expr = to_ops(self.class.new(o.functor_expr).interpolate) end o end def is_interop_rewriteable?(o) case o when Model::AccessExpression, Model::QualifiedName, Model::NamedAccessExpression, Model::CallMethodExpression true when Model::LiteralInteger # Only decimal integers can represent variables, else it is a number o.radix == 10 else false end end # Checks if the object is already a model object, or build it def to_ops(o, *args) case o when Model::PopsObject o when Puppet::Pops::Model::Factory o.current else build(o, *args) end end def self.concat(*args) new(args.map do |e| e = e.current if e.is_a?(self) case e when Model::LiteralString e.value when String e else raise ArgumentError, "can only concatenate strings, got #{e.class}" end end.join('')) end end diff --git a/lib/puppet/pops/model/model.rb b/lib/puppet/pops/model/model.rb index b186aca3f..b77c6ff01 100644 --- a/lib/puppet/pops/model/model.rb +++ b/lib/puppet/pops/model/model.rb @@ -1,606 +1,609 @@ # # The Puppet Pops Metamodel # # This module contains a formal description of the Puppet Pops (*P*uppet *OP*eration instruction*S*). # It describes a Metamodel containing DSL instructions, a description of PuppetType and related # classes needed to evaluate puppet logic. # The metamodel resembles the existing AST model, but it is a semantic model of instructions and # the types that they operate on rather than an Abstract Syntax Tree, although closely related. # # The metamodel is anemic (has no behavior) except basic datatype and type # assertions and reference/containment assertions. # The metamodel is also a generalized description of the Puppet DSL to enable the # same metamodel to be used to express Puppet DSL models (instances) with different semantics as # the language evolves. # # The metamodel is concretized by a validator for a particular version of # the Puppet DSL language. # # This metamodel is expressed using RGen. # require 'rgen/metamodel_builder' module Puppet::Pops::Model extend RGen::MetamodelBuilder::ModuleExtension # A base class for modeled objects that makes them Visitable, and Adaptable. # class PopsObject < RGen::MetamodelBuilder::MMBase include Puppet::Pops::Visitable include Puppet::Pops::Adaptable include Puppet::Pops::Containment abstract end # A Positioned object has an offset measured in an opaque unit (representing characters) from the start # of a source text (starting # from 0), and a length measured in the same opaque unit. The resolution of the opaque unit requires the # aid of a Locator instance that knows about the measure. This information is stored in the model's # root node - a Program. # # The offset and length are optional if the source of the model is not from parsed text. # class Positioned < PopsObject abstract has_attr 'offset', Integer has_attr 'length', Integer end # @abstract base class for expressions class Expression < Positioned abstract end # A Nop - the "no op" expression. # @note not really needed since the evaluator can evaluate nil with the meaning of NoOp # @todo deprecate? May be useful if there is the need to differentiate between nil and Nop when transforming model. # class Nop < Expression end # A binary expression is abstract and has a left and a right expression. The order of evaluation # and semantics are determined by the concrete subclass. # class BinaryExpression < Expression abstract # # @!attribute [rw] left_expr # @return [Expression] contains_one_uni 'left_expr', Expression, :lowerBound => 1 contains_one_uni 'right_expr', Expression, :lowerBound => 1 end # An unary expression is abstract and contains one expression. The semantics are determined by # a concrete subclass. # class UnaryExpression < Expression abstract contains_one_uni 'expr', Expression, :lowerBound => 1 end # A class that simply evaluates to the contained expression. # It is of value in order to preserve user entered parentheses in transformations, and # transformations from model to source. # class ParenthesizedExpression < UnaryExpression; end # A boolean not expression, reversing the truth of the unary expr. # class NotExpression < UnaryExpression; end # An arithmetic expression reversing the polarity of the numeric unary expr. # class UnaryMinusExpression < UnaryExpression; end + # Unfolds an array (a.k.a 'splat') + class UnfoldExpression < UnaryExpression; end + # An assignment expression assigns a value to the lval() of the left_expr. # class AssignmentExpression < BinaryExpression has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'=', :'+=', :'-=']), :lowerBound => 1 end # An arithmetic expression applies an arithmetic operator on left and right expressions. # class ArithmeticExpression < BinaryExpression has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'+', :'-', :'*', :'%', :'/', :'<<', :'>>' ]), :lowerBound => 1 end # A relationship expression associates the left and right expressions # class RelationshipExpression < BinaryExpression has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'->', :'<-', :'~>', :'<~']), :lowerBound => 1 end # A binary expression, that accesses the value denoted by right in left. i.e. typically # expressed concretely in a language as left[right]. # class AccessExpression < Expression contains_one_uni 'left_expr', Expression, :lowerBound => 1 contains_many_uni 'keys', Expression, :lowerBound => 1 end # A comparison expression compares left and right using a comparison operator. # class ComparisonExpression < BinaryExpression has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'==', :'!=', :'<', :'>', :'<=', :'>=' ]), :lowerBound => 1 end # A match expression matches left and right using a matching operator. # class MatchExpression < BinaryExpression has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'!~', :'=~']), :lowerBound => 1 end # An 'in' expression checks if left is 'in' right # class InExpression < BinaryExpression; end # A boolean expression applies a logical connective operator (and, or) to left and right expressions. # class BooleanExpression < BinaryExpression abstract end # An and expression applies the logical connective operator and to left and right expression # and does not evaluate the right expression if the left expression is false. # class AndExpression < BooleanExpression; end # An or expression applies the logical connective operator or to the left and right expression # and does not evaluate the right expression if the left expression is true # class OrExpression < BooleanExpression; end # A literal list / array containing 0:M expressions. # class LiteralList < Expression contains_many_uni 'values', Expression end # A Keyed entry has a key and a value expression. It is typically used as an entry in a Hash. # class KeyedEntry < Positioned contains_one_uni 'key', Expression, :lowerBound => 1 contains_one_uni 'value', Expression, :lowerBound => 1 end # A literal hash is a collection of KeyedEntry objects # class LiteralHash < Expression contains_many_uni 'entries', KeyedEntry end # A block contains a list of expressions # class BlockExpression < Expression contains_many_uni 'statements', Expression end # A case option entry in a CaseStatement # class CaseOption < Expression contains_many_uni 'values', Expression, :lowerBound => 1 contains_one_uni 'then_expr', Expression, :lowerBound => 1 end # A case expression has a test, a list of options (multi values => block map). # One CaseOption may contain a LiteralDefault as value. This option will be picked if nothing # else matched. # class CaseExpression < Expression contains_one_uni 'test', Expression, :lowerBound => 1 contains_many_uni 'options', CaseOption end # A query expression is an expression that is applied to some collection. # The contained optional expression may contain different types of relational expressions depending # on what the query is applied to. # class QueryExpression < Expression abstract contains_one_uni 'expr', Expression, :lowerBound => 0 end # An exported query is a special form of query that searches for exported objects. # class ExportedQuery < QueryExpression end # A virtual query is a special form of query that searches for virtual objects. # class VirtualQuery < QueryExpression end # An attribute operation sets or appends a value to a named attribute. # class AttributeOperation < Positioned has_attr 'attribute_name', String, :lowerBound => 1 has_attr 'operator', RGen::MetamodelBuilder::DataTypes::Enum.new([:'=>', :'+>', ]), :lowerBound => 1 contains_one_uni 'value_expr', Expression, :lowerBound => 1 end # An object that collects stored objects from the central cache and returns # them to the current host. Operations may optionally be applied. # class CollectExpression < Expression contains_one_uni 'type_expr', Expression, :lowerBound => 1 contains_one_uni 'query', QueryExpression, :lowerBound => 1 contains_many_uni 'operations', AttributeOperation end class Parameter < Positioned has_attr 'name', String, :lowerBound => 1 contains_one_uni 'value', Expression end # Abstract base class for definitions. # class Definition < Expression abstract end # Abstract base class for named and parameterized definitions. class NamedDefinition < Definition abstract has_attr 'name', String, :lowerBound => 1 contains_many_uni 'parameters', Parameter contains_one_uni 'body', Expression end # A resource type definition (a 'define' in the DSL). # class ResourceTypeDefinition < NamedDefinition end # A node definition matches hosts using Strings, or Regular expressions. It may inherit from # a parent node (also using a String or Regular expression). # class NodeDefinition < Definition contains_one_uni 'parent', Expression contains_many_uni 'host_matches', Expression, :lowerBound => 1 contains_one_uni 'body', Expression end class LocatableExpression < Expression has_many_attr 'line_offsets', Integer has_attr 'locator', Object, :lowerBound => 1, :transient => true module ClassModule # Go through the gymnastics of making either value or pattern settable # with synchronization to the other form. A derived value cannot be serialized # and we want to serialize the pattern. When recreating the object we need to # recreate it from the pattern string. # The below sets both values if one is changed. # def locator unless result = getLocator setLocator(result = Puppet::Pops::Parser::Locator.locator(source_text, source_ref(), line_offsets)) end result end end end # Contains one expression which has offsets reported virtually (offset against the Program's # overall locator). # class SubLocatedExpression < Expression contains_one_uni 'expr', Expression, :lowerBound => 1 # line offset index for contained expressions has_many_attr 'line_offsets', Integer # Number of preceding lines (before the line_offsets) has_attr 'leading_line_count', Integer # The offset of the leading source line (i.e. size of "left margin"). has_attr 'leading_line_offset', Integer # The locator for the sub-locatable's children (not for the sublocator itself) # The locator is not serialized and is recreated on demand from the indexing information # in self. # has_attr 'locator', Object, :lowerBound => 1, :transient => true module ClassModule def locator unless result = getLocator # Adapt myself to get the Locator for me adapter = Puppet::Pops::Adapters::SourcePosAdapter.adapt(self) # Get the program (root), and deal with case when not contained in a program program = eAllContainers.find {|c| c.is_a?(Program) } source_ref = program.nil? ? '' : program.source_ref # An outer locator is needed since SubLocator only deals with offsets. This outer locator # has 0,0 as origin. outer_locator = Puppet::Pops::Parser::Locator.locator(adpater.extract_text, source_ref, line_offsets) # Create a sublocator that describes an offset from the outer # NOTE: the offset of self is the same as the sublocator's leading_offset result = Puppet::Pops::Parser::Locator::SubLocator.new(outer_locator, leading_line_count, offset, leading_line_offset) setLocator(result) end result end end end # A heredoc is a wrapper around a LiteralString or a ConcatenatedStringExpression with a specification # of syntax. The expectation is that "syntax" has meaning to a validator. A syntax of nil or '' means # "unspecified syntax". # class HeredocExpression < Expression has_attr 'syntax', String contains_one_uni 'text_expr', Expression, :lowerBound => 1 end # A class definition # class HostClassDefinition < NamedDefinition has_attr 'parent_class', String end # i.e {|parameters| body } class LambdaExpression < Expression contains_many_uni 'parameters', Parameter contains_one_uni 'body', Expression end # If expression. If test is true, the then_expr part should be evaluated, else the (optional) # else_expr. An 'elsif' is simply an else_expr = IfExpression, and 'else' is simply else == Block. # a 'then' is typically a Block. # class IfExpression < Expression contains_one_uni 'test', Expression, :lowerBound => 1 contains_one_uni 'then_expr', Expression, :lowerBound => 1 contains_one_uni 'else_expr', Expression end # An if expression with boolean reversed test. # class UnlessExpression < IfExpression end # An abstract call. # class CallExpression < Expression abstract # A bit of a crutch; functions are either procedures (void return) or has an rvalue # this flag tells the evaluator that it is a failure to call a function that is void/procedure # where a value is expected. # has_attr 'rval_required', Boolean, :defaultValueLiteral => "false" contains_one_uni 'functor_expr', Expression, :lowerBound => 1 contains_many_uni 'arguments', Expression contains_one_uni 'lambda', Expression end # A function call where the functor_expr should evaluate to something callable. # class CallFunctionExpression < CallExpression; end # A function call where the given functor_expr should evaluate to the name # of a function. # class CallNamedFunctionExpression < CallExpression; end # A method/function call where the function expr is a NamedAccess and with support for # an optional lambda block # class CallMethodExpression < CallExpression end # Abstract base class for literals. # class Literal < Expression abstract end # A literal value is an abstract value holder. The type of the contained value is # determined by the concrete subclass. # class LiteralValue < Literal abstract end # A Regular Expression Literal. # class LiteralRegularExpression < LiteralValue has_attr 'value', Object, :lowerBound => 1, :transient => true has_attr 'pattern', String, :lowerBound => 1 module ClassModule # Go through the gymnastics of making either value or pattern settable # with synchronization to the other form. A derived value cannot be serialized # and we want to serialize the pattern. When recreating the object we need to # recreate it from the pattern string. # The below sets both values if one is changed. # def value= regexp setValue regexp setPattern regexp.to_s end def pattern= regexp_string setPattern regexp_string setValue Regexp.new(regexp_string) end end end # A Literal String # class LiteralString < LiteralValue has_attr 'value', String, :lowerBound => 1 end class LiteralNumber < LiteralValue abstract end # A literal number has a radix of decimal (10), octal (8), or hex (16) to enable string conversion with the input radix. # By default, a radix of 10 is used. # class LiteralInteger < LiteralNumber has_attr 'radix', Integer, :lowerBound => 1, :defaultValueLiteral => "10" has_attr 'value', Integer, :lowerBound => 1 end class LiteralFloat < LiteralNumber has_attr 'value', Float, :lowerBound => 1 end # The DSL `undef`. # class LiteralUndef < Literal; end # The DSL `default` class LiteralDefault < Literal; end # DSL `true` or `false` class LiteralBoolean < LiteralValue has_attr 'value', Boolean, :lowerBound => 1 end # A text expression is an interpolation of an expression. If the embedded expression is # a QualifiedName, it is taken as a variable name and resolved. All other expressions are evaluated. # The result is transformed to a string. # class TextExpression < UnaryExpression; end # An interpolated/concatenated string. The contained segments are expressions. Verbatim sections # should be LiteralString instances, and interpolated expressions should either be # TextExpression instances (if QualifiedNames should be turned into variables), or any other expression # if such treatment is not needed. # class ConcatenatedString < Expression contains_many_uni 'segments', Expression end # A DSL NAME (one or multiple parts separated by '::'). # class QualifiedName < LiteralValue has_attr 'value', String, :lowerBound => 1 end # A DSL CLASSREF (one or multiple parts separated by '::' where (at least) the first part starts with an upper case letter). # class QualifiedReference < LiteralValue has_attr 'value', String, :lowerBound => 1 end # A Variable expression looks up value of expr (some kind of name) in scope. # The expression is typically a QualifiedName, or QualifiedReference. # class VariableExpression < UnaryExpression; end # Epp start class EppExpression < Expression has_attr 'see_scope', Boolean contains_one_uni 'body', Expression end # A string to render class RenderStringExpression < LiteralString end # An expression to evluate and render class RenderExpression < UnaryExpression end # A resource body describes one resource instance # class ResourceBody < Positioned contains_one_uni 'title', Expression contains_many_uni 'operations', AttributeOperation end # An abstract resource describes the form of the resource (regular, virtual or exported) # and adds convenience methods to ask if it is virtual or exported. # All derived classes may not support all forms, and these needs to be validated # class AbstractResource < Expression abstract has_attr 'form', RGen::MetamodelBuilder::DataTypes::Enum.new([:regular, :virtual, :exported ]), :lowerBound => 1, :defaultValueLiteral => "regular" has_attr 'virtual', Boolean, :derived => true has_attr 'exported', Boolean, :derived => true module ClassModule def virtual_derived form == :virtual || form == :exported end def exported_derived form == :exported end end end # A resource expression is used to instantiate one or many resource. Resources may optionally # be virtual or exported, an exported resource is always virtual. # class ResourceExpression < AbstractResource contains_one_uni 'type_name', Expression, :lowerBound => 1 contains_many_uni 'bodies', ResourceBody end # A resource defaults sets defaults for a resource type. This class inherits from AbstractResource # but does only support the :regular form (this is intentional to be able to produce better error messages # when illegal forms are applied to a model. # class ResourceDefaultsExpression < AbstractResource contains_one_uni 'type_ref', QualifiedReference contains_many_uni 'operations', AttributeOperation end # A resource override overrides already set values. # class ResourceOverrideExpression < Expression contains_one_uni 'resources', Expression, :lowerBound => 1 contains_many_uni 'operations', AttributeOperation end # A selector entry describes a map from matching_expr to value_expr. # class SelectorEntry < Positioned contains_one_uni 'matching_expr', Expression, :lowerBound => 1 contains_one_uni 'value_expr', Expression, :lowerBound => 1 end # A selector expression represents a mapping from a left_expr to a matching SelectorEntry. # class SelectorExpression < Expression contains_one_uni 'left_expr', Expression, :lowerBound => 1 contains_many_uni 'selectors', SelectorEntry end # A named access expression looks up a named part. (e.g. $a.b) # class NamedAccessExpression < BinaryExpression; end # A Program is the top level construct returned by the parser # it contains the parsed result in the body, and has a reference to the full source text, # and its origin. The line_offset's is an array with the start offset of each line. # class Program < PopsObject contains_one_uni 'body', Expression has_many 'definitions', Definition has_attr 'source_text', String has_attr 'source_ref', String has_many_attr 'line_offsets', Integer has_attr 'locator', Object, :lowerBound => 1, :transient => true module ClassModule def locator unless result = getLocator setLocator(result = Puppet::Pops::Parser::Locator.locator(source_text, source_ref(), line_offsets)) end result end end end end diff --git a/lib/puppet/pops/model/model_label_provider.rb b/lib/puppet/pops/model/model_label_provider.rb index 979aa4bc5..aca2200e2 100644 --- a/lib/puppet/pops/model/model_label_provider.rb +++ b/lib/puppet/pops/model/model_label_provider.rb @@ -1,104 +1,105 @@ # A provider of labels for model object, producing a human name for the model object. # As an example, if object is an ArithmeticExpression with operator +, `#a_an(o)` produces "a '+' Expression", # #the(o) produces "the + Expression", and #label produces "+ Expression". # class Puppet::Pops::Model::ModelLabelProvider < Puppet::Pops::LabelProvider def initialize @@label_visitor ||= Puppet::Pops::Visitor.new(self,"label",0,0) end # Produces a label for the given objects type/operator without article. # If a Class is given, its name is used as label # def label o @@label_visitor.visit(o) end def label_Factory o ; label(o.current) end def label_Array o ; "Array" end def label_LiteralInteger o ; "Literal Integer" end def label_LiteralFloat o ; "Literal Float" end def label_ArithmeticExpression o ; "'#{o.operator}' expression" end def label_AccessExpression o ; "'[]' expression" end def label_MatchExpression o ; "'#{o.operator}' expression" end def label_CollectExpression o ; label(o.query) end def label_EppExpression o ; "Epp Template" end def label_ExportedQuery o ; "Exported Query" end def label_VirtualQuery o ; "Virtual Query" end def label_QueryExpression o ; "Collect Query" end def label_ComparisonExpression o ; "'#{o.operator}' expression" end def label_AndExpression o ; "'and' expression" end def label_OrExpression o ; "'or' expression" end def label_InExpression o ; "'in' expression" end def label_AssignmentExpression o ; "'#{o.operator}' expression" end def label_AttributeOperation o ; "'#{o.operator}' expression" end def label_LiteralList o ; "Array Expression" end def label_LiteralHash o ; "Hash Expression" end def label_KeyedEntry o ; "Hash Entry" end def label_LiteralBoolean o ; "Boolean" end def label_TrueClass o ; "Boolean" end def label_FalseClass o ; "Boolean" end def label_LiteralString o ; "String" end def label_LambdaExpression o ; "Lambda" end def label_LiteralDefault o ; "'default' expression" end def label_LiteralUndef o ; "'undef' expression" end def label_LiteralRegularExpression o ; "Regular Expression" end def label_Nop o ; "Nop Expression" end def label_NamedAccessExpression o ; "'.' expression" end def label_NilClass o ; "Nil Object" end def label_NotExpression o ; "'not' expression" end def label_VariableExpression o ; "Variable" end def label_TextExpression o ; "Expression in Interpolated String" end def label_UnaryMinusExpression o ; "Unary Minus" end + def label_UnfoldExpression o ; "Unfold" end def label_BlockExpression o ; "Block Expression" end def label_ConcatenatedString o ; "Double Quoted String" end def label_HeredocExpression o ; "'@(#{o.syntax})' expression" end def label_HostClassDefinition o ; "Host Class Definition" end def label_NodeDefinition o ; "Node Definition" end def label_ResourceTypeDefinition o ; "'define' expression" end def label_ResourceOverrideExpression o ; "Resource Override" end def label_Parameter o ; "Parameter Definition" end def label_ParenthesizedExpression o ; "Parenthesized Expression" end def label_IfExpression o ; "'if' statement" end def label_UnlessExpression o ; "'unless' Statement" end def label_CallNamedFunctionExpression o ; "Function Call" end def label_CallMethodExpression o ; "Method call" end def label_CaseExpression o ; "'case' statement" end def label_CaseOption o ; "Case Option" end def label_RenderStringExpression o ; "Epp Text" end def label_RenderExpression o ; "Epp Interpolated Expression" end def label_RelationshipExpression o ; "'#{o.operator}' expression" end def label_ResourceBody o ; "Resource Instance Definition" end def label_ResourceDefaultsExpression o ; "Resource Defaults Expression" end def label_ResourceExpression o ; "Resource Statement" end def label_SelectorExpression o ; "Selector Expression" end def label_SelectorEntry o ; "Selector Option" end def label_Integer o ; "Integer" end def label_Fixnum o ; "Integer" end def label_Bignum o ; "Integer" end def label_Float o ; "Float" end def label_String o ; "String" end def label_Regexp o ; "Regexp" end def label_Object o ; "Object" end def label_Hash o ; "Hash" end def label_QualifiedName o ; "Name" end def label_QualifiedReference o ; "Type-Name" end def label_PAbstractType o ; "#{Puppet::Pops::Types::TypeCalculator.string(o)}-Type" end def label_PResourceType o if o.title "#{Puppet::Pops::Types::TypeCalculator.string(o)} Resource-Reference" else "#{Puppet::Pops::Types::TypeCalculator.string(o)}-Type" end end def label_Class o if o <= Puppet::Pops::Types::PAbstractType simple_name = o.name.split('::').last simple_name[1..-5] + "-Type" else o.name end end end diff --git a/lib/puppet/pops/model/model_tree_dumper.rb b/lib/puppet/pops/model/model_tree_dumper.rb index 0366a421a..25eaed4d8 100644 --- a/lib/puppet/pops/model/model_tree_dumper.rb +++ b/lib/puppet/pops/model/model_tree_dumper.rb @@ -1,385 +1,389 @@ # Dumps a Pops::Model in reverse polish notation; i.e. LISP style # The intention is to use this for debugging output # TODO: BAD NAME - A DUMP is a Ruby Serialization # class Puppet::Pops::Model::ModelTreeDumper < Puppet::Pops::Model::TreeDumper def dump_Array o o.collect {|e| do_dump(e) } end def dump_LiteralFloat o o.value.to_s end def dump_LiteralInteger o case o.radix when 10 o.value.to_s when 8 "0%o" % o.value when 16 "0x%X" % o.value else "bad radix:" + o.value.to_s end end def dump_LiteralValue o o.value.to_s end def dump_Factory o do_dump(o.current) end def dump_ArithmeticExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end # x[y] prints as (slice x y) def dump_AccessExpression o if o.keys.size <= 1 ["slice", do_dump(o.left_expr), do_dump(o.keys[0])] else ["slice", do_dump(o.left_expr), do_dump(o.keys)] end end def dump_MatchesExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_CollectExpression o result = ["collect", do_dump(o.type_expr), :indent, :break, do_dump(o.query), :indent] o.operations do |ao| result << :break << do_dump(ao) end result += [:dedent, :dedent ] result end def dump_EppExpression o result = ["epp"] # result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 if o.body result << do_dump(o.body) else result << [] end result end def dump_ExportedQuery o result = ["<<| |>>"] result += dump_QueryExpression(o) unless is_nop?(o.expr) result end def dump_VirtualQuery o result = ["<| |>"] result += dump_QueryExpression(o) unless is_nop?(o.expr) result end def dump_QueryExpression o [do_dump(o.expr)] end def dump_ComparisonExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_AndExpression o ["&&", do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_OrExpression o ["||", do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_InExpression o ["in", do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_AssignmentExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end # Produces (name => expr) or (name +> expr) def dump_AttributeOperation o [o.attribute_name, o.operator, do_dump(o.value_expr)] end def dump_LiteralList o ["[]"] + o.values.collect {|x| do_dump(x)} end def dump_LiteralHash o ["{}"] + o.entries.collect {|x| do_dump(x)} end def dump_KeyedEntry o [do_dump(o.key), do_dump(o.value)] end def dump_MatchExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_LiteralString o "'#{o.value}'" end def dump_LambdaExpression o result = ["lambda"] result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 if o.body result << do_dump(o.body) else result << [] end result end def dump_LiteralDefault o ":default" end def dump_LiteralUndef o ":undef" end def dump_LiteralRegularExpression o "/#{o.value.source}/" end def dump_Nop o ":nop" end def dump_NamedAccessExpression o [".", do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_NilClass o "()" end def dump_NotExpression o ['!', dump(o.expr)] end def dump_VariableExpression o "$#{dump(o.expr)}" end # Interpolation (to string) shown as (str expr) def dump_TextExpression o ["str", do_dump(o.expr)] end def dump_UnaryMinusExpression o ['-', do_dump(o.expr)] end + def dump_UnfoldExpression o + ['unfold', do_dump(o.expr)] + end + def dump_BlockExpression o ["block"] + o.statements.collect {|x| do_dump(x) } end # Interpolated strings are shown as (cat seg0 seg1 ... segN) def dump_ConcatenatedString o ["cat"] + o.segments.collect {|x| do_dump(x)} end def dump_HeredocExpression(o) result = ["@(#{o.syntax})", :indent, :break, do_dump(o.text_expr), :dedent, :break] end def dump_HostClassDefinition o result = ["class", o.name] result << ["inherits", o.parent_class] if o.parent_class result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 if o.body result << do_dump(o.body) else result << [] end result end def dump_NodeDefinition o result = ["node"] result << ["matches"] + o.host_matches.collect {|m| do_dump(m) } result << ["parent", do_dump(o.parent)] if o.parent if o.body result << do_dump(o.body) else result << [] end result end def dump_NamedDefinition o # the nil must be replaced with a string result = [nil, o.name] result << ["parameters"] + o.parameters.collect {|p| do_dump(p) } if o.parameters.size() > 0 if o.body result << do_dump(o.body) else result << [] end result end def dump_ResourceTypeDefinition o result = dump_NamedDefinition(o) result[0] = 'define' result end def dump_ResourceOverrideExpression o result = ["override", do_dump(o.resources), :indent] o.operations.each do |p| result << :break << do_dump(p) end result << :dedent result end # Produces parameters as name, or (= name value) def dump_Parameter o name_part = "#{o.name}" if o.value ["=", name_part, do_dump(o.value)] else name_part end end def dump_ParenthesizedExpression o do_dump(o.expr) end # Hides that Program exists in the output (only its body is shown), the definitions are just # references to contained classes, resource types, and nodes def dump_Program(o) dump(o.body) end def dump_IfExpression o result = ["if", do_dump(o.test), :indent, :break, ["then", :indent, do_dump(o.then_expr), :dedent]] result += [:break, ["else", :indent, do_dump(o.else_expr), :dedent], :dedent] unless is_nop? o.else_expr result end def dump_UnlessExpression o result = ["unless", do_dump(o.test), :indent, :break, ["then", :indent, do_dump(o.then_expr), :dedent]] result += [:break, ["else", :indent, do_dump(o.else_expr), :dedent], :dedent] unless is_nop? o.else_expr result end # Produces (invoke name args...) when not required to produce an rvalue, and # (call name args ... ) otherwise. # def dump_CallNamedFunctionExpression o result = [o.rval_required ? "call" : "invoke", do_dump(o.functor_expr)] o.arguments.collect {|a| result << do_dump(a) } result end # def dump_CallNamedFunctionExpression o # result = [o.rval_required ? "call" : "invoke", do_dump(o.functor_expr)] # o.arguments.collect {|a| result << do_dump(a) } # result # end def dump_CallMethodExpression o result = [o.rval_required ? "call-method" : "invoke-method", do_dump(o.functor_expr)] o.arguments.collect {|a| result << do_dump(a) } result << do_dump(o.lambda) if o.lambda result end def dump_CaseExpression o result = ["case", do_dump(o.test), :indent] o.options.each do |s| result << :break << do_dump(s) end result << :dedent end def dump_CaseOption o result = ["when"] result << o.values.collect {|x| do_dump(x) } result << ["then", do_dump(o.then_expr) ] result end def dump_RelationshipExpression o [o.operator.to_s, do_dump(o.left_expr), do_dump(o.right_expr)] end def dump_RenderStringExpression o ["render-s", " '#{o.value}'"] end def dump_RenderExpression o ["render", do_dump(o.expr)] end def dump_ResourceBody o result = [do_dump(o.title), :indent] o.operations.each do |p| result << :break << do_dump(p) end result << :dedent result end def dump_ResourceDefaultsExpression o result = ["resource-defaults", do_dump(o.type_ref), :indent] o.operations.each do |p| result << :break << do_dump(p) end result << :dedent result end def dump_ResourceExpression o form = o.form == :regular ? '' : o.form.to_s + "-" result = [form+"resource", do_dump(o.type_name), :indent] o.bodies.each do |b| result << :break << do_dump(b) end result << :dedent result end def dump_SelectorExpression o ["?", do_dump(o.left_expr)] + o.selectors.collect {|x| do_dump(x) } end def dump_SelectorEntry o [do_dump(o.matching_expr), "=>", do_dump(o.value_expr)] end def dump_SubLocatedExpression o ["sublocated", do_dump(o.expr)] end def dump_Object o [o.class.to_s, o.to_s] end def is_nop? o o.nil? || o.is_a?(Puppet::Pops::Model::Nop) end end diff --git a/lib/puppet/pops/parser/egrammar.ra b/lib/puppet/pops/parser/egrammar.ra index f81e7a0d7..0a6cdc904 100644 --- a/lib/puppet/pops/parser/egrammar.ra +++ b/lib/puppet/pops/parser/egrammar.ra @@ -1,765 +1,767 @@ # vim: syntax=ruby # Parser using the Pops model, expression based class Puppet::Pops::Parser::Parser token STRING DQPRE DQMID DQPOST token LBRACK RBRACK LBRACE RBRACE SYMBOL FARROW COMMA TRUE token FALSE EQUALS APPENDS DELETES LESSEQUAL NOTEQUAL DOT COLON LLCOLLECT RRCOLLECT token QMARK LPAREN RPAREN ISEQUAL GREATEREQUAL GREATERTHAN LESSTHAN token IF ELSE token DEFINE ELSIF VARIABLE CLASS INHERITS NODE BOOLEAN token NAME SEMIC CASE DEFAULT AT ATAT LCOLLECT RCOLLECT CLASSREF token NOT OR AND UNDEF PARROW PLUS MINUS TIMES DIV LSHIFT RSHIFT UMINUS token MATCH NOMATCH REGEX IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB token IN UNLESS PIPE token LAMBDA SELBRACE token NUMBER token HEREDOC SUBLOCATE token RENDER_STRING RENDER_EXPR EPP_START EPP_END EPP_END_TRIM token FUNCTION token LOW prechigh left HIGH left SEMIC left PIPE left LPAREN left RPAREN left AT ATAT left DOT left CALL nonassoc EPP_START left LBRACK LISTSTART left RBRACK left QMARK left LCOLLECT LLCOLLECT right NOT + nonassoc SPLAT nonassoc UMINUS left IN left MATCH NOMATCH left TIMES DIV MODULO left MINUS PLUS left LSHIFT RSHIFT left NOTEQUAL ISEQUAL left GREATEREQUAL GREATERTHAN LESSTHAN LESSEQUAL left AND left OR right APPENDS DELETES EQUALS left LBRACE left SELBRACE left RBRACE left IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB left TITLE_COLON left CASE_COLON left FARROW left COMMA nonassoc RENDER_EXPR nonassoc RENDER_STRING left LOW preclow rule # Produces [Model::BlockExpression, Model::Expression, nil] depending on multiple statements, single statement or empty program : statements { result = create_program(Factory.block_or_expression(*val[0])) } | epp_expression { result = create_program(Factory.block_or_expression(*val[0])) } | nil # Produces a semantic model (non validated, but semantically adjusted). statements : syntactic_statements { result = transform_calls(val[0]) } # Change may have issues with nil; i.e. program is a sequence of nils/nops # Simplified from original which had validation for top level constructs - see statement rule # Produces Array syntactic_statements : syntactic_statement { result = [val[0]]} | syntactic_statements SEMIC syntactic_statement { result = val[0].push val[2] } | syntactic_statements syntactic_statement { result = val[0].push val[1] } # Produce a single expression or Array of expression syntactic_statement : any_expression { result = val[0] } | syntactic_statement COMMA any_expression { result = aryfy(val[0]).push val[2] } any_expression : relationship_expression relationship_expression : resource_expression =LOW { result = val[0] } | relationship_expression IN_EDGE relationship_expression { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship_expression IN_EDGE_SUB relationship_expression { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship_expression OUT_EDGE relationship_expression { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship_expression OUT_EDGE_SUB relationship_expression { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } #---EXPRESSION # # Produces Model::Expression expression : higher_precedence | expression LBRACK expressions RBRACK =LBRACK { result = val[0][*val[2]] ; loc result, val[0], val[3] } | expression IN expression { result = val[0].in val[2] ; loc result, val[1] } | expression MATCH expression { result = val[0] =~ val[2] ; loc result, val[1] } | expression NOMATCH expression { result = val[0].mne val[2] ; loc result, val[1] } | expression PLUS expression { result = val[0] + val[2] ; loc result, val[1] } | expression MINUS expression { result = val[0] - val[2] ; loc result, val[1] } | expression DIV expression { result = val[0] / val[2] ; loc result, val[1] } | expression TIMES expression { result = val[0] * val[2] ; loc result, val[1] } | expression MODULO expression { result = val[0] % val[2] ; loc result, val[1] } | expression LSHIFT expression { result = val[0] << val[2] ; loc result, val[1] } | expression RSHIFT expression { result = val[0] >> val[2] ; loc result, val[1] } | MINUS expression =UMINUS { result = val[1].minus() ; loc result, val[0] } + | TIMES expression =SPLAT { result = val[1].unfold() ; loc result, val[0] } | expression NOTEQUAL expression { result = val[0].ne val[2] ; loc result, val[1] } | expression ISEQUAL expression { result = val[0] == val[2] ; loc result, val[1] } | expression GREATERTHAN expression { result = val[0] > val[2] ; loc result, val[1] } | expression GREATEREQUAL expression { result = val[0] >= val[2] ; loc result, val[1] } | expression LESSTHAN expression { result = val[0] < val[2] ; loc result, val[1] } | expression LESSEQUAL expression { result = val[0] <= val[2] ; loc result, val[1] } | NOT expression { result = val[1].not ; loc result, val[0] } | expression AND expression { result = val[0].and val[2] ; loc result, val[1] } | expression OR expression { result = val[0].or val[2] ; loc result, val[1] } | expression EQUALS expression { result = val[0].set(val[2]) ; loc result, val[1] } | expression APPENDS expression { result = val[0].plus_set(val[2]) ; loc result, val[1] } | expression DELETES expression { result = val[0].minus_set(val[2]); loc result, val[1] } | expression QMARK selector_entries { result = val[0].select(*val[2]) ; loc result, val[0] } | LPAREN expression RPAREN { result = val[1].paren() ; loc result, val[0] } #---EXPRESSIONS # (e.g. argument list) # # This expression list can not contain function calls without parentheses around arguments # Produces Array expressions : expression { result = [val[0]] } | expressions COMMA expression { result = val[0].push(val[2]) } # These go through a chain of left recursion, ending with primary_expression higher_precedence : call_function_expression primary_expression : literal_expression | variable | call_method_with_lambda_expression | collection_expression | case_expression | if_expression | unless_expression | definition_expression | hostclass_expression | node_definition_expression | epp_render_expression | function_definition # Allways have the same value literal_expression : array | boolean | default | hash | regex | text_or_name | number | type | undef text_or_name : name { result = val[0] } | quotedtext { result = val[0] } #---CALL FUNCTION # # Produces Model::CallNamedFunction call_function_expression : primary_expression LPAREN expressions endcomma RPAREN { result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] } | primary_expression LPAREN RPAREN { result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] } | primary_expression LPAREN expressions endcomma RPAREN lambda { result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] result.lambda = val[5] } | primary_expression LPAREN RPAREN lambda { result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] result.lambda = val[3] } | primary_expression = LOW { result = val[0] } #---CALL METHOD # call_method_with_lambda_expression : call_method_expression =LOW { result = val[0] } | call_method_expression lambda { result = val[0]; val[0].lambda = val[1] } call_method_expression : named_access LPAREN expressions RPAREN { result = Factory.CALL_METHOD(val[0], val[2]); loc result, val[1], val[3] } | named_access LPAREN RPAREN { result = Factory.CALL_METHOD(val[0], []); loc result, val[1], val[3] } | named_access =LOW { result = Factory.CALL_METHOD(val[0], []); loc result, val[0] } # TODO: It may be of value to access named elements of types too named_access : expression DOT NAME { result = val[0].dot(Factory.fqn(val[2][:value])) loc result, val[1], val[2] } #---LAMBDA # # This is a temporary switch while experimenting with concrete syntax # One should be picked for inclusion in puppet. # Lambda with parameters to the left of the body lambda : lambda_parameter_list lambda_rest { result = Factory.LAMBDA(val[0], val[1]) # loc result, val[1] # TODO } lambda_rest : LBRACE statements RBRACE { result = val[1] } | LBRACE RBRACE { result = nil } # Produces Array lambda_parameter_list : PIPE PIPE { result = [] } | PIPE parameters endcomma PIPE { result = val[1] } #---CONDITIONALS # #--IF # # Produces Model::IfExpression if_expression : IF if_part { result = val[1] loc(result, val[0], val[1]) } # Produces Model::IfExpression if_part : expression LBRACE statements RBRACE else { result = Factory.IF(val[0], Factory.block_or_expression(*val[2]), val[4]) loc(result, val[0], (val[4] ? val[4] : val[3])) } | expression LBRACE RBRACE else { result = Factory.IF(val[0], nil, val[3]) loc(result, val[0], (val[3] ? val[3] : val[2])) } # Produces [Model::Expression, nil] - nil if there is no else or elsif part else : # nothing | ELSIF if_part { result = val[1] loc(result, val[0], val[1]) } | ELSE LBRACE statements RBRACE { result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] } | ELSE LBRACE RBRACE { result = nil # don't think a nop is needed here either } #--UNLESS # # Changed from Puppet 3x where there is no else part on unless # unless_expression : UNLESS expression LBRACE statements RBRACE unless_else { result = Factory.UNLESS(val[1], Factory.block_or_expression(*val[3]), val[5]) loc result, val[0], val[4] } | UNLESS expression LBRACE RBRACE unless_else { result = Factory.UNLESS(val[1], nil, nil) loc result, val[0], val[4] } # Different from else part of if, since "elsif" is not supported, but 'else' is # # Produces [Model::Expression, nil] - nil if there is no else or elsif part unless_else : # nothing | ELSE LBRACE statements RBRACE { result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] } | ELSE LBRACE RBRACE { result = nil # don't think a nop is needed here either } #--- CASE EXPRESSION # # Produces Model::CaseExpression case_expression : CASE expression LBRACE case_options RBRACE { result = Factory.CASE(val[1], *val[3]) loc result, val[0], val[4] } # Produces Array case_options : case_option { result = [val[0]] } | case_options case_option { result = val[0].push val[1] } # Produced Model::CaseOption (aka When) case_option : expressions case_colon LBRACE statements RBRACE { result = Factory.WHEN(val[0], val[3]) loc result, val[1], val[4] } | expressions case_colon LBRACE RBRACE = LOW { result = Factory.WHEN(val[0], nil) loc result, val[1], val[3] } case_colon: COLON =CASE_COLON { result = val[0] } # This special construct is required or racc will produce the wrong result when the selector entry # LHS is generalized to any expression (LBRACE looks like a hash). Thus it is not possible to write # a selector with a single entry where the entry LHS is a hash. # The SELBRACE token is a LBRACE that follows a QMARK, and this is produced by the lexer with a lookback # Produces Array # selector_entries : selector_entry | SELBRACE selector_entry_list endcomma RBRACE { result = val[1] } # Produces Array selector_entry_list : selector_entry { result = [val[0]] } | selector_entry_list COMMA selector_entry { result = val[0].push val[2] } # Produces a Model::SelectorEntry # This FARROW wins over FARROW in Hash selector_entry : expression FARROW expression { result = Factory.MAP(val[0], val[2]) ; loc result, val[1] } #---RESOURCE # # Produces [Model::ResourceExpression, Model::ResourceDefaultsExpression] # The resource expression parses a generalized syntax and then selects the correct # resulting model based on the combinatoin of the LHS and what follows. # It also handled exported and virtual resources, and the class case # resource_expression : expression =LOW { result = val[0] } | at expression LBRACE resourceinstances endsemi RBRACE { result = case Factory.resource_shape(val[1]) when :resource, :class tmp = Factory.RESOURCE(Factory.fqn(token_text(val[1])), val[3]) tmp.form = val[0] tmp when :defaults error val[1], "A resource default can not be virtual or exported" when :override error val[1], "A resource override can not be virtual or exported" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[1], val[4] } | at expression LBRACE attribute_operations endcomma RBRACE { result = case Factory.resource_shape(val[1]) when :resource, :class, :defaults, :override error val[1], "Defaults are not virtualizable" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end } | expression LBRACE resourceinstances endsemi RBRACE { result = case Factory.resource_shape(val[0]) when :resource, :class Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2]) when :defaults error val[1], "A resource default can not specify a resource name" when :override error val[1], "A resource override does not allow override of name of resource" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[0], val[4] } | expression LBRACE attribute_operations endcomma RBRACE { result = case Factory.resource_shape(val[0]) when :resource, :class # This catches deprecated syntax. # If the attribute operations does not include +>, then the found expression # is actually a LEFT followed by LITERAL_HASH # unless tmp = transform_resource_wo_title(val[0], val[2]) error val[1], "Syntax error resource body without title or hash with +>" end tmp when :defaults Factory.RESOURCE_DEFAULTS(val[0], val[2]) when :override # This was only done for override in original - TODO shuld it be here at all Factory.RESOURCE_OVERRIDE(val[0], val[2]) else error val[0], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[0], val[4] } | at CLASS LBRACE resourceinstances endsemi RBRACE { result = Factory.RESOURCE(Factory.fqn(token_text(val[1])), val[3]) result.form = val[0] loc result, val[1], val[5] } | CLASS LBRACE resourceinstances endsemi RBRACE { result = Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2]) loc result, val[0], val[4] } resourceinst : expression title_colon attribute_operations endcomma { result = Factory.RESOURCE_BODY(val[0], val[2]) } title_colon : COLON =TITLE_COLON { result = val[0] } resourceinstances : resourceinst { result = [val[0]] } | resourceinstances SEMIC resourceinst { result = val[0].push val[2] } # Produces Symbol corresponding to resource form # at : AT { result = :virtual } | AT AT { result = :exported } | ATAT { result = :exported } #---COLLECTION # # A Collection is a predicate applied to a set of objects with an implied context (used variables are # attributes of the object. # i.e. this is equivalent for source.select(QUERY).apply(ATTRIBUTE_OPERATIONS) # # Produces Model::CollectExpression # collection_expression : expression collect_query LBRACE attribute_operations endcomma RBRACE { result = Factory.COLLECT(val[0], val[1], val[3]) loc result, val[0], val[5] } | expression collect_query =LOW { result = Factory.COLLECT(val[0], val[1], []) loc result, val[0], val[1] } collect_query : LCOLLECT optional_query RCOLLECT { result = Factory.VIRTUAL_QUERY(val[1]) ; loc result, val[0], val[2] } | LLCOLLECT optional_query RRCOLLECT { result = Factory.EXPORTED_QUERY(val[1]) ; loc result, val[0], val[2] } optional_query : nil | expression #---ATTRIBUTE OPERATIONS # # (Not an expression) # # Produces Array # attribute_operations : { result = [] } | attribute_operation { result = [val[0]] } | attribute_operations COMMA attribute_operation { result = val[0].push(val[2]) } # Produces String # QUESTION: Why is BOOLEAN valid as an attribute name? # attribute_name : NAME | keyword | BOOLEAN # In this version, illegal combinations are validated instead of producing syntax errors # (Can give nicer error message "+> is not applicable to...") # Produces Model::AttributeOperation # attribute_operation : attribute_name FARROW expression { result = Factory.ATTRIBUTE_OP(val[0][:value], :'=>', val[2]) loc result, val[0], val[2] } | attribute_name PARROW expression { result = Factory.ATTRIBUTE_OP(val[0][:value], :'+>', val[2]) loc result, val[0], val[2] } #---DEFINE # # Produces Model::Definition # definition_expression : DEFINE classname parameter_list LBRACE opt_statements RBRACE { result = add_definition(Factory.DEFINITION(classname(val[1][:value]), val[2], val[4])) loc result, val[0], val[5] # New lexer does not keep track of this, this is done in validation if @lexer.respond_to?(:'indefine=') @lexer.indefine = false end } #---HOSTCLASS # # Produces Model::HostClassDefinition # hostclass_expression : CLASS stacked_classname parameter_list classparent LBRACE opt_statements RBRACE { # Remove this class' name from the namestack as all nested classes have been parsed namepop result = add_definition(Factory.HOSTCLASS(classname(val[1][:value]), val[2], token_text(val[3]), val[5])) loc result, val[0], val[6] } # Record the classname so nested classes gets a fully qualified name at parse-time # This is a separate rule since racc does not support intermediate actions. # stacked_classname : classname { namestack(val[0][:value]) ; result = val[0] } opt_statements : statements | nil # Produces String, name or nil result classparent : nil | INHERITS classnameordefault { result = val[1] } # Produces String (this construct allows a class to be named "default" and to be referenced as # the parent class. # TODO: Investigate the validity # Produces a String (classname), or a token (DEFAULT). # classnameordefault : classname | DEFAULT #---NODE # # Produces Model::NodeDefinition # node_definition_expression : NODE hostnames nodeparent LBRACE statements RBRACE { result = add_definition(Factory.NODE(val[1], val[2], val[4])) loc result, val[0], val[5] } | NODE hostnames nodeparent LBRACE RBRACE { result = add_definition(Factory.NODE(val[1], val[2], nil)) loc result, val[0], val[4] } # Hostnames is not a list of names, it is a list of name matchers (including a Regexp). # (The old implementation had a special "Hostname" object with some minimal validation) # # Produces Array # hostnames : hostname { result = [result] } | hostnames COMMA hostname { result = val[0].push(val[2]) } # Produces a LiteralExpression (string, :default, or regexp) # String with interpolation is validated for better error message hostname : dotted_name { result = val[0] } | quotedtext { result = val[0] } | DEFAULT { result = Factory.literal(:default); loc result, val[0] } | regex dotted_name : NAME { result = Factory.literal(val[0][:value]); loc result, val[0] } | dotted_name DOT NAME { result = Factory.concat(val[0], '.', val[2][:value]); loc result, val[0], val[2] } # Produces Expression, since hostname is an Expression nodeparent : nil | INHERITS hostname { result = val[1] } #---FUNCTION DEFINITION # function_definition : FUNCTION { result = Factory.QNAME(val[0][:value]) ; loc result, val[0] } # For now the function word will just be reserved, in the future it will # produce a function definition # FUNCTION classname parameter_list LBRACE opt_statements RBRACE { # result = add_definition(Factory.FUNCTION(val[1][:value], val[2], val[4])) # loc result, val[0], val[5] # } #---NAMES AND PARAMETERS COMMON TO SEVERAL RULES # Produces String # TODO: The error that "class" is not a valid classname is bad - classname rule is also used for other things classname : NAME { result = val[0] } | CLASS { error val[0], "'class' is not a valid classname" } # Produces Array parameter_list : nil { result = [] } | LPAREN RPAREN { result = [] } | LPAREN parameters endcomma RPAREN { result = val[1] } # Produces Array parameters : parameter { result = [val[0]] } | parameters COMMA parameter { result = val[0].push(val[2]) } # Produces Model::Parameter parameter : VARIABLE EQUALS expression { result = Factory.PARAM(val[0][:value], val[2]) ; loc result, val[0] } | VARIABLE { result = Factory.PARAM(val[0][:value]); loc result, val[0] } #--RESTRICTED EXPRESSIONS # i.e. where one could have expected an expression, but the set is limited ## What is allowed RHS of match operators (see expression) #match_rvalue # : regex # | text_or_name #--VARIABLE # variable : VARIABLE { result = Factory.fqn(val[0][:value]).var ; loc result, val[0] } #---LITERALS (dynamic and static) # array : LBRACK expressions RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[2] } | LBRACK expressions COMMA RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] } | LBRACK RBRACK { result = Factory.literal([]) ; loc result, val[0] } | LISTSTART expressions RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[2] } | LISTSTART expressions COMMA RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] } | LISTSTART RBRACK { result = Factory.literal([]) ; loc result, val[0] } hash : LBRACE hashpairs RBRACE { result = Factory.HASH(val[1]); loc result, val[0], val[2] } | LBRACE hashpairs COMMA RBRACE { result = Factory.HASH(val[1]); loc result, val[0], val[3] } | LBRACE RBRACE { result = Factory.literal({}) ; loc result, val[0], val[3] } hashpairs : hashpair { result = [val[0]] } | hashpairs COMMA hashpair { result = val[0].push val[2] } hashpair : expression FARROW expression { result = Factory.KEY_ENTRY(val[0], val[2]); loc result, val[1] } quotedtext : string | dq_string | heredoc string : STRING { result = Factory.literal(val[0][:value]) ; loc result, val[0] } dq_string : dqpre dqrval { result = Factory.string(val[0], *val[1]) ; loc result, val[0], val[1][-1] } dqpre : DQPRE { result = Factory.literal(val[0][:value]); loc result, val[0] } dqpost : DQPOST { result = Factory.literal(val[0][:value]); loc result, val[0] } dqmid : DQMID { result = Factory.literal(val[0][:value]); loc result, val[0] } dqrval : text_expression dqtail { result = [val[0]] + val[1] } text_expression : expression { result = Factory.TEXT(val[0]) } dqtail : dqpost { result = [val[0]] } | dqmid dqrval { result = [val[0]] + val[1] } heredoc : HEREDOC sublocated_text { result = Factory.HEREDOC(val[0][:value], val[1]); loc result, val[0] } sublocated_text : SUBLOCATE string { result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] } | SUBLOCATE dq_string { result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] } epp_expression : EPP_START epp_parameters_list statements { result = Factory.EPP(val[1], val[2]); loc result, val[0] } epp_parameters_list : =LOW{ result = nil } | PIPE PIPE { result = [] } | PIPE parameters endcomma PIPE { result = val[1] } epp_render_expression : RENDER_STRING { result = Factory.RENDER_STRING(val[0][:value]); loc result, val[0] } | RENDER_EXPR expression epp_end { result = Factory.RENDER_EXPR(val[1]); loc result, val[0], val[2] } | RENDER_EXPR LBRACE statements RBRACE epp_end { result = Factory.RENDER_EXPR(Factory.block_or_expression(*val[2])); loc result, val[0], val[4] } epp_end : EPP_END | EPP_END_TRIM number : NUMBER { result = Factory.NUMBER(val[0][:value]) ; loc result, val[0] } name : NAME { result = Factory.QNAME_OR_NUMBER(val[0][:value]) ; loc result, val[0] } type : CLASSREF { result = Factory.QREF(val[0][:value]) ; loc result, val[0] } undef : UNDEF { result = Factory.literal(:undef); loc result, val[0] } default : DEFAULT { result = Factory.literal(:default); loc result, val[0] } # Assumes lexer produces a Boolean value for booleans, or this will go wrong and produce a literal string # with the text 'true'. #TODO: could be changed to a specific boolean literal factory method to prevent this possible glitch. boolean : BOOLEAN { result = Factory.literal(val[0][:value]) ; loc result, val[0] } regex : REGEX { result = Factory.literal(val[0][:value]); loc result, val[0] } #---MARKERS, SPECIAL TOKENS, SYNTACTIC SUGAR, etc. endcomma : # | COMMA { result = nil } endsemi : # | SEMIC keyword : AND | CASE | CLASS | DEFAULT | DEFINE | ELSE | ELSIF | IF | IN | INHERITS | NODE | OR | UNDEF | UNLESS nil : { result = nil} end ---- header ---- require 'puppet' require 'puppet/pops' module Puppet class ParseError < Puppet::Error; end class ImportError < Racc::ParseError; end class AlreadyImportedError < ImportError; end end ---- inner ---- # Make emacs happy # Local Variables: # mode: ruby # End: diff --git a/lib/puppet/pops/parser/eparser.rb b/lib/puppet/pops/parser/eparser.rb index 2d524b95a..022136a09 100644 --- a/lib/puppet/pops/parser/eparser.rb +++ b/lib/puppet/pops/parser/eparser.rb @@ -1,2610 +1,2630 @@ # # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.9 # from Racc grammer file "". # require 'racc/parser.rb' require 'puppet' require 'puppet/pops' module Puppet class ParseError < Puppet::Error; end class ImportError < Racc::ParseError; end class AlreadyImportedError < ImportError; end end module Puppet module Pops module Parser class Parser < Racc::Parser -module_eval(<<'...end egrammar.ra/module_eval...', 'egrammar.ra', 761) +module_eval(<<'...end egrammar.ra/module_eval...', 'egrammar.ra', 763) # Make emacs happy # Local Variables: # mode: ruby # End: ...end egrammar.ra/module_eval... ##### State transition tables begin ### clist = [ -'59,61,277,-131,53,240,55,-218,267,-133,-227,362,315,226,247,267,59,61', -'237,246,226,226,300,14,355,59,61,245,233,42,242,49,244,52,46,128,50', -'71,67,127,44,70,47,48,278,-131,68,13,260,-218,69,-133,-227,12,137,223', -'128,135,59,61,127,72,53,137,55,397,135,43,266,262,263,66,62,267,64,65', -'63,72,124,51,128,14,249,54,127,250,72,42,62,49,330,52,46,318,50,71,67', -'62,44,70,47,48,237,128,68,13,128,127,69,128,127,12,333,127,128,274,59', -'61,127,72,53,365,55,335,81,43,350,222,349,66,62,337,64,65,350,76,349', -'51,104,14,108,54,103,59,61,42,299,49,298,52,46,276,50,71,67,74,44,70', -'47,48,252,251,68,13,107,116,69,342,343,12,77,79,78,80,59,61,344,72,53', -'226,55,395,81,43,213,347,82,66,62,243,64,65,351,353,292,51,104,14,108', -'54,103,189,274,42,276,49,274,52,46,361,50,71,67,298,44,70,47,48,291', -'298,68,13,107,76,69,156,153,12,151,372,314,290,59,61,374,72,53,276,55', -'393,81,43,276,129,82,66,62,274,64,65,377,116,117,51,104,14,108,54,103', -'317,116,42,381,49,353,52,46,383,50,71,67,384,44,70,47,48,385,386,68', -'13,107,387,69,113,389,12,390,391,321,76,59,61,73,72,53,398,55,399,81', -'43,400,401,,66,62,,64,65,,,,51,104,14,108,54,103,,,42,,49,,52,110,,50', -'71,67,,44,70,,,,,68,13,107,,69,,,12,,,,,59,61,,72,53,,55,,81,43,,,,66', -'62,,64,65,,,,51,104,14,108,54,103,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,107,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,', -'51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,', -',,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52', -'110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,', -',,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44,70,47,48', -',,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14', -',54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61', -',72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50', -'71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62', -',64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,', -'69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51', -',14,,54,,,,42,,49,,52,123,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59', -'61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,', -'50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66', -'62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13', -',,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,', -',42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,296,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67', -',44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,140,55,,,43,,,,66,62', -',64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,', -'69,,,12,,,,,59,61,,72,53,142,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,', -',,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72', -'53,,55,145,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71', -'67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64', -'65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,', -',12,,,,,59,61,,72,53,,55,302,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,145,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67', -',44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,155,,,43,,,,66,62,', -'64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69', -',,12,,,,,59,61,,72,53,,55,371,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44', -'70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65', -',,,51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44,70,47,48,,,68,13,,,69,', -',12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49', -',52,46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44,70', -'47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,', -',51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12', -',,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52', -'46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43', -',,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67,,44,70,47,48', -',,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14', -',54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61', -',72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50', -'71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62', -',64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,', -'69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51', -',14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59', -'61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,', -'50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66', -'62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13', -',,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,', -',42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,', -'44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65', -',,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12', -',,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52', -'110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,', -',,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,', -'68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14', -',54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61', -',72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50', -'71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62', -',64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,', -'69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51', -',14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59', -'61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,', -'50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66', -'62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13', -',,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,', -',42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,', -'44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,356,,43,,,188,66,62,', -'64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69', -',,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,191', -'208,202,209,52,203,211,204,200,198,,193,206,,,,,68,13,212,207,205,,', -'12,,,,,59,61,,72,53,,55,,210,192,,,,66,62,,64,65,,,,51,,14,,54,,,,42', -',49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51', -',14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59', -'61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,', -'50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66', -'62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13', -',,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,', -',42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53', -',55,304,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,46,,50,71,67', -',44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64', -'65,,,,51,,14,220,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69', -',,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,', -'49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55', -',,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51', -',14,228,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,', -',,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52', -'46,,50,71,67,,44,70,47,48,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43', -',,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,', -',68,13,,,69,,,12,,,,,59,61,,72,53,324,55,,,43,,,,66,62,,64,65,,,,51', -',14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59', -'61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,', -'50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66', -'62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13', -',,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,', -',42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53', -'323,55,,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67', -',44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65', -',,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12', -',,,,59,61,,72,53,,55,326,,43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49', -',52,110,,50,71,67,,44,70,,,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,', -'43,,,,66,62,,64,65,,,,51,,14,,54,,,,42,,49,,52,110,,50,71,67,,44,70', -',,,,68,13,,,69,,,12,,,,,59,61,,72,53,,55,,,43,,,,66,62,,64,65,,59,61', -'51,,14,,54,,,,191,208,202,209,52,203,211,204,200,198,,193,206,,59,61', -',68,13,212,207,205,,,12,,,,137,,,135,72,,,,,210,192,,,,66,62,,64,65', -'81,,,51,72,137,,54,135,100,101,102,97,92,104,62,108,,103,,,93,95,94', -'96,,,,72,,,,,,,,,,,62,107,,,,99,98,,,85,86,88,87,90,91,,83,84,,,,,81', -'82,105,,,248,,,,100,101,102,97,92,104,,108,,103,89,,93,95,94,96,,,,', -',,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,248,,,82,100', -'101,102,97,92,104,,108,,103,,,93,95,94,96,,89,,,,,,,,,,,,,,107,,,,99', -'98,,,85,86,88,87,90,91,,83,84,,,,,81,82,232,,,,,,,100,101,102,97,92', -'104,,108,,103,89,,93,95,94,96,,,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88', -'87,90,91,81,83,84,,,,,,82,100,101,102,97,92,104,,108,,103,,,93,95,94', -'96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,,83,84,,,,,81,82', -'231,,,,,,,100,101,102,97,92,104,,108,,103,89,,93,95,94,96,,,,,,,,,,', -',,,,,107,,,,99,98,,,85,86,88,87,90,91,,83,84,,,,,81,82,230,,,,,,,100', -'101,102,97,92,104,,108,,103,89,,93,95,94,96,,,,,,,,,,,,,,,,107,,,,99', -'98,,,85,86,88,87,90,91,,83,84,,,,,81,82,229,,,,,,,100,101,102,97,92', -'104,,108,,103,89,,93,95,94,96,,,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88', -'87,90,91,81,83,84,,,,,,82,100,101,102,97,92,104,,108,,103,,218,93,95', -'94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,', -',,82,100,101,102,97,92,104,,108,,103,,,93,95,94,96,,89,,,,,,,,,,,,,', -'107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,,,,82,100,101,102,97,92', -'104,,108,,103,262,263,93,95,94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85', -'86,88,87,90,91,81,83,84,,,,,,82,100,101,102,97,92,104,,108,,103,,,93', -'95,94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84', -',,,,,82,100,101,102,97,92,104,,108,,103,,,93,95,94,96,,89,,,,,,,,,,', -',,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,,,,82,100,101,102,97', -'92,104,,108,,103,,,93,95,94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86', -'88,87,90,91,81,83,84,,,,,,82,100,101,102,97,92,104,,108,,103,,,93,95', -'94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,', -',,82,100,101,102,97,92,104,,108,81,103,,81,93,95,94,96,,89,,,,,104,', -'108,104,103,108,,103,,107,,,,99,98,,,85,86,88,87,90,91,,83,84,107,,', -'107,,82,,,,,88,87,81,88,87,83,84,,83,84,,,82,89,,82,104,,108,,103,,', -',,81,,,,,89,,,89,100,101,102,97,92,104,,108,107,103,,,93,95,94,96,85', -'86,88,87,,,,83,84,,,,,,82,107,,,,99,98,,,85,86,88,87,90,91,81,83,84', -'89,,,,,82,100,101,102,97,92,104,272,108,,103,,,93,95,94,96,,89,,,,,', -',,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,,83,84,,,,,81,82,105,,,,,,', -'100,101,102,97,92,104,,108,81,103,89,,93,95,94,96,,,,,,,104,,108,,103', -',,,,107,,,,99,98,,,85,86,88,87,90,91,,83,84,107,,,81,,82,,,85,86,88', -'87,,,,83,84,104,,108,81,103,82,89,,,,,,,,,,,104,,108,,103,,89,,,107', -',,,,,,,85,86,88,87,90,91,,83,84,107,,,,,82,,,85,86,88,87,90,91,81,83', -'84,,,,,,82,89,,,,92,104,,108,81,103,,,93,,,,,89,,,,92,104,,108,,103', -',,93,,107,,,,,,,,85,86,88,87,90,91,,83,84,107,,,,,82,,,85,86,88,87,90', -'91,81,83,84,,,,,,82,89,,,,92,104,,108,81,103,,,93,,,,,89,,,,92,104,', -'108,,103,,,93,,107,,,,,,,,85,86,88,87,90,91,,83,84,107,,,,,82,,,85,86', -'88,87,90,91,81,83,84,,,,,,82,89,,,97,92,104,,108,,103,,81,93,95,94,96', -',89,,,,,,97,92,104,,108,,103,,107,93,95,94,96,,,,85,86,88,87,90,91,', -'83,84,,,,107,,82,,,98,,,85,86,88,87,90,91,81,83,84,,,,89,,82,100,101', -'102,97,92,104,,108,,103,,,93,95,94,96,,89,,,,,,,,,,,,,,107,,,,99,98', -',,85,86,88,87,90,91,81,83,84,,,268,,,82,100,101,102,97,92,104,,108,', -'103,,,93,95,94,96,,89,,,,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91', -'81,83,84,,,,,,82,100,101,102,97,92,104,,108,,103,,,93,95,94,96,,89,', -',,,,,,,,,,,,107,,,,99,98,,,85,86,88,87,90,91,81,83,84,,,,,,82,100,101', -'102,97,92,104,,108,81,103,,81,93,95,94,96,,89,,,,,104,,108,104,103,108', -',103,,107,,,,99,98,,81,85,86,88,87,90,91,,83,84,107,,,107,104,82,108', -',103,,,,,,,83,84,,83,84,,,82,89,,82,,,,,107,,,,,,,,,,,,,,,83,84,,286', -'208,285,209,82,283,211,287,281,280,,282,284,,,,,,,212,207,288,286,208', -'285,209,,283,211,287,281,280,,282,284,,,210,289,,,212,207,288,286,208', -'285,209,,283,211,287,281,280,,282,284,,,210,289,,,212,207,288,,,,,,', -',,,,,,,,,210,289' ] - racc_action_table = arr = ::Array.new(6523, nil) +'60,62,-134,279,54,242,56,-219,269,-132,-228,268,317,228,249,269,269', +'254,253,248,228,228,302,15,357,60,62,247,235,43,244,50,246,53,47,130', +'51,72,68,129,45,71,48,49,-134,280,69,14,262,-219,70,-132,-228,12,13', +'225,130,119,60,62,129,73,54,139,56,399,137,44,352,316,351,67,63,130', +'65,66,64,129,126,52,367,15,251,55,130,252,73,43,129,50,332,53,47,292', +'51,72,68,63,45,71,48,49,278,130,69,14,130,129,70,130,129,12,13,129,60', +'62,60,62,335,73,54,352,56,351,82,44,264,265,276,67,63,337,65,66,77,339', +'293,52,105,15,109,55,104,294,118,43,278,50,245,53,47,344,51,72,68,75', +'45,71,48,49,345,346,69,14,108,228,70,239,349,12,13,300,353,355,60,62', +'239,73,54,224,56,397,82,44,276,278,83,67,63,276,65,66,363,364,323,52', +'105,15,109,55,104,300,215,43,191,50,77,53,47,158,51,72,68,374,45,71', +'48,49,301,155,69,14,108,376,70,153,278,12,13,276,131,379,60,62,118,73', +'54,300,56,395,82,44,320,118,83,67,63,383,65,66,355,385,386,52,105,15', +'109,55,104,387,388,43,389,50,115,53,47,391,51,72,68,392,45,71,48,49', +'393,319,69,14,108,77,70,74,400,12,13,401,402,403,60,62,,73,54,,56,,82', +'44,,,,67,63,,65,66,,,,52,105,15,109,55,104,,,43,,50,,53,111,,51,72,68', +',45,71,78,80,79,81,69,14,108,,70,,,12,13,,,,60,62,,73,54,,56,,82,44', +',,,67,63,,65,66,,,,52,105,15,109,55,104,,,43,,50,,53,111,,51,72,68,', +'45,71,,,,,69,14,108,,70,,,12,13,,,,60,62,,73,54,,56,,82,44,,,,67,63', +',65,66,,,,52,105,15,109,55,104,,,43,,50,,53,111,,51,72,68,,45,71,,,', +',69,14,108,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52', +',15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,', +',60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111', +',51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,', +'67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,', +',69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,', +'15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,', +'60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111', +',51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,', +'67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69', +'14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,', +'55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62', +',73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51', +'72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63', +',65,66,,,,52,,15,,55,,,,43,,50,,53,125,,51,72,68,,45,71,,,,,69,14,,', +'70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,', +',43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73', +'54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68', +',45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65', +'66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,', +',12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,193', +'210,204,211,53,205,213,206,202,200,,195,208,,,,,69,14,214,209,207,,', +'12,13,,,,60,62,,73,54,142,56,,212,194,,,,67,63,,65,66,,,,52,,15,,55', +',,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,', +'73,54,144,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51', +'72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,147,,44,,,,67', +'63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14', +',,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55', +',,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,', +'73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72', +'68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,', +'65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70', +',,12,13,,,,60,62,,73,54,,157,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43', +',50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54', +',56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,', +'45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66', +',,,52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,', +',12,13,,,,60,62,,73,54,,56,147,,44,,,,67,63,,65,66,,,,52,,15,,55,,,', +'43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62,', +'73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72', +'68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67', +'63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69', +'14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,', +'55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60', +'62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51', +'72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,', +'67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,', +',69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,', +'15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,', +'60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111', +',51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,', +'67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69', +'14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,', +'55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62', +',73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51', +'72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63', +',65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,', +'70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,', +',43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73', +'54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68', +',45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65', +'66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,', +',12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43', +',50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54', +',56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,', +'45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66', +',,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12', +'13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50', +',53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56', +',,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71', +',,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52', +',15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,', +',60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111', +',51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,', +'67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69', +'14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,', +'55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62', +',73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51', +'72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63', +',65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,', +'70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,', +',43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73', +'54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68', +',45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65', +'66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,', +',12,13,,,,60,62,,73,54,,56,373,,44,,,190,67,63,,65,66,,,,52,,15,,55', +',,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62', +',73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,193,210,204,211,53', +'205,213,206,202,200,,195,208,,,,,69,14,214,209,207,,,12,13,,,,60,62', +',73,54,,56,,212,194,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,', +'51,72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44', +',,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,', +',69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,', +'15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,', +'60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111', +',51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,306,,44', +',,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49', +',,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,304,,44,,,,67,63,,65,66,,,', +'52,,15,,55,,,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,,,12', +'13,,,,60,62,,73,54,325,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,', +'50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,', +'56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45', +'71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,', +',,52,,15,222,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,', +'12,13,,,,60,62,,73,54,,56,358,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43', +',50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54', +',56,298,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,47,,51,72,68', +',45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63', +',65,66,,,,52,,15,230,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14', +',,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55', +',,,43,,50,,53,47,,51,72,68,,45,71,48,49,,,69,14,,,70,,,12,13,,,,60,62', +',73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51', +'72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63', +',65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,', +'70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,', +',43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73', +'54,326,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72', +'68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,', +'65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70', +',,12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43', +',50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54', +',56,,,44,,,,67,63,,65,66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,', +'45,71,,,,,69,14,,,70,,,12,13,,,,60,62,,73,54,,56,328,,44,,,,67,63,,65', +'66,,,,52,,15,,55,,,,43,,50,,53,111,,51,72,68,,45,71,,,,,69,14,,,70,', +',12,13,,,,60,62,,73,54,,56,,,44,,,,67,63,,65,66,,60,62,52,,15,,55,,', +',43,,50,,53,111,,51,72,68,,45,71,,60,62,,69,14,,,70,,,12,13,,,139,,', +'137,73,,,,,,44,,60,62,67,63,,65,66,82,,,52,73,139,,55,137,101,102,103', +'98,93,105,63,109,,104,,,94,96,95,97,,,,73,,,139,,,137,,,,,63,108,,,', +'100,99,,,86,87,89,88,91,92,73,84,85,,,,,82,83,234,,63,,,,,101,102,103', +'98,93,105,,109,,104,,90,94,96,95,97,,,,,,,,,,,,,,,,108,,,,100,99,,,86', +'87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,,104,,,94', +'96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,82,84,85', +',,250,,,83,101,102,103,98,93,105,,109,,104,,,94,96,95,97,,,90,,,,,,', +',,,,,,108,,,,100,99,,,86,87,89,88,91,92,,84,85,,,,,82,83,233,,,,,,,101', +'102,103,98,93,105,,109,,104,,90,94,96,95,97,,,,,,,,,,,,,,,,108,,,,100', +'99,,,86,87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,', +'104,,,94,96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92', +',84,85,,,,,82,83,232,,,,,,,101,102,103,98,93,105,,109,,104,,90,94,96', +'95,97,,,,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,,84,85,,,,,82', +'83,106,,,250,,,,101,102,103,98,93,105,,109,,104,,90,94,96,95,97,,,,', +',,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,,84,85,,,,,82,83,231,,', +',,,,101,102,103,98,93,105,,109,,104,,90,94,96,95,97,,,,,,,,,,,,,,,,108', +',,,100,99,,,86,87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105', +',109,,104,,220,94,96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89', +'88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,,104,,,94,96,95', +'97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,82,84,85,,,,,', +'83,101,102,103,98,93,105,,109,,104,264,265,94,96,95,97,,,90,,,,,,,,', +',,,,108,,,,100,99,,,86,87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98', +'93,105,,109,,104,,,94,96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87', +'89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,,104,,,94,96', +'95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,82,84,85,,', +',,,83,101,102,103,98,93,105,,109,,104,,,94,96,95,97,,,90,,,,,,,,,,,', +',108,,,,100,99,,,86,87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93', +'105,,109,,104,,,94,96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87,89', +'88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,82,104,,82,94,96', +'95,97,,,90,,,,105,,109,105,104,109,,104,,108,,,,100,99,,,86,87,89,88', +'91,92,,84,85,108,,,108,,83,,,,,89,88,,89,88,84,85,,84,85,,,83,,90,83', +',,,,,,,,,,82,,,,,90,,,90,101,102,103,98,93,105,274,109,,104,,,94,96', +'95,97,,,,,,,,,,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,,84,85,,,,,82', +'83,106,,,,,,,101,102,103,98,93,105,,109,,104,,90,94,96,95,97,,,,,,,', +',,,,,,,,108,,,,100,99,,,86,87,89,88,91,92,82,84,85,,,270,,,83,101,102', +'103,98,93,105,,109,82,104,,,94,96,95,97,,,90,,,,105,,109,,104,,,,,108', +',,,100,99,,,86,87,89,88,91,92,,84,85,108,,,82,,83,,,86,87,89,88,,,,84', +'85,105,,109,82,104,83,,90,,,,,,,,,,105,,109,,104,,,90,,108,,,,,,,,86', +'87,89,88,,,,84,85,108,,,82,,83,,,86,87,89,88,91,92,,84,85,105,,109,', +'104,83,,90,,82,,,,,,,,,,,,,93,105,90,109,108,104,,,94,,,,86,87,89,88', +'91,92,,84,85,,,,,,83,108,,,,,,,82,86,87,89,88,91,92,,84,85,,90,,93,105', +'83,109,82,104,,,94,,,,,,,,,93,105,,109,90,104,,,94,,108,,,,,,,,86,87', +'89,88,91,92,,84,85,108,,,,,83,,,86,87,89,88,91,92,,84,85,,,,,82,83,', +'90,,,,,,101,102,103,98,93,105,,109,82,104,,90,94,96,95,97,,,,,,,105', +',109,,104,,,,,108,,,,100,99,,82,86,87,89,88,91,92,,84,85,108,,98,93', +'105,83,109,,104,,,94,96,95,97,84,85,,,,,,83,,90,,,,,,108,,,,,82,,,86', +'87,89,88,91,92,,84,85,98,93,105,,109,83,104,,,94,96,95,97,,,,,,,,,,', +',90,,,,108,,,,,99,,,86,87,89,88,91,92,82,84,85,,,,,,83,101,102,103,98', +'93,105,,109,,104,,,94,96,95,97,,,90,,,,,,,,,,,,,108,,,,100,99,,,86,87', +'89,88,91,92,82,84,85,,,,,,83,101,102,103,98,93,105,,109,82,104,,,94', +'96,95,97,,,90,,,93,105,,109,,104,,,94,,108,,,,100,99,,,86,87,89,88,91', +'92,,84,85,108,,,82,,83,,,86,87,89,88,91,92,82,84,85,105,,109,,104,83', +',90,,,,105,,109,,104,,,,,,,,,90,,108,,,,,,,,,,,108,,,,84,85,,,,,,83', +',,,84,85,,288,210,287,211,83,285,213,289,283,282,,284,286,,,,,,,214', +'209,290,288,210,287,211,,285,213,289,283,282,,284,286,,,212,291,,,214', +'209,290,288,210,287,211,,285,213,289,283,282,,284,286,,,212,291,,,214', +'209,290,,,,,,,,,,,,,,,,212,291' ] + racc_action_table = arr = ::Array.new(6619, nil) idx = 0 clist.each do |str| str.split(',', -1).each do |i| arr[idx] = i.to_i unless i.empty? idx += 1 end end clist = [ -'0,0,201,198,0,131,0,206,227,200,205,312,237,153,141,305,242,242,125', -'141,116,237,227,0,305,240,240,139,123,0,131,0,139,0,0,203,0,0,0,203', -'0,0,0,0,201,198,0,0,153,206,0,200,205,0,242,116,123,242,384,384,123', -'0,384,240,384,384,240,0,163,330,330,0,0,163,0,0,0,242,46,0,49,384,144', -'0,49,144,240,384,242,384,265,384,384,239,384,384,384,240,384,384,384', -'384,130,202,384,384,46,202,384,110,46,384,269,110,314,234,5,5,314,384', -'5,314,5,273,165,384,347,115,347,384,384,275,384,384,302,157,302,384', -'165,5,165,384,165,151,151,5,226,5,224,5,5,279,5,5,5,5,5,5,5,5,149,149', -'5,5,165,220,5,293,295,5,8,8,8,8,383,383,297,5,383,298,383,383,166,5', -'106,301,165,5,5,133,5,5,303,304,219,5,166,383,166,5,166,104,308,383', -'309,383,310,383,383,311,383,383,383,259,383,383,383,383,217,316,383', -'383,166,75,383,73,63,383,62,329,235,215,381,381,332,383,381,195,381', -'381,164,383,334,47,166,383,383,194,383,383,341,342,41,383,164,381,164', -'383,164,238,40,381,350,381,351,381,381,353,381,381,381,354,381,381,381', -'381,358,359,381,381,164,360,381,39,366,381,367,370,243,6,188,188,1,381', -'188,388,188,392,111,381,394,396,,381,381,,381,381,,,,381,111,188,111', -'381,111,,,188,,188,,188,188,,188,188,188,,188,188,,,,,188,188,111,,188', -',,188,,,,,12,12,,188,12,,12,,109,188,,,,188,188,,188,188,,,,188,109', -'12,109,188,109,,,12,,12,,12,12,,12,12,12,,12,12,,,,,12,12,109,,12,,', -'12,,,,,13,13,,12,13,,13,,,12,,,,12,12,,12,12,,,,12,,13,,12,,,,13,,13', -',13,13,,13,13,13,,13,13,,,,,13,13,,,13,,,13,,,,,14,14,,13,14,,14,,,13', -',,,13,13,,13,13,,,,13,,14,,13,,,,14,,14,,14,14,,14,14,14,,14,14,,,,', -'14,14,,,14,,,14,,,,,362,362,,14,362,,362,,,14,,,,14,14,,14,14,,,,14', -',362,,14,,,,362,,362,,362,362,,362,362,362,,362,362,362,362,,,362,362', -',,362,,,362,,,,,349,349,,362,349,,349,,,362,,,,362,362,,362,362,,,,362', -',349,,362,,,,349,,349,,349,349,,349,349,349,,349,349,,,,,349,349,,,349', -',,349,,,,,191,191,,349,191,,191,,,349,,,,349,349,,349,349,,,,349,,191', -',349,,,,191,,191,,191,191,,191,191,191,,191,191,,,,,191,191,,,191,,', -'191,,,,,42,42,,191,42,,42,,,191,,,,191,191,,191,191,,,,191,,42,,191', -',,,42,,42,,42,42,,42,42,42,,42,42,,,,,42,42,,,42,,,42,,,,,43,43,,42', -'43,,43,,,42,,,,42,42,,42,42,,,,42,,43,,42,,,,43,,43,,43,43,,43,43,43', -',43,43,,,,,43,43,,,43,,,43,,,,,44,44,,43,44,,44,,,43,,,,43,43,,43,43', -',,,43,,44,,43,,,,44,,44,,44,44,,44,44,44,,44,44,,,,,44,44,,,44,,,44', -',,,,45,45,,44,45,,45,,,44,,,,44,44,,44,44,,,,44,,45,,44,,,,45,,45,,45', -'45,,45,45,45,,45,45,,,,,45,45,,,45,,,45,,,,,192,192,,45,192,,192,,,45', -',,,45,45,,45,45,,,,45,,192,,45,,,,192,,192,,192,192,,192,192,192,,192', -'192,,,,,192,192,,,192,,,192,,,,,193,193,,192,193,,193,,,192,,,,192,192', -',192,192,,,,192,,193,,192,,,,193,,193,,193,193,,193,193,193,,193,193', -',,,,193,193,,,193,,,193,,,,,333,333,,193,333,,333,,,193,,,,193,193,', -'193,193,,,,193,,333,,193,,,,333,,333,,333,333,,333,333,333,,333,333', -',,,,333,333,,,333,,,333,,,,,222,222,,333,222,,222,222,,333,,,,333,333', -',333,333,,,,333,,222,,333,,,,222,,222,,222,222,,222,222,222,,222,222', -'222,222,,,222,222,,,222,,,222,,,,,53,53,,222,53,53,53,,,222,,,,222,222', -',222,222,,,,222,,53,,222,,,,53,,53,,53,53,,53,53,53,,53,53,,,,,53,53', -',,53,,,53,,,,,54,54,,53,54,54,54,,,53,,,,53,53,,53,53,,,,53,,54,,53', -',,,54,,54,,54,54,,54,54,54,,54,54,,,,,54,54,,,54,,,54,,,,,55,55,,54', -'55,,55,55,,54,,,,54,54,,54,54,,,,54,,55,,54,,,,55,,55,,55,55,,55,55', -'55,,55,55,,,,,55,55,,,55,,,55,,,,,60,60,,55,60,,60,,,55,,,,55,55,,55', -'55,,,,55,,60,,55,,,,60,,60,,60,60,,60,60,60,,60,60,,,,,60,60,,,60,,', -'60,,,,,229,229,,60,229,,229,229,,60,,,,60,60,,60,60,,,,60,,229,,60,', -',,229,,229,,229,229,,229,229,229,,229,229,229,229,,,229,229,,,229,,', -'229,,,,,155,155,,229,155,,155,155,,229,,,,229,229,,229,229,,,,229,,155', -',229,,,,155,,155,,155,155,,155,155,155,,155,155,155,155,,,155,155,,', -'155,,,155,,,,,65,65,,155,65,,65,,,155,,,,155,155,,155,155,,,,155,,65', -',155,,,,65,,65,,65,65,,65,65,65,,65,65,,,,,65,65,,,65,,,65,,,,,318,318', -',65,318,,318,318,,65,,,,65,65,,65,65,,,,65,,318,,65,,,,318,,318,,318', -'318,,318,318,318,,318,318,318,318,,,318,318,,,318,,,318,,,,,74,74,,318', -'74,,74,,,318,,,,318,318,,318,318,,,,318,,74,,318,,,,74,,74,,74,74,,74', -'74,74,,74,74,74,74,,,74,74,,,74,,,74,,,,,317,317,,74,317,,317,,,74,', -',,74,74,,74,74,,,,74,,317,,74,,,,317,,317,,317,317,,317,317,317,,317', -'317,317,317,,,317,317,,,317,,,317,,,,,76,76,,317,76,,76,,,317,,,,317', -'317,,317,317,,,,317,,76,,317,,,,76,,76,,76,76,,76,76,76,,76,76,76,76', -',,76,76,,,76,,,76,,,,,77,77,,76,77,,77,,,76,,,,76,76,,76,76,,,,76,,77', -',76,,,,77,,77,,77,77,,77,77,77,,77,77,77,77,,,77,77,,,77,,,77,,,,,78', -'78,,77,78,,78,,,77,,,,77,77,,77,77,,,,77,,78,,77,,,,78,,78,,78,78,,78', -'78,78,,78,78,78,78,,,78,78,,,78,,,78,,,,,79,79,,78,79,,79,,,78,,,,78', -'78,,78,78,,,,78,,79,,78,,,,79,,79,,79,79,,79,79,79,,79,79,79,79,,,79', -'79,,,79,,,79,,,,,80,80,,79,80,,80,,,79,,,,79,79,,79,79,,,,79,,80,,79', -',,,80,,80,,80,80,,80,80,80,,80,80,80,80,,,80,80,,,80,,,80,,,,,81,81', +'0,0,202,203,0,133,0,208,229,200,207,165,239,155,143,307,165,151,151', +'143,118,239,229,0,307,242,242,141,125,0,133,0,141,0,0,205,0,0,0,205', +'0,0,0,0,202,203,0,0,155,208,0,200,207,0,0,118,125,42,386,386,125,0,386', +'242,386,386,242,0,304,237,304,0,0,316,0,0,0,316,47,0,316,386,146,0,204', +'146,242,386,204,386,267,386,386,217,386,386,386,242,386,386,386,386', +'197,50,386,386,47,50,386,111,47,386,386,111,153,153,5,5,271,386,5,349', +'5,349,168,386,332,332,196,386,386,275,386,386,159,277,219,386,168,5', +'168,386,168,221,222,5,281,5,135,5,5,295,5,5,5,5,5,5,5,5,297,299,5,5', +'168,300,5,132,303,5,5,226,305,306,385,385,127,5,385,117,385,385,167', +'5,310,311,168,5,5,312,5,5,313,314,245,5,167,385,167,5,167,318,107,385', +'105,385,76,385,385,74,385,385,385,331,385,385,385,385,228,64,385,385', +'167,334,385,63,336,385,385,236,48,343,383,383,344,385,383,261,383,383', +'113,385,241,41,167,385,385,352,385,385,353,355,356,385,113,383,113,385', +'113,360,361,383,362,383,40,383,383,368,383,383,383,369,383,383,383,383', +'372,240,383,383,113,6,383,1,390,383,383,394,396,398,190,190,,383,190', +',190,,166,383,,,,383,383,,383,383,,,,383,166,190,166,383,166,,,190,', +'190,,190,190,,190,190,190,,190,190,8,8,8,8,190,190,166,,190,,,190,190', +',,,12,12,,190,12,,12,,110,190,,,,190,190,,190,190,,,,190,110,12,110', +'190,110,,,12,,12,,12,12,,12,12,12,,12,12,,,,,12,12,110,,12,,,12,12,', +',,13,13,,12,13,,13,,112,12,,,,12,12,,12,12,,,,12,112,13,112,12,112,', +',13,,13,,13,13,,13,13,13,,13,13,,,,,13,13,112,,13,,,13,13,,,,14,14,', +'13,14,,14,,,13,,,,13,13,,13,13,,,,13,,14,,13,,,,14,,14,,14,14,,14,14', +'14,,14,14,,,,,14,14,,,14,,,14,14,,,,15,15,,14,15,,15,,,14,,,,14,14,', +'14,14,,,,14,,15,,14,,,,15,,15,,15,15,,15,15,15,,15,15,,,,,15,15,,,15', +',,15,15,,,,364,364,,15,364,,364,,,15,,,,15,15,,15,15,,,,15,,364,,15', +',,,364,,364,,364,364,,364,364,364,,364,364,364,364,,,364,364,,,364,', +',364,364,,,,351,351,,364,351,,351,,,364,,,,364,364,,364,364,,,,364,', +'351,,364,,,,351,,351,,351,351,,351,351,351,,351,351,,,,,351,351,,,351', +',,351,351,,,,193,193,,351,193,,193,,,351,,,,351,351,,351,351,,,,351', +',193,,351,,,,193,,193,,193,193,,193,193,193,,193,193,,,,,193,193,,,193', +',,193,193,,,,43,43,,193,43,,43,,,193,,,,193,193,,193,193,,,,193,,43', +',193,,,,43,,43,,43,43,,43,43,43,,43,43,,,,,43,43,,,43,,,43,43,,,,44', +'44,,43,44,,44,,,43,,,,43,43,,43,43,,,,43,,44,,43,,,,44,,44,,44,44,,44', +'44,44,,44,44,,,,,44,44,,,44,,,44,44,,,,45,45,,44,45,,45,,,44,,,,44,44', +',44,44,,,,44,,45,,44,,,,45,,45,,45,45,,45,45,45,,45,45,,,,,45,45,,,45', +',,45,45,,,,46,46,,45,46,,46,,,45,,,,45,45,,45,45,,,,45,,46,,45,,,,46', +',46,,46,46,,46,46,46,,46,46,,,,,46,46,,,46,,,46,46,,,,235,235,,46,235', +',235,,,46,,,,46,46,,46,46,,,,46,,235,,46,,,,235,,235,,235,235,,235,235', +'235,,235,235,,,,,235,235,,,235,,,235,235,,,,194,194,,235,194,,194,,', +'235,,,,235,235,,235,235,,,,235,,194,,235,,,,194,,194,,194,194,,194,194', +'194,,194,194,,,,,194,194,,,194,,,194,194,,,,195,195,,194,195,,195,,', +'194,,,,194,194,,194,194,,,,194,,195,,194,,,,195,,195,,195,195,,195,195', +'195,,195,195,,,,,195,195,,,195,,,195,195,,,,234,234,,195,234,,234,,', +'195,,,,195,195,,195,195,,,,195,,234,,195,,,,234,234,234,234,234,234', +'234,234,234,234,,234,234,,,,,234,234,234,234,234,,,234,234,,,,54,54', +',234,54,54,54,,234,234,,,,234,234,,234,234,,,,234,,54,,234,,,,54,,54', +',54,54,,54,54,54,,54,54,,,,,54,54,,,54,,,54,54,,,,55,55,,54,55,55,55', +',,54,,,,54,54,,54,54,,,,54,,55,,54,,,,55,,55,,55,55,,55,55,55,,55,55', +',,,,55,55,,,55,,,55,55,,,,56,56,,55,56,,56,56,,55,,,,55,55,,55,55,,', +',55,,56,,55,,,,56,,56,,56,56,,56,56,56,,56,56,,,,,56,56,,,56,,,56,56', +',,,61,61,,56,61,,61,,,56,,,,56,56,,56,56,,,,56,,61,,56,,,,61,,61,,61', +'61,,61,61,61,,61,61,,,,,61,61,,,61,,,61,61,,,,335,335,,61,335,,335,', +',61,,,,61,61,,61,61,,,,61,,335,,61,,,,335,,335,,335,335,,335,335,335', +',335,335,,,,,335,335,,,335,,,335,335,,,,270,270,,335,270,,270,,,335', +',,,335,335,,335,335,,,,335,,270,,335,,,,270,,270,,270,270,,270,270,270', +',270,270,,,,,270,270,,,270,,,270,270,,,,66,66,,270,66,,66,,,270,,,,270', +'270,,270,270,,,,270,,66,,270,,,,66,,66,,66,66,,66,66,66,,66,66,,,,,66', +'66,,,66,,,66,66,,,,276,276,,66,276,,276,,,66,,,,66,66,,66,66,,,,66,', +'276,,66,,,,276,,276,,276,276,,276,276,276,,276,276,,,,,276,276,,,276', +',,276,276,,,,75,75,,276,75,,75,,,276,,,,276,276,,276,276,,,,276,,75', +',276,,,,75,,75,,75,75,,75,75,75,,75,75,75,75,,,75,75,,,75,,,75,75,,', +',157,157,,75,157,,157,157,,75,,,,75,75,,75,75,,,,75,,157,,75,,,,157', +',157,,157,157,,157,157,157,,157,157,157,157,,,157,157,,,157,,,157,157', +',,,77,77,,157,77,,77,,,157,,,,157,157,,157,157,,,,157,,77,,157,,,,77', +',77,,77,77,,77,77,77,,77,77,77,77,,,77,77,,,77,,,77,77,,,,78,78,,77', +'78,,78,,,77,,,,77,77,,77,77,,,,77,,78,,77,,,,78,,78,,78,78,,78,78,78', +',78,78,78,78,,,78,78,,,78,,,78,78,,,,79,79,,78,79,,79,,,78,,,,78,78', +',78,78,,,,78,,79,,78,,,,79,,79,,79,79,,79,79,79,,79,79,79,79,,,79,79', +',,79,,,79,79,,,,80,80,,79,80,,80,,,79,,,,79,79,,79,79,,,,79,,80,,79', +',,,80,,80,,80,80,,80,80,80,,80,80,80,80,,,80,80,,,80,,,80,80,,,,81,81', ',80,81,,81,,,80,,,,80,80,,80,80,,,,80,,81,,80,,,,81,,81,,81,81,,81,81', -'81,,81,81,,,,,81,81,,,81,,,81,,,,,82,82,,81,82,,82,,,81,,,,81,81,,81', -'81,,,,81,,82,,81,,,,82,,82,,82,82,,82,82,82,,82,82,,,,,82,82,,,82,,', -'82,,,,,83,83,,82,83,,83,,,82,,,,82,82,,82,82,,,,82,,83,,82,,,,83,,83', -',83,83,,83,83,83,,83,83,,,,,83,83,,,83,,,83,,,,,84,84,,83,84,,84,,,83', -',,,83,83,,83,83,,,,83,,84,,83,,,,84,,84,,84,84,,84,84,84,,84,84,,,,', -'84,84,,,84,,,84,,,,,85,85,,84,85,,85,,,84,,,,84,84,,84,84,,,,84,,85', -',84,,,,85,,85,,85,85,,85,85,85,,85,85,,,,,85,85,,,85,,,85,,,,,86,86', -',85,86,,86,,,85,,,,85,85,,85,85,,,,85,,86,,85,,,,86,,86,,86,86,,86,86', -'86,,86,86,,,,,86,86,,,86,,,86,,,,,87,87,,86,87,,87,,,86,,,,86,86,,86', -'86,,,,86,,87,,86,,,,87,,87,,87,87,,87,87,87,,87,87,,,,,87,87,,,87,,', -'87,,,,,88,88,,87,88,,88,,,87,,,,87,87,,87,87,,,,87,,88,,87,,,,88,,88', -',88,88,,88,88,88,,88,88,,,,,88,88,,,88,,,88,,,,,89,89,,88,89,,89,,,88', -',,,88,88,,88,88,,,,88,,89,,88,,,,89,,89,,89,89,,89,89,89,,89,89,,,,', -'89,89,,,89,,,89,,,,,90,90,,89,90,,90,,,89,,,,89,89,,89,89,,,,89,,90', -',89,,,,90,,90,,90,90,,90,90,90,,90,90,,,,,90,90,,,90,,,90,,,,,91,91', -',90,91,,91,,,90,,,,90,90,,90,90,,,,90,,91,,90,,,,91,,91,,91,91,,91,91', -'91,,91,91,,,,,91,91,,,91,,,91,,,,,92,92,,91,92,,92,,,91,,,,91,91,,91', -'91,,,,91,,92,,91,,,,92,,92,,92,92,,92,92,92,,92,92,,,,,92,92,,,92,,', -'92,,,,,93,93,,92,93,,93,,,92,,,,92,92,,92,92,,,,92,,93,,92,,,,93,,93', -',93,93,,93,93,93,,93,93,,,,,93,93,,,93,,,93,,,,,94,94,,93,94,,94,,,93', -',,,93,93,,93,93,,,,93,,94,,93,,,,94,,94,,94,94,,94,94,94,,94,94,,,,', -'94,94,,,94,,,94,,,,,95,95,,94,95,,95,,,94,,,,94,94,,94,94,,,,94,,95', -',94,,,,95,,95,,95,95,,95,95,95,,95,95,,,,,95,95,,,95,,,95,,,,,96,96', -',95,96,,96,,,95,,,,95,95,,95,95,,,,95,,96,,95,,,,96,,96,,96,96,,96,96', -'96,,96,96,,,,,96,96,,,96,,,96,,,,,97,97,,96,97,,97,,,96,,,,96,96,,96', -'96,,,,96,,97,,96,,,,97,,97,,97,97,,97,97,97,,97,97,,,,,97,97,,,97,,', -'97,,,,,98,98,,97,98,,98,,,97,,,,97,97,,97,97,,,,97,,98,,97,,,,98,,98', -',98,98,,98,98,98,,98,98,,,,,98,98,,,98,,,98,,,,,99,99,,98,99,,99,,,98', -',,,98,98,,98,98,,,,98,,99,,98,,,,99,,99,,99,99,,99,99,99,,99,99,,,,', -'99,99,,,99,,,99,,,,,100,100,,99,100,,100,,,99,,,,99,99,,99,99,,,,99', -',100,,99,,,,100,,100,,100,100,,100,100,100,,100,100,,,,,100,100,,,100', -',,100,,,,,101,101,,100,101,,101,,,100,,,,100,100,,100,100,,,,100,,101', -',100,,,,101,,101,,101,101,,101,101,101,,101,101,,,,,101,101,,,101,,', -'101,,,,,102,102,,101,102,,102,,,101,,,,101,101,,101,101,,,,101,,102', -',101,,,,102,,102,,102,102,,102,102,102,,102,102,,,,,102,102,,,102,,', -'102,,,,,103,103,,102,103,,103,,,102,,,,102,102,,102,102,,,,102,,103', -',102,,,,103,,103,,103,103,,103,103,103,,103,103,,,,,103,103,,,103,,', -'103,,,,,306,306,,103,306,,306,306,,103,,,103,103,103,,103,103,,,,103', -',306,,103,,,,306,,306,,306,306,,306,306,306,,306,306,,,,,306,306,,,306', -',,306,,,,,105,105,,306,105,,105,,,306,,,,306,306,,306,306,,,,306,,105', -',306,,,,105,105,105,105,105,105,105,105,105,105,,105,105,,,,,105,105', -'105,105,105,,,105,,,,,299,299,,105,299,,299,,105,105,,,,105,105,,105', -'105,,,,105,,299,,105,,,,299,,299,,299,299,,299,299,299,,299,299,,,,', -'299,299,,,299,,,299,,,,,107,107,,299,107,,107,,,299,,,,299,299,,299', -'299,,,,299,,107,,299,,,,107,,107,,107,107,,107,107,107,,107,107,,,,', -'107,107,,,107,,,107,,,,,108,108,,107,108,,108,,,107,,,,107,107,,107', -'107,,,,107,,108,,107,,,,108,,108,,108,108,,108,108,108,,108,108,,,,', -'108,108,,,108,,,108,,,,,292,292,,108,292,,292,,,108,,,,108,108,,108', -'108,,,,108,,292,,108,,,,292,,292,,292,292,,292,292,292,,292,292,,,,', -'292,292,,,292,,,292,,,,,278,278,,292,278,,278,,,292,,,,292,292,,292', -'292,,,,292,,278,,292,,,,278,,278,,278,278,,278,278,278,,278,278,,,,', -'278,278,,,278,,,278,,,,,277,277,,278,277,,277,,,278,,,,278,278,,278', -'278,,,,278,,277,,278,,,,277,,277,,277,277,,277,277,277,,277,277,,,,', -'277,277,,,277,,,277,,,,,230,230,,277,230,,230,230,,277,,,,277,277,,277', -'277,,,,277,,230,,277,,,,230,,230,,230,230,,230,230,230,,230,230,230', -'230,,,230,230,,,230,,,230,,,,,113,113,,230,113,,113,,,230,,,,230,230', -',230,230,,,,230,,113,113,230,,,,113,,113,,113,113,,113,113,113,,113', -'113,,,,,113,113,,,113,,,113,,,,,274,274,,113,274,,274,,,113,,,,113,113', -',113,113,,,,113,,274,,113,,,,274,,274,,274,274,,274,274,274,,274,274', -',,,,274,274,,,274,,,274,,,,,268,268,,274,268,,268,,,274,,,,274,274,', -'274,274,,,,274,,268,,274,,,,268,,268,,268,268,,268,268,268,,268,268', -',,,,268,268,,,268,,,268,,,,,117,117,,268,117,,117,,,268,,,,268,268,', -'268,268,,,,268,,117,117,268,,,,117,,117,,117,117,,117,117,117,,117,117', -',,,,117,117,,,117,,,117,,,,,152,152,,117,152,,152,,,117,,,,117,117,', -'117,117,,,,117,,152,,117,,,,152,,152,,152,152,,152,152,152,,152,152', -'152,152,,,152,152,,,152,,,152,,,,,231,231,,152,231,,231,,,152,,,,152', -'152,,152,152,,,,152,,231,,152,,,,231,,231,,231,231,,231,231,231,,231', -'231,,,,,231,231,,,231,,,231,,,,,246,246,,231,246,246,246,,,231,,,,231', -'231,,231,231,,,,231,,246,,231,,,,246,,246,,246,246,,246,246,246,,246', -'246,,,,,246,246,,,246,,,246,,,,,233,233,,246,233,,233,,,246,,,,246,246', -',246,246,,,,246,,233,,246,,,,233,,233,,233,233,,233,233,233,,233,233', -',,,,233,233,,,233,,,233,,,,,267,267,,233,267,,267,,,233,,,,233,233,', -'233,233,,,,233,,267,,233,,,,267,,267,,267,267,,267,267,267,,267,267', -',,,,267,267,,,267,,,267,,,,,124,124,,267,124,,124,,,267,,,,267,267,', -'267,267,,,,267,,124,,267,,,,124,,124,,124,124,,124,124,124,,124,124', -',,,,124,124,,,124,,,124,,,,,244,244,,124,244,244,244,,,124,,,,124,124', -',124,124,,,,124,,244,,124,,,,244,,244,,244,244,,244,244,244,,244,244', -',,,,244,244,,,244,,,244,,,,,255,255,,244,255,,255,,,244,,,,244,244,', -'244,244,,,,244,,255,,244,,,,255,,255,,255,255,,255,255,255,,255,255', -',,,,255,255,,,255,,,255,,,,,250,250,,255,250,,250,250,,255,,,,255,255', -',255,255,,,,255,,250,,255,,,,250,,250,,250,250,,250,250,250,,250,250', -',,,,250,250,,,250,,,250,,,,,248,248,,250,248,,248,,,250,,,,250,250,', -'250,250,,,,250,,248,,250,,,,248,,248,,248,248,,248,248,248,,248,248', -',,,,248,248,,,248,,,248,,,,,232,232,,248,232,,232,,,248,,,,248,248,', -'248,248,,204,204,248,,232,,248,,,,232,232,232,232,232,232,232,232,232', -'232,,232,232,,50,50,,232,232,232,232,232,,,232,,,,204,,,204,232,,,,', -'232,232,,,,232,232,,232,232,138,,,232,204,50,,232,50,138,138,138,138', -'138,138,204,138,,138,,,138,138,138,138,,,,50,,,,,,,,,,,50,138,,,,138', -'138,,,138,138,138,138,138,138,,138,138,,,,,264,138,264,,,264,,,,264', -'264,264,264,264,264,,264,,264,138,,264,264,264,264,,,,,,,,,,,,,,,,264', -',,,264,264,,,264,264,264,264,264,264,143,264,264,,,143,,,264,143,143', -'143,143,143,143,,143,,143,,,143,143,143,143,,264,,,,,,,,,,,,,,143,,', -',143,143,,,143,143,143,143,143,143,,143,143,,,,,122,143,122,,,,,,,122', -'122,122,122,122,122,,122,,122,143,,122,122,122,122,,,,,,,,,,,,,,,,122', -',,,122,122,,,122,122,122,122,122,122,147,122,122,,,,,,122,147,147,147', -'147,147,147,,147,,147,,,147,147,147,147,,122,,,,,,,,,,,,,,147,,,,147', -'147,,,147,147,147,147,147,147,,147,147,,,,,121,147,121,,,,,,,121,121', -'121,121,121,121,,121,,121,147,,121,121,121,121,,,,,,,,,,,,,,,,121,,', -',121,121,,,121,121,121,121,121,121,,121,121,,,,,120,121,120,,,,,,,120', -'120,120,120,120,120,,120,,120,121,,120,120,120,120,,,,,,,,,,,,,,,,120', -',,,120,120,,,120,120,120,120,120,120,,120,120,,,,,118,120,118,,,,,,', -'118,118,118,118,118,118,,118,,118,120,,118,118,118,118,,,,,,,,,,,,,', -',,118,,,,118,118,,,118,118,118,118,118,118,112,118,118,,,,,,118,112', -'112,112,112,112,112,,112,,112,,112,112,112,112,112,,118,,,,,,,,,,,,', -',112,,,,112,112,,,112,112,112,112,112,112,154,112,112,,,,,,112,154,154', -'154,154,154,154,,154,,154,,,154,154,154,154,,112,,,,,,,,,,,,,,154,,', -',154,154,,,154,154,154,154,154,154,322,154,154,,,,,,154,322,322,322', -'322,322,322,,322,,322,154,154,322,322,322,322,,154,,,,,,,,,,,,,,322', -',,,322,322,,,322,322,322,322,322,322,325,322,322,,,,,,322,325,325,325', -'325,325,325,,325,,325,,,325,325,325,325,,322,,,,,,,,,,,,,,325,,,,325', -'325,,,325,325,325,325,325,325,331,325,325,,,,,,325,331,331,331,331,331', -'331,,331,,331,,,331,331,331,331,,325,,,,,,,,,,,,,,331,,,,331,331,,,331', -'331,331,331,331,331,214,331,331,,,,,,331,214,214,214,214,214,214,,214', -',214,,,214,214,214,214,,331,,,,,,,,,,,,,,214,,,,214,214,,,214,214,214', -'214,214,214,339,214,214,,,,,,214,339,339,339,339,339,339,,339,,339,', -',339,339,339,339,,214,,,,,,,,,,,,,,339,,,,339,339,,,339,339,339,339', -'339,339,340,339,339,,,,,,339,340,340,340,340,340,340,,340,167,340,,168', -'340,340,340,340,,339,,,,,167,,167,168,167,168,,168,,340,,,,340,340,', -',340,340,340,340,340,340,,340,340,167,,,168,,340,,,,,167,167,172,168', -'168,167,167,,168,168,,,167,340,,168,172,,172,,172,,,,,346,,,,,167,,', -'168,346,346,346,346,346,346,,346,172,346,,,346,346,346,346,172,172,172', -'172,,,,172,172,,,,,,172,346,,,,346,346,,,346,346,346,346,346,346,190', -'346,346,172,,,,,346,190,190,190,190,190,190,190,190,,190,,,190,190,190', -'190,,346,,,,,,,,,,,,,,190,,,,190,190,,,190,190,190,190,190,190,,190', -'190,,,,,11,190,11,,,,,,,11,11,11,11,11,11,,11,173,11,190,,11,11,11,11', -',,,,,,173,,173,,173,,,,,11,,,,11,11,,,11,11,11,11,11,11,,11,11,173,', -',174,,11,,,173,173,173,173,,,,173,173,174,,174,175,174,173,11,,,,,,', -',,,,175,,175,,175,,173,,,174,,,,,,,,174,174,174,174,174,174,,174,174', -'175,,,,,174,,,175,175,175,175,175,175,176,175,175,,,,,,175,174,,,,176', -'176,,176,177,176,,,176,,,,,175,,,,177,177,,177,,177,,,177,,176,,,,,', -',,176,176,176,176,176,176,,176,176,177,,,,,176,,,177,177,177,177,177', -'177,178,177,177,,,,,,177,176,,,,178,178,,178,179,178,,,178,,,,,177,', -',,179,179,,179,,179,,,179,,178,,,,,,,,178,178,178,178,178,178,,178,178', -'179,,,,,178,,,179,179,179,179,179,179,180,179,179,,,,,,179,178,,,180', -'180,180,,180,,180,,181,180,180,180,180,,179,,,,,,181,181,181,,181,,181', -',180,181,181,181,181,,,,180,180,180,180,180,180,,180,180,,,,181,,180', -',,181,,,181,181,181,181,181,181,182,181,181,,,,180,,181,182,182,182', -'182,182,182,,182,,182,,,182,182,182,182,,181,,,,,,,,,,,,,,182,,,,182', -'182,,,182,182,182,182,182,182,185,182,182,,,185,,,182,185,185,185,185', -'185,185,,185,,185,,,185,185,185,185,,182,,,,,,,,,,,,,,185,,,,185,185', -',,185,185,185,185,185,185,184,185,185,,,,,,185,184,184,184,184,184,184', -',184,,184,,,184,184,184,184,,185,,,,,,,,,,,,,,184,,,,184,184,,,184,184', -'184,184,184,184,183,184,184,,,,,,184,183,183,183,183,183,183,,183,170', -'183,,169,183,183,183,183,,184,,,,,170,,170,169,170,169,,169,,183,,,', -'183,183,,171,183,183,183,183,183,183,,183,183,170,,,169,171,183,171', -',171,,,,,,,170,170,,169,169,,,170,183,,169,,,,,171,,,,,,,,,,,,,,,171', -'171,,276,276,276,276,171,276,276,276,276,276,,276,276,,,,,,,276,276', -'276,271,271,271,271,,271,271,271,271,271,,271,271,,,276,276,,,271,271', -'271,213,213,213,213,,213,213,213,213,213,,213,213,,,271,271,,,213,213', -'213,,,,,,,,,,,,,,,,213,213' ] - racc_action_check = arr = ::Array.new(6523, nil) +'81,,81,81,81,81,,,81,81,,,81,,,81,81,,,,82,82,,81,82,,82,,,81,,,,81', +'81,,81,81,,,,81,,82,,81,,,,82,,82,,82,82,,82,82,82,,82,82,,,,,82,82', +',,82,,,82,82,,,,83,83,,82,83,,83,,,82,,,,82,82,,82,82,,,,82,,83,,82', +',,,83,,83,,83,83,,83,83,83,,83,83,,,,,83,83,,,83,,,83,83,,,,84,84,,83', +'84,,84,,,83,,,,83,83,,83,83,,,,83,,84,,83,,,,84,,84,,84,84,,84,84,84', +',84,84,,,,,84,84,,,84,,,84,84,,,,85,85,,84,85,,85,,,84,,,,84,84,,84', +'84,,,,84,,85,,84,,,,85,,85,,85,85,,85,85,85,,85,85,,,,,85,85,,,85,,', +'85,85,,,,86,86,,85,86,,86,,,85,,,,85,85,,85,85,,,,85,,86,,85,,,,86,', +'86,,86,86,,86,86,86,,86,86,,,,,86,86,,,86,,,86,86,,,,87,87,,86,87,,87', +',,86,,,,86,86,,86,86,,,,86,,87,,86,,,,87,,87,,87,87,,87,87,87,,87,87', +',,,,87,87,,,87,,,87,87,,,,88,88,,87,88,,88,,,87,,,,87,87,,87,87,,,,87', +',88,,87,,,,88,,88,,88,88,,88,88,88,,88,88,,,,,88,88,,,88,,,88,88,,,', +'89,89,,88,89,,89,,,88,,,,88,88,,88,88,,,,88,,89,,88,,,,89,,89,,89,89', +',89,89,89,,89,89,,,,,89,89,,,89,,,89,89,,,,90,90,,89,90,,90,,,89,,,', +'89,89,,89,89,,,,89,,90,,89,,,,90,,90,,90,90,,90,90,90,,90,90,,,,,90', +'90,,,90,,,90,90,,,,91,91,,90,91,,91,,,90,,,,90,90,,90,90,,,,90,,91,', +'90,,,,91,,91,,91,91,,91,91,91,,91,91,,,,,91,91,,,91,,,91,91,,,,92,92', +',91,92,,92,,,91,,,,91,91,,91,91,,,,91,,92,,91,,,,92,,92,,92,92,,92,92', +'92,,92,92,,,,,92,92,,,92,,,92,92,,,,93,93,,92,93,,93,,,92,,,,92,92,', +'92,92,,,,92,,93,,92,,,,93,,93,,93,93,,93,93,93,,93,93,,,,,93,93,,,93', +',,93,93,,,,94,94,,93,94,,94,,,93,,,,93,93,,93,93,,,,93,,94,,93,,,,94', +',94,,94,94,,94,94,94,,94,94,,,,,94,94,,,94,,,94,94,,,,95,95,,94,95,', +'95,,,94,,,,94,94,,94,94,,,,94,,95,,94,,,,95,,95,,95,95,,95,95,95,,95', +'95,,,,,95,95,,,95,,,95,95,,,,96,96,,95,96,,96,,,95,,,,95,95,,95,95,', +',,95,,96,,95,,,,96,,96,,96,96,,96,96,96,,96,96,,,,,96,96,,,96,,,96,96', +',,,97,97,,96,97,,97,,,96,,,,96,96,,96,96,,,,96,,97,,96,,,,97,,97,,97', +'97,,97,97,97,,97,97,,,,,97,97,,,97,,,97,97,,,,98,98,,97,98,,98,,,97', +',,,97,97,,97,97,,,,97,,98,,97,,,,98,,98,,98,98,,98,98,98,,98,98,,,,', +'98,98,,,98,,,98,98,,,,99,99,,98,99,,99,,,98,,,,98,98,,98,98,,,,98,,99', +',98,,,,99,,99,,99,99,,99,99,99,,99,99,,,,,99,99,,,99,,,99,99,,,,100', +'100,,99,100,,100,,,99,,,,99,99,,99,99,,,,99,,100,,99,,,,100,,100,,100', +'100,,100,100,100,,100,100,,,,,100,100,,,100,,,100,100,,,,101,101,,100', +'101,,101,,,100,,,,100,100,,100,100,,,,100,,101,,100,,,,101,,101,,101', +'101,,101,101,101,,101,101,,,,,101,101,,,101,,,101,101,,,,102,102,,101', +'102,,102,,,101,,,,101,101,,101,101,,,,101,,102,,101,,,,102,,102,,102', +'102,,102,102,102,,102,102,,,,,102,102,,,102,,,102,102,,,,103,103,,102', +'103,,103,,,102,,,,102,102,,102,102,,,,102,,103,,102,,,,103,,103,,103', +'103,,103,103,103,,103,103,,,,,103,103,,,103,,,103,103,,,,104,104,,103', +'104,,104,,,103,,,,103,103,,103,103,,,,103,,104,,103,,,,104,,104,,104', +'104,,104,104,104,,104,104,,,,,104,104,,,104,,,104,104,,,,320,320,,104', +'320,,320,320,,104,,,104,104,104,,104,104,,,,104,,320,,104,,,,320,,320', +',320,320,,320,320,320,,320,320,320,320,,,320,320,,,320,,,320,320,,,', +'106,106,,320,106,,106,,,320,,,,320,320,,320,320,,,,320,,106,,320,,,', +'106,106,106,106,106,106,106,106,106,106,,106,106,,,,,106,106,106,106', +'106,,,106,106,,,,319,319,,106,319,,319,,106,106,,,,106,106,,106,106', +',,,106,,319,,106,,,,319,,319,,319,319,,319,319,319,,319,319,319,319', +',,319,319,,,319,,,319,319,,,,108,108,,319,108,,108,,,319,,,,319,319', +',319,319,,,,319,,108,,319,,,,108,,108,,108,108,,108,108,108,,108,108', +',,,,108,108,,,108,,,108,108,,,,109,109,,108,109,,109,,,108,,,,108,108', +',108,108,,,,108,,109,,108,,,,109,,109,,109,109,,109,109,109,,109,109', +',,,,109,109,,,109,,,109,109,,,,233,233,,109,233,,233,,,109,,,,109,109', +',109,109,,,,109,,233,,109,,,,233,,233,,233,233,,233,233,233,,233,233', +',,,,233,233,,,233,,,233,233,,,,232,232,,233,232,,232,232,,233,,,,233', +'233,,233,233,,,,233,,232,,233,,,,232,,232,,232,232,,232,232,232,,232', +'232,232,232,,,232,232,,,232,,,232,232,,,,231,231,,232,231,,231,231,', +'232,,,,232,232,,232,232,,,,232,,231,,232,,,,231,,231,,231,231,,231,231', +'231,,231,231,231,231,,,231,231,,,231,,,231,231,,,,246,246,,231,246,246', +'246,,,231,,,,231,231,,231,231,,,,231,,246,,231,,,,246,,246,,246,246', +',246,246,246,,246,246,,,,,246,246,,,246,,,246,246,,,,269,269,,246,269', +',269,,,246,,,,246,246,,246,246,,,,246,,269,,246,,,,269,,269,,269,269', +',269,269,269,,269,269,,,,,269,269,,,269,,,269,269,,,,115,115,,269,115', +',115,,,269,,,,269,269,,269,269,,,,269,,115,115,269,,,,115,,115,,115', +'115,,115,115,115,,115,115,,,,,115,115,,,115,,,115,115,,,,308,308,,115', +'308,,308,308,,115,,,,115,115,,115,115,,,,115,,308,,115,,,,308,,308,', +'308,308,,308,308,308,,308,308,,,,,308,308,,,308,,,308,308,,,,224,224', +',308,224,,224,224,,308,,,,308,308,,308,308,,,,308,,224,,308,,,,224,', +'224,,224,224,,224,224,224,,224,224,224,224,,,224,224,,,224,,,224,224', +',,,119,119,,224,119,,119,,,224,,,,224,224,,224,224,,,,224,,119,119,224', +',,,119,,119,,119,119,,119,119,119,,119,119,,,,,119,119,,,119,,,119,119', +',,,154,154,,119,154,,154,,,119,,,,119,119,,119,119,,,,119,,154,,119', +',,,154,,154,,154,154,,154,154,154,,154,154,154,154,,,154,154,,,154,', +',154,154,,,,279,279,,154,279,,279,,,154,,,,154,154,,154,154,,,,154,', +'279,,154,,,,279,,279,,279,279,,279,279,279,,279,279,,,,,279,279,,,279', +',,279,279,,,,294,294,,279,294,,294,,,279,,,,279,279,,279,279,,,,279', +',294,,279,,,,294,,294,,294,294,,294,294,294,,294,294,,,,,294,294,,,294', +',,294,294,,,,257,257,,294,257,,257,,,294,,,,294,294,,294,294,,,,294', +',257,,294,,,,257,,257,,257,257,,257,257,257,,257,257,,,,,257,257,,,257', +',,257,257,,,,248,248,,257,248,248,248,,,257,,,,257,257,,257,257,,,,257', +',248,,257,,,,248,,248,,248,248,,248,248,248,,248,248,,,,,248,248,,,248', +',,248,248,,,,126,126,,248,126,,126,,,248,,,,248,248,,248,248,,,,248', +',126,,248,,,,126,,126,,126,126,,126,126,126,,126,126,,,,,126,126,,,126', +',,126,126,,,,250,250,,126,250,,250,,,126,,,,126,126,,126,126,,,,126', +',250,,126,,,,250,,250,,250,250,,250,250,250,,250,250,,,,,250,250,,,250', +',,250,250,,,,301,301,,250,301,,301,,,250,,,,250,250,,250,250,,,,250', +',301,,250,,,,301,,301,,301,301,,301,301,301,,301,301,,,,,301,301,,,301', +',,301,301,,,,252,252,,301,252,,252,252,,301,,,,301,301,,301,301,,,,301', +',252,,301,,,,252,,252,,252,252,,252,252,252,,252,252,,,,,252,252,,,252', +',,252,252,,,,280,280,,252,280,,280,,,252,,,,252,252,,252,252,,244,244', +'252,,280,,252,,,,280,,280,,280,280,,280,280,280,,280,280,,51,51,,280', +'280,,,280,,,280,280,,,244,,,244,280,,,,,,280,,206,206,280,280,,280,280', +'140,,,280,244,51,,280,51,140,140,140,140,140,140,244,140,,140,,,140', +'140,140,140,,,,51,,,206,,,206,,,,,51,140,,,,140,140,,,140,140,140,140', +'140,140,206,140,140,,,,,124,140,124,,206,,,,,124,124,124,124,124,124', +',124,,124,,140,124,124,124,124,,,,,,,,,,,,,,,,124,,,,124,124,,,124,124', +'124,124,124,124,216,124,124,,,,,,124,216,216,216,216,216,216,,216,,216', +',,216,216,216,216,,,124,,,,,,,,,,,,,216,,,,216,216,,,216,216,216,216', +'216,216,145,216,216,,,145,,,216,145,145,145,145,145,145,,145,,145,,', +'145,145,145,145,,,216,,,,,,,,,,,,,145,,,,145,145,,,145,145,145,145,145', +'145,,145,145,,,,,123,145,123,,,,,,,123,123,123,123,123,123,,123,,123', +',145,123,123,123,123,,,,,,,,,,,,,,,,123,,,,123,123,,,123,123,123,123', +'123,123,149,123,123,,,,,,123,149,149,149,149,149,149,,149,,149,,,149', +'149,149,149,,,123,,,,,,,,,,,,,149,,,,149,149,,,149,149,149,149,149,149', +',149,149,,,,,122,149,122,,,,,,,122,122,122,122,122,122,,122,,122,,149', +'122,122,122,122,,,,,,,,,,,,,,,,122,,,,122,122,,,122,122,122,122,122', +'122,,122,122,,,,,266,122,266,,,266,,,,266,266,266,266,266,266,,266,', +'266,,122,266,266,266,266,,,,,,,,,,,,,,,,266,,,,266,266,,,266,266,266', +'266,266,266,,266,266,,,,,120,266,120,,,,,,,120,120,120,120,120,120,', +'120,,120,,266,120,120,120,120,,,,,,,,,,,,,,,,120,,,,120,120,,,120,120', +'120,120,120,120,114,120,120,,,,,,120,114,114,114,114,114,114,,114,,114', +',114,114,114,114,114,,,120,,,,,,,,,,,,,114,,,,114,114,,,114,114,114', +'114,114,114,156,114,114,,,,,,114,156,156,156,156,156,156,,156,,156,', +',156,156,156,156,,,114,,,,,,,,,,,,,156,,,,156,156,,,156,156,156,156', +'156,156,324,156,156,,,,,,156,324,324,324,324,324,324,,324,,324,156,156', +'324,324,324,324,,,156,,,,,,,,,,,,,324,,,,324,324,,,324,324,324,324,324', +'324,327,324,324,,,,,,324,327,327,327,327,327,327,,327,,327,,,327,327', +'327,327,,,324,,,,,,,,,,,,,327,,,,327,327,,,327,327,327,327,327,327,333', +'327,327,,,,,,327,333,333,333,333,333,333,,333,,333,,,333,333,333,333', +',,327,,,,,,,,,,,,,333,,,,333,333,,,333,333,333,333,333,333,341,333,333', +',,,,,333,341,341,341,341,341,341,,341,,341,,,341,341,341,341,,,333,', +',,,,,,,,,,,341,,,,341,341,,,341,341,341,341,341,341,342,341,341,,,,', +',341,342,342,342,342,342,342,,342,,342,,,342,342,342,342,,,341,,,,,', +',,,,,,,342,,,,342,342,,,342,342,342,342,342,342,348,342,342,,,,,,342', +'348,348,348,348,348,348,,348,169,348,,170,348,348,348,348,,,342,,,,169', +',169,170,169,170,,170,,348,,,,348,348,,,348,348,348,348,348,348,,348', +'348,169,,,170,,348,,,,,169,169,,170,170,169,169,,170,170,,,169,,348', +'170,,,,,,,,,,,192,,,,,169,,,170,192,192,192,192,192,192,192,192,,192', +',,192,192,192,192,,,,,,,,,,,,,,,,192,,,,192,192,,,192,192,192,192,192', +'192,,192,192,,,,,11,192,11,,,,,,,11,11,11,11,11,11,,11,,11,,192,11,11', +'11,11,,,,,,,,,,,,,,,,11,,,,11,11,,,11,11,11,11,11,11,187,11,11,,,187', +',,11,187,187,187,187,187,187,,187,174,187,,,187,187,187,187,,,11,,,', +'174,,174,,174,,,,,187,,,,187,187,,,187,187,187,187,187,187,,187,187', +'174,,,175,,187,,,174,174,174,174,,,,174,174,175,,175,176,175,174,,187', +',,,,,,,,,176,,176,,176,,,174,,175,,,,,,,,175,175,175,175,,,,175,175', +'176,,,177,,175,,,176,176,176,176,176,176,,176,176,177,,177,,177,176', +',175,,178,,,,,,,,,,,,,178,178,176,178,177,178,,,178,,,,177,177,177,177', +'177,177,,177,177,,,,,,177,178,,,,,,,179,178,178,178,178,178,178,,178', +'178,,177,,179,179,178,179,180,179,,,179,,,,,,,,,180,180,,180,178,180', +',,180,,179,,,,,,,,179,179,179,179,179,179,,179,179,180,,,,,179,,,180', +'180,180,180,180,180,,180,180,,,,,186,180,,179,,,,,,186,186,186,186,186', +'186,,186,171,186,,180,186,186,186,186,,,,,,,171,,171,,171,,,,,186,,', +',186,186,,182,186,186,186,186,186,186,,186,186,171,,182,182,182,186', +'182,,182,,,182,182,182,182,171,171,,,,,,171,,186,,,,,,182,,,,,183,,', +'182,182,182,182,182,182,,182,182,183,183,183,,183,182,183,,,183,183', +'183,183,,,,,,,,,,,,182,,,,183,,,,,183,,,183,183,183,183,183,183,184', +'183,183,,,,,,183,184,184,184,184,184,184,,184,,184,,,184,184,184,184', +',,183,,,,,,,,,,,,,184,,,,184,184,,,184,184,184,184,184,184,185,184,184', +',,,,,184,185,185,185,185,185,185,,185,181,185,,,185,185,185,185,,,184', +',,181,181,,181,,181,,,181,,185,,,,185,185,,,185,185,185,185,185,185', +',185,185,181,,,172,,185,,,181,181,181,181,181,181,173,181,181,172,,172', +',172,181,,185,,,,173,,173,,173,,,,,,,,,181,,172,,,,,,,,,,,173,,,,172', +'172,,,,,,172,,,,173,173,,273,273,273,273,173,273,273,273,273,273,,273', +'273,,,,,,,273,273,273,278,278,278,278,,278,278,278,278,278,,278,278', +',,273,273,,,278,278,278,215,215,215,215,,215,215,215,215,215,,215,215', +',,278,278,,,215,215,215,,,,,,,,,,,,,,,,215,215' ] + racc_action_check = arr = ::Array.new(6619, nil) idx = 0 clist.each do |str| str.split(',', -1).each do |i| arr[idx] = i.to_i unless i.empty? idx += 1 end end racc_action_pointer = [ - -2, 292, nil, nil, nil, 114, 277, nil, 106, nil, - nil, 5820, 346, 404, 462, nil, nil, nil, nil, nil, + -2, 283, nil, nil, nil, 114, 269, nil, 268, nil, + nil, 5879, 346, 404, 462, 520, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 258, - 190, 227, 694, 752, 810, 868, 70, 199, nil, 44, - 4739, nil, nil, 1158, 1216, 1274, nil, nil, nil, nil, - 1332, nil, 153, 156, nil, 1506, nil, nil, nil, nil, - nil, nil, nil, 225, 1622, 211, 1738, 1796, 1854, 1912, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 239, 173, 32, 752, 810, 868, 926, 70, 186, nil, + 67, 4797, nil, nil, 1216, 1274, 1332, nil, nil, nil, + nil, 1390, nil, 150, 149, nil, 1564, nil, nil, nil, + nil, nil, nil, nil, 209, 1680, 194, 1796, 1854, 1912, 1970, 2028, 2086, 2144, 2202, 2260, 2318, 2376, 2434, 2492, 2550, 2608, 2666, 2724, 2782, 2840, 2898, 2956, 3014, 3072, - 3130, 3188, 3246, 3304, 161, 3420, 176, 3536, 3594, 350, - 73, 292, 5235, 3884, nil, 119, -15, 4058, 5181, nil, - 5120, 5059, 4944, 20, 4406, -7, nil, nil, nil, nil, - 77, -7, nil, 169, nil, nil, nil, nil, 4768, 20, - nil, 7, nil, 4883, 73, nil, nil, 4998, nil, 156, - nil, 141, 4116, -22, 5289, 1448, nil, 123, nil, nil, - nil, nil, nil, 61, 234, 118, 176, 5630, 5633, 6349, - 6346, 6376, 5682, 5837, 5880, 5897, 5951, 5968, 6022, 6039, - 6093, 6113, 6167, 6329, 6275, 6221, nil, nil, 288, nil, - 5759, 636, 926, 984, 206, 225, nil, nil, -8, nil, - -2, -9, 67, -1, 4715, -1, -4, nil, nil, nil, - nil, nil, nil, 6453, 5505, 184, nil, 195, nil, 182, - 95, nil, 1100, nil, 136, nil, 131, -4, nil, 1390, - 3826, 4174, 4696, 4290, 74, 193, nil, -14, 251, 85, - 23, nil, 14, 248, 4464, nil, 4232, nil, 4638, nil, - 4580, nil, nil, nil, nil, 4522, nil, nil, nil, 201, - nil, nil, nil, nil, 4829, 81, nil, 4348, 4000, 100, - nil, 6431, nil, 114, 3942, 122, 6409, 3768, 3710, 139, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, 3652, 141, nil, 159, nil, 106, 144, 3478, - nil, 176, 102, 183, 161, 3, 3362, nil, 161, 192, - 165, 200, 3, nil, 78, nil, 207, 1680, 1564, nil, - nil, nil, 5343, nil, nil, 5397, nil, nil, nil, 159, - -10, 5451, 225, 1042, 230, nil, nil, nil, nil, 5559, - 5613, 241, 181, nil, nil, nil, 5705, 94, nil, 578, - 254, 232, nil, 259, 263, nil, nil, nil, 267, 268, - 272, nil, 520, nil, nil, nil, 258, 277, nil, nil, - 278, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 230, nil, 172, 56, nil, nil, nil, 286, nil, - nil, nil, 288, nil, 291, nil, 292, nil, nil, nil, - nil, nil ] + 3130, 3188, 3246, 3304, 3362, 164, 3478, 194, 3594, 3652, + 350, 73, 408, 234, 5347, 4000, nil, 171, -15, 4174, + 5293, nil, 5171, 5056, 4887, 20, 4522, 151, nil, nil, + nil, nil, 142, -7, nil, 128, nil, nil, nil, nil, + 4826, 20, nil, 7, nil, 4995, 73, nil, nil, 5110, + nil, 13, nil, 112, 4232, -22, 5401, 1738, nil, 122, + nil, nil, nil, nil, nil, 4, 292, 176, 118, 5742, + 5745, 6218, 6461, 6472, 5950, 5993, 6010, 6053, 6076, 6123, + 6140, 6418, 6248, 6293, 6347, 6401, 6201, 5933, nil, nil, + 288, nil, 5818, 694, 1042, 1100, 87, 90, nil, nil, + -2, nil, -9, -8, 48, -1, 4823, -1, -4, nil, + nil, nil, nil, nil, nil, 6549, 4941, 46, nil, 113, + nil, 131, 74, nil, 4116, nil, 159, nil, 203, -4, + nil, 3826, 3768, 3710, 1158, 984, 188, 32, nil, -14, + 269, 234, 23, nil, 4773, 154, 3884, nil, 4464, nil, + 4580, nil, 4696, nil, nil, nil, nil, 4406, nil, nil, + nil, 225, nil, nil, nil, nil, 5232, 81, nil, 3942, + 1506, 106, nil, 6505, nil, 122, 1622, 126, 6527, 4290, + 4754, 134, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, 4348, 125, nil, 151, nil, 91, + 130, 4638, nil, 159, 36, 163, 141, 3, 4058, nil, + 143, 173, 148, 183, 185, nil, 37, nil, 189, 3536, + 3420, nil, nil, nil, 5455, nil, nil, 5509, nil, nil, + nil, 143, 47, 5563, 214, 1448, 214, nil, nil, nil, + nil, 5617, 5671, 222, 164, nil, nil, nil, 5725, 89, + nil, 636, 239, 218, nil, 243, 244, nil, nil, nil, + 250, 251, 253, nil, 578, nil, nil, nil, 241, 262, + nil, nil, 267, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, 230, nil, 172, 56, nil, nil, nil, + 275, nil, nil, nil, 278, nil, 279, nil, 280, nil, + nil, nil, nil, nil ] racc_action_default = [ - -229, -230, -1, -2, -3, -4, -5, -8, -10, -11, - -16, -108, -230, -230, -230, -45, -46, -47, -48, -49, + -230, -231, -1, -2, -3, -4, -5, -8, -10, -11, + -16, -109, -231, -231, -231, -231, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, - -60, -61, -62, -63, -64, -65, -66, -67, -68, -73, - -74, -78, -230, -230, -230, -230, -230, -119, -121, -230, - -230, -157, -167, -230, -230, -230, -180, -181, -182, -183, - -230, -185, -230, -196, -199, -230, -204, -205, -206, -207, - -208, -209, -210, -230, -230, -7, -230, -230, -230, -230, - -230, -230, -230, -230, -230, -230, -230, -230, -230, -230, - -230, -230, -230, -230, -230, -230, -230, -230, -230, -230, - -230, -230, -230, -230, -230, -128, -123, -229, -229, -28, - -230, -35, -230, -230, -75, -230, -230, -230, -230, -85, - -230, -230, -230, -230, -230, -229, -138, -158, -159, -120, - -229, -229, -147, -149, -150, -151, -152, -153, -43, -230, - -170, -230, -173, -230, -230, -176, -177, -189, -184, -230, - -192, -230, -230, -230, -230, -230, 402, -6, -9, -12, - -13, -14, -15, -230, -18, -19, -20, -21, -22, -23, - -24, -25, -26, -27, -29, -30, -31, -32, -33, -34, - -36, -37, -38, -39, -40, -230, -41, -103, -230, -79, - -230, -222, -228, -216, -213, -211, -117, -129, -205, -132, - -209, -230, -219, -217, -225, -207, -208, -215, -220, -221, - -223, -224, -226, -128, -127, -230, -126, -230, -42, -211, - -70, -80, -230, -83, -211, -163, -166, -230, -77, -230, - -230, -230, -128, -230, -213, -229, -160, -230, -230, -230, - -230, -155, -230, -230, -230, -168, -230, -171, -230, -174, - -230, -186, -187, -188, -190, -230, -193, -194, -195, -211, - -197, -200, -202, -203, -108, -230, -17, -230, -230, -211, - -105, -128, -116, -230, -214, -230, -212, -230, -230, -211, - -131, -133, -216, -217, -218, -219, -222, -225, -227, -228, - -124, -125, -212, -230, -72, -230, -82, -230, -212, -230, - -76, -230, -88, -230, -94, -230, -230, -98, -213, -211, - -213, -230, -230, -141, -230, -161, -211, -229, -230, -148, - -156, -154, -44, -169, -172, -179, -175, -178, -191, -230, - -230, -107, -230, -212, -211, -111, -118, -112, -130, -134, - -135, -230, -69, -81, -84, -164, -165, -88, -87, -230, - -230, -94, -93, -230, -230, -102, -97, -99, -230, -230, - -230, -114, -229, -142, -143, -144, -230, -230, -139, -140, - -230, -146, -198, -201, -104, -106, -115, -122, -71, -86, - -89, -230, -92, -230, -230, -109, -110, -113, -230, -162, - -136, -145, -230, -91, -230, -96, -230, -101, -137, -90, - -95, -100 ] + -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, + -74, -75, -79, -231, -231, -231, -231, -231, -120, -122, + -231, -231, -158, -168, -231, -231, -231, -181, -182, -183, + -184, -231, -186, -231, -197, -200, -231, -205, -206, -207, + -208, -209, -210, -211, -231, -231, -7, -231, -231, -231, + -231, -231, -231, -231, -231, -231, -231, -231, -231, -231, + -231, -231, -231, -231, -231, -231, -231, -231, -231, -231, + -231, -231, -231, -231, -231, -231, -129, -124, -230, -230, + -28, -231, -29, -36, -231, -231, -76, -231, -231, -231, + -231, -86, -231, -231, -231, -231, -231, -230, -139, -159, + -160, -121, -230, -230, -148, -150, -151, -152, -153, -154, + -44, -231, -171, -231, -174, -231, -231, -177, -178, -190, + -185, -231, -193, -231, -231, -231, -231, -231, 404, -6, + -9, -12, -13, -14, -15, -231, -18, -19, -20, -21, + -22, -23, -24, -25, -26, -27, -30, -31, -32, -33, + -34, -35, -37, -38, -39, -40, -41, -231, -42, -104, + -231, -80, -231, -223, -229, -217, -214, -212, -118, -130, + -206, -133, -210, -231, -220, -218, -226, -208, -209, -216, + -221, -222, -224, -225, -227, -129, -128, -231, -127, -231, + -43, -212, -71, -81, -231, -84, -212, -164, -167, -231, + -78, -231, -231, -231, -129, -231, -214, -230, -161, -231, + -231, -231, -231, -156, -231, -231, -231, -169, -231, -172, + -231, -175, -231, -187, -188, -189, -191, -231, -194, -195, + -196, -212, -198, -201, -203, -204, -109, -231, -17, -231, + -231, -212, -106, -129, -117, -231, -215, -231, -213, -231, + -231, -212, -132, -134, -217, -218, -219, -220, -223, -226, + -228, -229, -125, -126, -213, -231, -73, -231, -83, -231, + -213, -231, -77, -231, -89, -231, -95, -231, -231, -99, + -214, -212, -214, -231, -231, -142, -231, -162, -212, -230, + -231, -149, -157, -155, -45, -170, -173, -180, -176, -179, + -192, -231, -231, -108, -231, -213, -212, -112, -119, -113, + -131, -135, -136, -231, -70, -82, -85, -165, -166, -89, + -88, -231, -231, -95, -94, -231, -231, -103, -98, -100, + -231, -231, -231, -115, -230, -143, -144, -145, -231, -231, + -140, -141, -231, -147, -199, -202, -105, -107, -116, -123, + -72, -87, -90, -231, -93, -231, -231, -110, -111, -114, + -231, -163, -137, -146, -231, -92, -231, -97, -231, -102, + -138, -91, -96, -101 ] racc_goto_table = [ - 2, 114, 4, 130, 109, 111, 112, 148, 136, 134, - 261, 187, 195, 194, 224, 273, 352, 367, 186, 235, - 348, 215, 217, 307, 238, 159, 160, 161, 162, 319, - 158, 320, 234, 75, 118, 120, 121, 122, 336, 271, - 275, 354, 338, 139, 141, 138, 138, 143, 269, 306, - 380, 259, 147, 312, 363, 311, 239, 154, 221, 345, - 327, 256, 388, 382, 293, 379, 257, 3, 254, 297, - 255, 163, 253, 138, 164, 165, 166, 167, 168, 169, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, 185, 270, 190, 357, 214, - 214, 150, 157, 219, 329, 138, 152, 227, 1, 138, - nil, nil, nil, nil, 332, nil, 190, nil, nil, nil, - 279, nil, nil, nil, 341, nil, nil, 236, nil, 358, - nil, 360, 236, 241, nil, 316, nil, nil, nil, 309, - 308, 310, nil, nil, nil, nil, nil, 264, nil, nil, - nil, nil, 258, nil, 359, 265, 130, nil, nil, nil, - nil, 366, 136, 134, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 334, 376, - 185, 294, nil, 118, 120, 121, 373, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 136, 134, - 136, 134, 328, nil, nil, nil, nil, nil, nil, nil, + 2, 132, 4, 116, 110, 112, 113, 114, 150, 138, + 136, 197, 263, 196, 275, 226, 189, 354, 369, 237, + 350, 321, 309, 322, 240, 161, 162, 163, 164, 76, + 217, 219, 188, 236, 160, 120, 122, 123, 124, 338, + 273, 356, 277, 340, 141, 143, 140, 140, 145, 271, + 308, 382, 261, 149, 313, 314, 365, 241, 156, 223, + 347, 329, 258, 390, 384, 381, 295, 259, 3, 256, + 257, 299, 165, 255, 140, 166, 167, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, + 181, 182, 183, 184, 185, 186, 187, 359, 192, 159, + 216, 216, 272, 152, 154, 221, 331, 140, 1, 229, + nil, 140, nil, nil, nil, nil, 334, nil, 192, nil, + 281, nil, nil, nil, nil, nil, 343, nil, 360, 238, + 362, nil, nil, nil, 238, 243, 318, nil, nil, 311, + nil, 310, 312, nil, nil, nil, nil, nil, nil, 266, + nil, nil, nil, nil, 260, 132, 361, 267, nil, nil, + nil, nil, nil, 368, 138, 136, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 336, nil, + nil, 378, 187, nil, 296, 120, 122, 123, 375, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 138, 136, 138, 136, 330, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, 297, 140, 192, 192, nil, nil, + nil, 303, 305, nil, nil, nil, nil, nil, 324, 315, + 324, nil, 327, nil, 145, nil, nil, 377, nil, 149, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, 295, 138, 190, 190, nil, nil, nil, 301, - 303, nil, nil, nil, nil, nil, 322, 313, 322, nil, - 325, 375, 143, nil, nil, nil, nil, 147, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 322, - 331, nil, nil, nil, nil, nil, 190, nil, 364, 339, - 340, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 322, nil, nil, nil, nil, nil, - nil, 346, nil, nil, nil, nil, nil, nil, 138, nil, - nil, nil, nil, 378, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 370, 369, - nil, nil, nil, nil, nil, 185, nil, nil, nil, nil, + nil, 324, 333, nil, nil, nil, nil, 366, 192, nil, + nil, 341, 342, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 324, nil, nil, nil, + nil, nil, nil, 348, nil, nil, nil, nil, nil, nil, + 140, nil, nil, nil, nil, nil, 380, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 118, nil, nil, nil, nil, nil, nil, nil, nil, + 372, 371, nil, nil, nil, nil, nil, 187, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 369, nil, nil, nil, nil, nil, + nil, nil, nil, 120, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 392, nil, 394, 396 ] + nil, nil, nil, nil, nil, nil, 371, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, 394, nil, 396, 398 ] racc_goto_check = [ - 2, 40, 4, 65, 10, 10, 10, 82, 32, 38, - 89, 52, 57, 55, 45, 56, 48, 67, 13, 66, - 47, 61, 61, 50, 66, 8, 8, 8, 8, 73, - 7, 73, 55, 6, 10, 10, 10, 10, 58, 59, - 39, 51, 62, 12, 12, 10, 10, 10, 53, 49, - 46, 45, 10, 69, 70, 56, 72, 10, 44, 75, - 77, 78, 67, 48, 39, 47, 79, 3, 83, 39, - 84, 12, 86, 10, 10, 10, 10, 10, 10, 10, + 2, 65, 4, 40, 10, 10, 10, 10, 82, 32, + 38, 57, 89, 55, 56, 45, 52, 48, 67, 66, + 47, 73, 50, 73, 66, 8, 8, 8, 8, 6, + 61, 61, 13, 55, 7, 10, 10, 10, 10, 58, + 59, 51, 39, 62, 12, 12, 10, 10, 10, 53, + 49, 46, 45, 10, 56, 69, 70, 72, 10, 44, + 75, 77, 78, 67, 48, 47, 39, 79, 3, 83, + 84, 39, 12, 86, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 52, 10, 50, 10, - 10, 87, 6, 12, 39, 10, 88, 12, 1, 10, - nil, nil, nil, nil, 39, nil, 10, nil, nil, nil, - 57, nil, nil, nil, 39, nil, nil, 4, nil, 56, - nil, 56, 4, 4, nil, 45, nil, nil, nil, 57, - 55, 55, nil, nil, nil, nil, nil, 10, nil, nil, - nil, nil, 2, nil, 39, 2, 65, nil, nil, nil, - nil, 39, 32, 38, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 57, 39, - 10, 40, nil, 10, 10, 10, 89, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 32, 38, - 32, 38, 82, nil, nil, nil, nil, nil, nil, nil, + 10, 10, 10, 10, 10, 10, 10, 50, 10, 6, + 10, 10, 52, 87, 88, 12, 39, 10, 1, 12, + nil, 10, nil, nil, nil, nil, 39, nil, 10, nil, + 57, nil, nil, nil, nil, nil, 39, nil, 56, 4, + 56, nil, nil, nil, 4, 4, 45, nil, nil, 57, + nil, 55, 55, nil, nil, nil, nil, nil, nil, 10, + nil, nil, nil, nil, 2, 65, 39, 2, nil, nil, + nil, nil, nil, 39, 32, 38, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 57, nil, + nil, 39, 10, nil, 40, 10, 10, 10, 89, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 32, 38, 32, 38, 82, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, 2, 10, 10, 10, nil, nil, + nil, 2, 2, nil, nil, nil, nil, nil, 10, 4, + 10, nil, 10, nil, 10, nil, nil, 52, nil, 10, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, 2, 10, 10, 10, nil, nil, nil, 2, - 2, nil, nil, nil, nil, nil, 10, 4, 10, nil, - 10, 52, 10, nil, nil, nil, nil, 10, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 10, - 10, nil, nil, nil, nil, nil, 10, nil, 65, 10, - 10, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 10, nil, nil, nil, nil, nil, - nil, 10, nil, nil, nil, nil, nil, nil, 10, nil, - nil, nil, nil, 40, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 2, 4, - nil, nil, nil, nil, nil, 10, nil, nil, nil, nil, + nil, 10, 10, nil, nil, nil, nil, 65, 10, nil, + nil, 10, 10, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, 10, nil, nil, nil, + nil, nil, nil, 10, nil, nil, nil, nil, nil, nil, + 10, nil, nil, nil, nil, nil, 40, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 10, nil, nil, nil, nil, nil, nil, nil, nil, + 2, 4, nil, nil, nil, nil, nil, 10, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, 4, nil, nil, nil, nil, nil, + nil, nil, nil, 10, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 2, nil, 2, 2 ] + nil, nil, nil, nil, nil, nil, 4, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, 2, nil, 2, 2 ] racc_goto_pointer = [ - nil, 108, 0, 67, 2, nil, 28, -46, -52, nil, - -8, nil, -10, -85, nil, nil, nil, nil, nil, nil, + nil, 108, 0, 68, 2, nil, 24, -43, -53, nil, + -8, nil, -10, -72, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, -42, nil, nil, nil, nil, nil, -41, -155, - -39, nil, nil, nil, -57, -102, -299, -282, -288, -182, - -208, -264, -92, -140, nil, -92, -179, -93, -236, -151, - nil, -86, -234, nil, nil, -46, -106, -300, nil, -182, - -260, nil, -75, -211, nil, -239, nil, -190, -90, -85, - nil, nil, -53, -81, -79, nil, -77, 39, 43, -144 ] + -38, nil, nil, nil, -58, -103, -300, -284, -289, -183, + -211, -266, -88, -141, nil, -93, -182, -95, -237, -152, + nil, -78, -235, nil, nil, -49, -108, -301, nil, -182, + -260, nil, -76, -221, nil, -240, nil, -191, -91, -86, + nil, nil, -53, -82, -81, nil, -78, 40, 40, -144 ] racc_goto_default = [ - nil, nil, 368, nil, 216, 5, 6, 7, 8, 9, - 11, 10, 305, nil, 15, 39, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, nil, - nil, 40, 41, 115, nil, nil, 119, nil, nil, nil, - nil, nil, nil, nil, 45, nil, nil, nil, 196, nil, - 106, nil, 197, 201, 199, 126, nil, nil, 125, nil, - nil, 131, nil, 132, 133, 225, 144, 146, 56, 57, - 58, 60, nil, nil, nil, 149, nil, nil, nil, nil ] + nil, nil, 370, nil, 218, 5, 6, 7, 8, 9, + 11, 10, 307, nil, 16, 40, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, nil, + nil, 41, 42, 117, nil, nil, 121, nil, nil, nil, + nil, nil, nil, nil, 46, nil, nil, nil, 198, nil, + 107, nil, 199, 203, 201, 128, nil, nil, 127, nil, + nil, 133, nil, 134, 135, 227, 146, 148, 57, 58, + 59, 61, nil, nil, nil, 151, nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, - 1, 90, :_reduce_1, - 1, 90, :_reduce_2, - 1, 90, :_reduce_none, - 1, 91, :_reduce_4, - 1, 94, :_reduce_5, - 3, 94, :_reduce_6, - 2, 94, :_reduce_7, - 1, 95, :_reduce_8, - 3, 95, :_reduce_9, - 1, 96, :_reduce_none, - 1, 97, :_reduce_11, - 3, 97, :_reduce_12, - 3, 97, :_reduce_13, - 3, 97, :_reduce_14, - 3, 97, :_reduce_15, - 1, 99, :_reduce_none, - 4, 99, :_reduce_17, - 3, 99, :_reduce_18, - 3, 99, :_reduce_19, - 3, 99, :_reduce_20, - 3, 99, :_reduce_21, - 3, 99, :_reduce_22, - 3, 99, :_reduce_23, - 3, 99, :_reduce_24, - 3, 99, :_reduce_25, - 3, 99, :_reduce_26, - 3, 99, :_reduce_27, - 2, 99, :_reduce_28, - 3, 99, :_reduce_29, - 3, 99, :_reduce_30, - 3, 99, :_reduce_31, - 3, 99, :_reduce_32, - 3, 99, :_reduce_33, - 3, 99, :_reduce_34, - 2, 99, :_reduce_35, - 3, 99, :_reduce_36, - 3, 99, :_reduce_37, - 3, 99, :_reduce_38, - 3, 99, :_reduce_39, - 3, 99, :_reduce_40, - 3, 99, :_reduce_41, - 3, 99, :_reduce_42, - 1, 101, :_reduce_43, - 3, 101, :_reduce_44, + 1, 91, :_reduce_1, + 1, 91, :_reduce_2, + 1, 91, :_reduce_none, + 1, 92, :_reduce_4, + 1, 95, :_reduce_5, + 3, 95, :_reduce_6, + 2, 95, :_reduce_7, + 1, 96, :_reduce_8, + 3, 96, :_reduce_9, + 1, 97, :_reduce_none, + 1, 98, :_reduce_11, + 3, 98, :_reduce_12, + 3, 98, :_reduce_13, + 3, 98, :_reduce_14, + 3, 98, :_reduce_15, 1, 100, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, - 1, 104, :_reduce_none, + 4, 100, :_reduce_17, + 3, 100, :_reduce_18, + 3, 100, :_reduce_19, + 3, 100, :_reduce_20, + 3, 100, :_reduce_21, + 3, 100, :_reduce_22, + 3, 100, :_reduce_23, + 3, 100, :_reduce_24, + 3, 100, :_reduce_25, + 3, 100, :_reduce_26, + 3, 100, :_reduce_27, + 2, 100, :_reduce_28, + 2, 100, :_reduce_29, + 3, 100, :_reduce_30, + 3, 100, :_reduce_31, + 3, 100, :_reduce_32, + 3, 100, :_reduce_33, + 3, 100, :_reduce_34, + 3, 100, :_reduce_35, + 2, 100, :_reduce_36, + 3, 100, :_reduce_37, + 3, 100, :_reduce_38, + 3, 100, :_reduce_39, + 3, 100, :_reduce_40, + 3, 100, :_reduce_41, + 3, 100, :_reduce_42, + 3, 100, :_reduce_43, + 1, 102, :_reduce_44, + 3, 102, :_reduce_45, + 1, 101, :_reduce_none, + 1, 105, :_reduce_none, + 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 105, :_reduce_none, - 1, 122, :_reduce_67, - 1, 122, :_reduce_68, - 5, 103, :_reduce_69, - 3, 103, :_reduce_70, - 6, 103, :_reduce_71, - 4, 103, :_reduce_72, - 1, 103, :_reduce_73, - 1, 107, :_reduce_74, - 2, 107, :_reduce_75, - 4, 130, :_reduce_76, - 3, 130, :_reduce_77, - 1, 130, :_reduce_78, - 3, 131, :_reduce_79, - 2, 129, :_reduce_80, - 3, 133, :_reduce_81, - 2, 133, :_reduce_82, - 2, 132, :_reduce_83, - 4, 132, :_reduce_84, - 2, 110, :_reduce_85, - 5, 135, :_reduce_86, - 4, 135, :_reduce_87, - 0, 136, :_reduce_none, - 2, 136, :_reduce_89, - 4, 136, :_reduce_90, - 3, 136, :_reduce_91, - 6, 111, :_reduce_92, - 5, 111, :_reduce_93, + 1, 105, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 106, :_reduce_none, + 1, 123, :_reduce_68, + 1, 123, :_reduce_69, + 5, 104, :_reduce_70, + 3, 104, :_reduce_71, + 6, 104, :_reduce_72, + 4, 104, :_reduce_73, + 1, 104, :_reduce_74, + 1, 108, :_reduce_75, + 2, 108, :_reduce_76, + 4, 131, :_reduce_77, + 3, 131, :_reduce_78, + 1, 131, :_reduce_79, + 3, 132, :_reduce_80, + 2, 130, :_reduce_81, + 3, 134, :_reduce_82, + 2, 134, :_reduce_83, + 2, 133, :_reduce_84, + 4, 133, :_reduce_85, + 2, 111, :_reduce_86, + 5, 136, :_reduce_87, + 4, 136, :_reduce_88, 0, 137, :_reduce_none, - 4, 137, :_reduce_95, - 3, 137, :_reduce_96, - 5, 109, :_reduce_97, - 1, 138, :_reduce_98, - 2, 138, :_reduce_99, - 5, 139, :_reduce_100, - 4, 139, :_reduce_101, - 1, 140, :_reduce_102, - 1, 102, :_reduce_none, - 4, 102, :_reduce_104, - 1, 142, :_reduce_105, - 3, 142, :_reduce_106, - 3, 141, :_reduce_107, - 1, 98, :_reduce_108, - 6, 98, :_reduce_109, - 6, 98, :_reduce_110, - 5, 98, :_reduce_111, - 5, 98, :_reduce_112, - 6, 98, :_reduce_113, - 5, 98, :_reduce_114, - 4, 147, :_reduce_115, - 1, 148, :_reduce_116, - 1, 144, :_reduce_117, - 3, 144, :_reduce_118, - 1, 143, :_reduce_119, - 2, 143, :_reduce_120, - 1, 143, :_reduce_121, - 6, 108, :_reduce_122, - 2, 108, :_reduce_123, - 3, 149, :_reduce_124, - 3, 149, :_reduce_125, - 1, 150, :_reduce_none, - 1, 150, :_reduce_none, - 0, 146, :_reduce_128, - 1, 146, :_reduce_129, - 3, 146, :_reduce_130, - 1, 152, :_reduce_none, - 1, 152, :_reduce_none, - 1, 152, :_reduce_none, - 3, 151, :_reduce_134, - 3, 151, :_reduce_135, - 6, 112, :_reduce_136, - 7, 113, :_reduce_137, - 1, 157, :_reduce_138, - 1, 156, :_reduce_none, - 1, 156, :_reduce_none, - 1, 158, :_reduce_none, - 2, 158, :_reduce_142, - 1, 159, :_reduce_none, + 2, 137, :_reduce_90, + 4, 137, :_reduce_91, + 3, 137, :_reduce_92, + 6, 112, :_reduce_93, + 5, 112, :_reduce_94, + 0, 138, :_reduce_none, + 4, 138, :_reduce_96, + 3, 138, :_reduce_97, + 5, 110, :_reduce_98, + 1, 139, :_reduce_99, + 2, 139, :_reduce_100, + 5, 140, :_reduce_101, + 4, 140, :_reduce_102, + 1, 141, :_reduce_103, + 1, 103, :_reduce_none, + 4, 103, :_reduce_105, + 1, 143, :_reduce_106, + 3, 143, :_reduce_107, + 3, 142, :_reduce_108, + 1, 99, :_reduce_109, + 6, 99, :_reduce_110, + 6, 99, :_reduce_111, + 5, 99, :_reduce_112, + 5, 99, :_reduce_113, + 6, 99, :_reduce_114, + 5, 99, :_reduce_115, + 4, 148, :_reduce_116, + 1, 149, :_reduce_117, + 1, 145, :_reduce_118, + 3, 145, :_reduce_119, + 1, 144, :_reduce_120, + 2, 144, :_reduce_121, + 1, 144, :_reduce_122, + 6, 109, :_reduce_123, + 2, 109, :_reduce_124, + 3, 150, :_reduce_125, + 3, 150, :_reduce_126, + 1, 151, :_reduce_none, + 1, 151, :_reduce_none, + 0, 147, :_reduce_129, + 1, 147, :_reduce_130, + 3, 147, :_reduce_131, + 1, 153, :_reduce_none, + 1, 153, :_reduce_none, + 1, 153, :_reduce_none, + 3, 152, :_reduce_135, + 3, 152, :_reduce_136, + 6, 113, :_reduce_137, + 7, 114, :_reduce_138, + 1, 158, :_reduce_139, + 1, 157, :_reduce_none, + 1, 157, :_reduce_none, 1, 159, :_reduce_none, - 6, 114, :_reduce_145, - 5, 114, :_reduce_146, - 1, 160, :_reduce_147, - 3, 160, :_reduce_148, - 1, 162, :_reduce_149, - 1, 162, :_reduce_150, - 1, 162, :_reduce_151, + 2, 159, :_reduce_143, + 1, 160, :_reduce_none, + 1, 160, :_reduce_none, + 6, 115, :_reduce_146, + 5, 115, :_reduce_147, + 1, 161, :_reduce_148, + 3, 161, :_reduce_149, + 1, 163, :_reduce_150, + 1, 163, :_reduce_151, + 1, 163, :_reduce_152, + 1, 163, :_reduce_none, + 1, 164, :_reduce_154, + 3, 164, :_reduce_155, 1, 162, :_reduce_none, - 1, 163, :_reduce_153, - 3, 163, :_reduce_154, - 1, 161, :_reduce_none, - 2, 161, :_reduce_156, - 1, 116, :_reduce_157, - 1, 154, :_reduce_158, - 1, 154, :_reduce_159, + 2, 162, :_reduce_157, + 1, 117, :_reduce_158, + 1, 155, :_reduce_159, 1, 155, :_reduce_160, - 2, 155, :_reduce_161, - 4, 155, :_reduce_162, - 1, 134, :_reduce_163, - 3, 134, :_reduce_164, - 3, 164, :_reduce_165, - 1, 164, :_reduce_166, - 1, 106, :_reduce_167, - 3, 117, :_reduce_168, - 4, 117, :_reduce_169, - 2, 117, :_reduce_170, - 3, 117, :_reduce_171, - 4, 117, :_reduce_172, - 2, 117, :_reduce_173, - 3, 120, :_reduce_174, - 4, 120, :_reduce_175, - 2, 120, :_reduce_176, - 1, 165, :_reduce_177, - 3, 165, :_reduce_178, + 1, 156, :_reduce_161, + 2, 156, :_reduce_162, + 4, 156, :_reduce_163, + 1, 135, :_reduce_164, + 3, 135, :_reduce_165, + 3, 165, :_reduce_166, + 1, 165, :_reduce_167, + 1, 107, :_reduce_168, + 3, 118, :_reduce_169, + 4, 118, :_reduce_170, + 2, 118, :_reduce_171, + 3, 118, :_reduce_172, + 4, 118, :_reduce_173, + 2, 118, :_reduce_174, + 3, 121, :_reduce_175, + 4, 121, :_reduce_176, + 2, 121, :_reduce_177, + 1, 166, :_reduce_178, 3, 166, :_reduce_179, - 1, 127, :_reduce_none, - 1, 127, :_reduce_none, - 1, 127, :_reduce_none, - 1, 167, :_reduce_183, - 2, 168, :_reduce_184, - 1, 170, :_reduce_185, - 1, 172, :_reduce_186, + 3, 167, :_reduce_180, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 1, 128, :_reduce_none, + 1, 168, :_reduce_184, + 2, 169, :_reduce_185, + 1, 171, :_reduce_186, 1, 173, :_reduce_187, - 2, 171, :_reduce_188, - 1, 174, :_reduce_189, + 1, 174, :_reduce_188, + 2, 172, :_reduce_189, 1, 175, :_reduce_190, - 2, 175, :_reduce_191, - 2, 169, :_reduce_192, - 2, 176, :_reduce_193, - 2, 176, :_reduce_194, - 3, 92, :_reduce_195, - 0, 177, :_reduce_196, - 2, 177, :_reduce_197, - 4, 177, :_reduce_198, - 1, 115, :_reduce_199, - 3, 115, :_reduce_200, - 5, 115, :_reduce_201, - 1, 178, :_reduce_none, - 1, 178, :_reduce_none, - 1, 123, :_reduce_204, - 1, 126, :_reduce_205, - 1, 124, :_reduce_206, + 1, 176, :_reduce_191, + 2, 176, :_reduce_192, + 2, 170, :_reduce_193, + 2, 177, :_reduce_194, + 2, 177, :_reduce_195, + 3, 93, :_reduce_196, + 0, 178, :_reduce_197, + 2, 178, :_reduce_198, + 4, 178, :_reduce_199, + 1, 116, :_reduce_200, + 3, 116, :_reduce_201, + 5, 116, :_reduce_202, + 1, 179, :_reduce_none, + 1, 179, :_reduce_none, + 1, 124, :_reduce_205, + 1, 127, :_reduce_206, 1, 125, :_reduce_207, - 1, 119, :_reduce_208, - 1, 118, :_reduce_209, - 1, 121, :_reduce_210, - 0, 128, :_reduce_none, - 1, 128, :_reduce_212, - 0, 145, :_reduce_none, - 1, 145, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 1, 153, :_reduce_none, - 0, 93, :_reduce_229 ] - -racc_reduce_n = 230 - -racc_shift_n = 402 + 1, 126, :_reduce_208, + 1, 120, :_reduce_209, + 1, 119, :_reduce_210, + 1, 122, :_reduce_211, + 0, 129, :_reduce_none, + 1, 129, :_reduce_213, + 0, 146, :_reduce_none, + 1, 146, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 1, 154, :_reduce_none, + 0, 94, :_reduce_230 ] + +racc_reduce_n = 231 + +racc_shift_n = 404 racc_token_table = { false => 0, :error => 1, :STRING => 2, :DQPRE => 3, :DQMID => 4, :DQPOST => 5, :LBRACK => 6, :RBRACK => 7, :LBRACE => 8, :RBRACE => 9, :SYMBOL => 10, :FARROW => 11, :COMMA => 12, :TRUE => 13, :FALSE => 14, :EQUALS => 15, :APPENDS => 16, :DELETES => 17, :LESSEQUAL => 18, :NOTEQUAL => 19, :DOT => 20, :COLON => 21, :LLCOLLECT => 22, :RRCOLLECT => 23, :QMARK => 24, :LPAREN => 25, :RPAREN => 26, :ISEQUAL => 27, :GREATEREQUAL => 28, :GREATERTHAN => 29, :LESSTHAN => 30, :IF => 31, :ELSE => 32, :DEFINE => 33, :ELSIF => 34, :VARIABLE => 35, :CLASS => 36, :INHERITS => 37, :NODE => 38, :BOOLEAN => 39, :NAME => 40, :SEMIC => 41, :CASE => 42, :DEFAULT => 43, :AT => 44, :ATAT => 45, :LCOLLECT => 46, :RCOLLECT => 47, :CLASSREF => 48, :NOT => 49, :OR => 50, :AND => 51, :UNDEF => 52, :PARROW => 53, :PLUS => 54, :MINUS => 55, :TIMES => 56, :DIV => 57, :LSHIFT => 58, :RSHIFT => 59, :UMINUS => 60, :MATCH => 61, :NOMATCH => 62, :REGEX => 63, :IN_EDGE => 64, :OUT_EDGE => 65, :IN_EDGE_SUB => 66, :OUT_EDGE_SUB => 67, :IN => 68, :UNLESS => 69, :PIPE => 70, :LAMBDA => 71, :SELBRACE => 72, :NUMBER => 73, :HEREDOC => 74, :SUBLOCATE => 75, :RENDER_STRING => 76, :RENDER_EXPR => 77, :EPP_START => 78, :EPP_END => 79, :EPP_END_TRIM => 80, :FUNCTION => 81, :LOW => 82, :HIGH => 83, :CALL => 84, :LISTSTART => 85, - :MODULO => 86, - :TITLE_COLON => 87, - :CASE_COLON => 88 } + :SPLAT => 86, + :MODULO => 87, + :TITLE_COLON => 88, + :CASE_COLON => 89 } -racc_nt_base = 89 +racc_nt_base = 90 racc_use_result_var = true Racc_arg = [ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ] Racc_token_to_s_table = [ "$end", "error", "STRING", "DQPRE", "DQMID", "DQPOST", "LBRACK", "RBRACK", "LBRACE", "RBRACE", "SYMBOL", "FARROW", "COMMA", "TRUE", "FALSE", "EQUALS", "APPENDS", "DELETES", "LESSEQUAL", "NOTEQUAL", "DOT", "COLON", "LLCOLLECT", "RRCOLLECT", "QMARK", "LPAREN", "RPAREN", "ISEQUAL", "GREATEREQUAL", "GREATERTHAN", "LESSTHAN", "IF", "ELSE", "DEFINE", "ELSIF", "VARIABLE", "CLASS", "INHERITS", "NODE", "BOOLEAN", "NAME", "SEMIC", "CASE", "DEFAULT", "AT", "ATAT", "LCOLLECT", "RCOLLECT", "CLASSREF", "NOT", "OR", "AND", "UNDEF", "PARROW", "PLUS", "MINUS", "TIMES", "DIV", "LSHIFT", "RSHIFT", "UMINUS", "MATCH", "NOMATCH", "REGEX", "IN_EDGE", "OUT_EDGE", "IN_EDGE_SUB", "OUT_EDGE_SUB", "IN", "UNLESS", "PIPE", "LAMBDA", "SELBRACE", "NUMBER", "HEREDOC", "SUBLOCATE", "RENDER_STRING", "RENDER_EXPR", "EPP_START", "EPP_END", "EPP_END_TRIM", "FUNCTION", "LOW", "HIGH", "CALL", "LISTSTART", + "SPLAT", "MODULO", "TITLE_COLON", "CASE_COLON", "$start", "program", "statements", "epp_expression", "nil", "syntactic_statements", "syntactic_statement", "any_expression", "relationship_expression", "resource_expression", "expression", "higher_precedence", "expressions", "selector_entries", "call_function_expression", "primary_expression", "literal_expression", "variable", "call_method_with_lambda_expression", "collection_expression", "case_expression", "if_expression", "unless_expression", "definition_expression", "hostclass_expression", "node_definition_expression", "epp_render_expression", "function_definition", "array", "boolean", "default", "hash", "regex", "text_or_name", "number", "type", "undef", "name", "quotedtext", "endcomma", "lambda", "call_method_expression", "named_access", "lambda_parameter_list", "lambda_rest", "parameters", "if_part", "else", "unless_else", "case_options", "case_option", "case_colon", "selector_entry", "selector_entry_list", "at", "resourceinstances", "endsemi", "attribute_operations", "resourceinst", "title_colon", "collect_query", "optional_query", "attribute_operation", "attribute_name", "keyword", "classname", "parameter_list", "opt_statements", "stacked_classname", "classparent", "classnameordefault", "hostnames", "nodeparent", "hostname", "dotted_name", "parameter", "hashpairs", "hashpair", "string", "dq_string", "heredoc", "dqpre", "dqrval", "dqpost", "dqmid", "text_expression", "dqtail", "sublocated_text", "epp_parameters_list", "epp_end" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted -module_eval(<<'.,.,', 'egrammar.ra', 65) +module_eval(<<'.,.,', 'egrammar.ra', 66) def _reduce_1(val, _values, result) result = create_program(Factory.block_or_expression(*val[0])) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 66) +module_eval(<<'.,.,', 'egrammar.ra', 67) def _reduce_2(val, _values, result) result = create_program(Factory.block_or_expression(*val[0])) result end .,., # reduce 3 omitted -module_eval(<<'.,.,', 'egrammar.ra', 71) +module_eval(<<'.,.,', 'egrammar.ra', 72) def _reduce_4(val, _values, result) result = transform_calls(val[0]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 77) +module_eval(<<'.,.,', 'egrammar.ra', 78) def _reduce_5(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 78) +module_eval(<<'.,.,', 'egrammar.ra', 79) def _reduce_6(val, _values, result) result = val[0].push val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 79) +module_eval(<<'.,.,', 'egrammar.ra', 80) def _reduce_7(val, _values, result) result = val[0].push val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 83) +module_eval(<<'.,.,', 'egrammar.ra', 84) def _reduce_8(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 84) +module_eval(<<'.,.,', 'egrammar.ra', 85) def _reduce_9(val, _values, result) result = aryfy(val[0]).push val[2] result end .,., # reduce 10 omitted -module_eval(<<'.,.,', 'egrammar.ra', 90) +module_eval(<<'.,.,', 'egrammar.ra', 91) def _reduce_11(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 91) +module_eval(<<'.,.,', 'egrammar.ra', 92) def _reduce_12(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 92) +module_eval(<<'.,.,', 'egrammar.ra', 93) def _reduce_13(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 93) +module_eval(<<'.,.,', 'egrammar.ra', 94) def _reduce_14(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 94) +module_eval(<<'.,.,', 'egrammar.ra', 95) def _reduce_15(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., # reduce 16 omitted -module_eval(<<'.,.,', 'egrammar.ra', 101) +module_eval(<<'.,.,', 'egrammar.ra', 102) def _reduce_17(val, _values, result) result = val[0][*val[2]] ; loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 102) +module_eval(<<'.,.,', 'egrammar.ra', 103) def _reduce_18(val, _values, result) result = val[0].in val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 103) +module_eval(<<'.,.,', 'egrammar.ra', 104) def _reduce_19(val, _values, result) result = val[0] =~ val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 104) +module_eval(<<'.,.,', 'egrammar.ra', 105) def _reduce_20(val, _values, result) result = val[0].mne val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 105) +module_eval(<<'.,.,', 'egrammar.ra', 106) def _reduce_21(val, _values, result) result = val[0] + val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 106) +module_eval(<<'.,.,', 'egrammar.ra', 107) def _reduce_22(val, _values, result) result = val[0] - val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 107) +module_eval(<<'.,.,', 'egrammar.ra', 108) def _reduce_23(val, _values, result) result = val[0] / val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 108) +module_eval(<<'.,.,', 'egrammar.ra', 109) def _reduce_24(val, _values, result) result = val[0] * val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 109) +module_eval(<<'.,.,', 'egrammar.ra', 110) def _reduce_25(val, _values, result) result = val[0] % val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 110) +module_eval(<<'.,.,', 'egrammar.ra', 111) def _reduce_26(val, _values, result) result = val[0] << val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 111) +module_eval(<<'.,.,', 'egrammar.ra', 112) def _reduce_27(val, _values, result) result = val[0] >> val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 112) +module_eval(<<'.,.,', 'egrammar.ra', 113) def _reduce_28(val, _values, result) result = val[1].minus() ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 113) +module_eval(<<'.,.,', 'egrammar.ra', 114) def _reduce_29(val, _values, result) - result = val[0].ne val[2] ; loc result, val[1] + result = val[1].unfold() ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 114) +module_eval(<<'.,.,', 'egrammar.ra', 115) def _reduce_30(val, _values, result) - result = val[0] == val[2] ; loc result, val[1] + result = val[0].ne val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 115) +module_eval(<<'.,.,', 'egrammar.ra', 116) def _reduce_31(val, _values, result) - result = val[0] > val[2] ; loc result, val[1] + result = val[0] == val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 116) +module_eval(<<'.,.,', 'egrammar.ra', 117) def _reduce_32(val, _values, result) - result = val[0] >= val[2] ; loc result, val[1] + result = val[0] > val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 117) +module_eval(<<'.,.,', 'egrammar.ra', 118) def _reduce_33(val, _values, result) - result = val[0] < val[2] ; loc result, val[1] + result = val[0] >= val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 118) +module_eval(<<'.,.,', 'egrammar.ra', 119) def _reduce_34(val, _values, result) - result = val[0] <= val[2] ; loc result, val[1] + result = val[0] < val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 119) +module_eval(<<'.,.,', 'egrammar.ra', 120) def _reduce_35(val, _values, result) - result = val[1].not ; loc result, val[0] + result = val[0] <= val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 120) +module_eval(<<'.,.,', 'egrammar.ra', 121) def _reduce_36(val, _values, result) - result = val[0].and val[2] ; loc result, val[1] + result = val[1].not ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 121) +module_eval(<<'.,.,', 'egrammar.ra', 122) def _reduce_37(val, _values, result) - result = val[0].or val[2] ; loc result, val[1] + result = val[0].and val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 122) +module_eval(<<'.,.,', 'egrammar.ra', 123) def _reduce_38(val, _values, result) - result = val[0].set(val[2]) ; loc result, val[1] + result = val[0].or val[2] ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 123) +module_eval(<<'.,.,', 'egrammar.ra', 124) def _reduce_39(val, _values, result) - result = val[0].plus_set(val[2]) ; loc result, val[1] + result = val[0].set(val[2]) ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 124) +module_eval(<<'.,.,', 'egrammar.ra', 125) def _reduce_40(val, _values, result) - result = val[0].minus_set(val[2]); loc result, val[1] + result = val[0].plus_set(val[2]) ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 125) +module_eval(<<'.,.,', 'egrammar.ra', 126) def _reduce_41(val, _values, result) - result = val[0].select(*val[2]) ; loc result, val[0] + result = val[0].minus_set(val[2]); loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 126) +module_eval(<<'.,.,', 'egrammar.ra', 127) def _reduce_42(val, _values, result) - result = val[1].paren() ; loc result, val[0] + result = val[0].select(*val[2]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 134) +module_eval(<<'.,.,', 'egrammar.ra', 128) def _reduce_43(val, _values, result) - result = [val[0]] + result = val[1].paren() ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 135) +module_eval(<<'.,.,', 'egrammar.ra', 136) def _reduce_44(val, _values, result) - result = val[0].push(val[2]) + result = [val[0]] result end .,., -# reduce 45 omitted +module_eval(<<'.,.,', 'egrammar.ra', 137) + def _reduce_45(val, _values, result) + result = val[0].push(val[2]) + result + end +.,., # reduce 46 omitted # reduce 47 omitted # reduce 48 omitted # reduce 49 omitted # reduce 50 omitted # reduce 51 omitted # reduce 52 omitted # reduce 53 omitted # reduce 54 omitted # reduce 55 omitted # reduce 56 omitted # reduce 57 omitted # reduce 58 omitted # reduce 59 omitted # reduce 60 omitted # reduce 61 omitted # reduce 62 omitted # reduce 63 omitted # reduce 64 omitted # reduce 65 omitted # reduce 66 omitted -module_eval(<<'.,.,', 'egrammar.ra', 168) - def _reduce_67(val, _values, result) +# reduce 67 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 170) + def _reduce_68(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 169) - def _reduce_68(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 171) + def _reduce_69(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 177) - def _reduce_69(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 179) + def _reduce_70(val, _values, result) result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 181) - def _reduce_70(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 183) + def _reduce_71(val, _values, result) result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 185) - def _reduce_71(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 187) + def _reduce_72(val, _values, result) result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] result.lambda = val[5] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 190) - def _reduce_72(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 192) + def _reduce_73(val, _values, result) result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] result.lambda = val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 194) - def _reduce_73(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 196) + def _reduce_74(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 199) - def _reduce_74(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 201) + def _reduce_75(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 200) - def _reduce_75(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 202) + def _reduce_76(val, _values, result) result = val[0]; val[0].lambda = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 203) - def _reduce_76(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 205) + def _reduce_77(val, _values, result) result = Factory.CALL_METHOD(val[0], val[2]); loc result, val[1], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 204) - def _reduce_77(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 206) + def _reduce_78(val, _values, result) result = Factory.CALL_METHOD(val[0], []); loc result, val[1], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 205) - def _reduce_78(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 207) + def _reduce_79(val, _values, result) result = Factory.CALL_METHOD(val[0], []); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 210) - def _reduce_79(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 212) + def _reduce_80(val, _values, result) result = val[0].dot(Factory.fqn(val[2][:value])) loc result, val[1], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 222) - def _reduce_80(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 224) + def _reduce_81(val, _values, result) result = Factory.LAMBDA(val[0], val[1]) # loc result, val[1] # TODO result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 227) - def _reduce_81(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 229) + def _reduce_82(val, _values, result) result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 228) - def _reduce_82(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 230) + def _reduce_83(val, _values, result) result = nil result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 232) - def _reduce_83(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 234) + def _reduce_84(val, _values, result) result = [] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 233) - def _reduce_84(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 235) + def _reduce_85(val, _values, result) result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 243) - def _reduce_85(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 245) + def _reduce_86(val, _values, result) result = val[1] loc(result, val[0], val[1]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 250) - def _reduce_86(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 252) + def _reduce_87(val, _values, result) result = Factory.IF(val[0], Factory.block_or_expression(*val[2]), val[4]) loc(result, val[0], (val[4] ? val[4] : val[3])) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 254) - def _reduce_87(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 256) + def _reduce_88(val, _values, result) result = Factory.IF(val[0], nil, val[3]) loc(result, val[0], (val[3] ? val[3] : val[2])) result end .,., -# reduce 88 omitted +# reduce 89 omitted -module_eval(<<'.,.,', 'egrammar.ra', 262) - def _reduce_89(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 264) + def _reduce_90(val, _values, result) result = val[1] loc(result, val[0], val[1]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 266) - def _reduce_90(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 268) + def _reduce_91(val, _values, result) result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 270) - def _reduce_91(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 272) + def _reduce_92(val, _values, result) result = nil # don't think a nop is needed here either result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 279) - def _reduce_92(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 281) + def _reduce_93(val, _values, result) result = Factory.UNLESS(val[1], Factory.block_or_expression(*val[3]), val[5]) loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 283) - def _reduce_93(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 285) + def _reduce_94(val, _values, result) result = Factory.UNLESS(val[1], nil, nil) loc result, val[0], val[4] result end .,., -# reduce 94 omitted +# reduce 95 omitted -module_eval(<<'.,.,', 'egrammar.ra', 293) - def _reduce_95(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 295) + def _reduce_96(val, _values, result) result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 297) - def _reduce_96(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 299) + def _reduce_97(val, _values, result) result = nil # don't think a nop is needed here either result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 305) - def _reduce_97(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 307) + def _reduce_98(val, _values, result) result = Factory.CASE(val[1], *val[3]) loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 311) - def _reduce_98(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 313) + def _reduce_99(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 312) - def _reduce_99(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 314) + def _reduce_100(val, _values, result) result = val[0].push val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 317) - def _reduce_100(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 319) + def _reduce_101(val, _values, result) result = Factory.WHEN(val[0], val[3]) loc result, val[1], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 321) - def _reduce_101(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 323) + def _reduce_102(val, _values, result) result = Factory.WHEN(val[0], nil) loc result, val[1], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 325) - def _reduce_102(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 327) + def _reduce_103(val, _values, result) result = val[0] result end .,., -# reduce 103 omitted +# reduce 104 omitted -module_eval(<<'.,.,', 'egrammar.ra', 336) - def _reduce_104(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 338) + def _reduce_105(val, _values, result) result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 341) - def _reduce_105(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 343) + def _reduce_106(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 342) - def _reduce_106(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 344) + def _reduce_107(val, _values, result) result = val[0].push val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 347) - def _reduce_107(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 349) + def _reduce_108(val, _values, result) result = Factory.MAP(val[0], val[2]) ; loc result, val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 359) - def _reduce_108(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 361) + def _reduce_109(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 362) - def _reduce_109(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 364) + def _reduce_110(val, _values, result) result = case Factory.resource_shape(val[1]) when :resource, :class tmp = Factory.RESOURCE(Factory.fqn(token_text(val[1])), val[3]) tmp.form = val[0] tmp when :defaults error val[1], "A resource default can not be virtual or exported" when :override error val[1], "A resource override can not be virtual or exported" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[1], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 377) - def _reduce_110(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 379) + def _reduce_111(val, _values, result) result = case Factory.resource_shape(val[1]) when :resource, :class, :defaults, :override error val[1], "Defaults are not virtualizable" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 385) - def _reduce_111(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 387) + def _reduce_112(val, _values, result) result = case Factory.resource_shape(val[0]) when :resource, :class Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2]) when :defaults error val[1], "A resource default can not specify a resource name" when :override error val[1], "A resource override does not allow override of name of resource" else error val[1], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 398) - def _reduce_112(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 400) + def _reduce_113(val, _values, result) result = case Factory.resource_shape(val[0]) when :resource, :class # This catches deprecated syntax. # If the attribute operations does not include +>, then the found expression # is actually a LEFT followed by LITERAL_HASH # unless tmp = transform_resource_wo_title(val[0], val[2]) error val[1], "Syntax error resource body without title or hash with +>" end tmp when :defaults Factory.RESOURCE_DEFAULTS(val[0], val[2]) when :override # This was only done for override in original - TODO shuld it be here at all Factory.RESOURCE_OVERRIDE(val[0], val[2]) else error val[0], "Expression is not valid as a resource, resource-default, or resource-override" end loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 419) - def _reduce_113(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 421) + def _reduce_114(val, _values, result) result = Factory.RESOURCE(Factory.fqn(token_text(val[1])), val[3]) result.form = val[0] loc result, val[1], val[5] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 424) - def _reduce_114(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 426) + def _reduce_115(val, _values, result) result = Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2]) loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 429) - def _reduce_115(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 431) + def _reduce_116(val, _values, result) result = Factory.RESOURCE_BODY(val[0], val[2]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 431) - def _reduce_116(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 433) + def _reduce_117(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 434) - def _reduce_117(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 436) + def _reduce_118(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 435) - def _reduce_118(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 437) + def _reduce_119(val, _values, result) result = val[0].push val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 440) - def _reduce_119(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 442) + def _reduce_120(val, _values, result) result = :virtual result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 441) - def _reduce_120(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 443) + def _reduce_121(val, _values, result) result = :exported result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 442) - def _reduce_121(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 444) + def _reduce_122(val, _values, result) result = :exported result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 454) - def _reduce_122(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 456) + def _reduce_123(val, _values, result) result = Factory.COLLECT(val[0], val[1], val[3]) loc result, val[0], val[5] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 458) - def _reduce_123(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 460) + def _reduce_124(val, _values, result) result = Factory.COLLECT(val[0], val[1], []) loc result, val[0], val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 463) - def _reduce_124(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 465) + def _reduce_125(val, _values, result) result = Factory.VIRTUAL_QUERY(val[1]) ; loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 464) - def _reduce_125(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 466) + def _reduce_126(val, _values, result) result = Factory.EXPORTED_QUERY(val[1]) ; loc result, val[0], val[2] result end .,., -# reduce 126 omitted - # reduce 127 omitted -module_eval(<<'.,.,', 'egrammar.ra', 477) - def _reduce_128(val, _values, result) +# reduce 128 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 479) + def _reduce_129(val, _values, result) result = [] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 478) - def _reduce_129(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 480) + def _reduce_130(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 479) - def _reduce_130(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 481) + def _reduce_131(val, _values, result) result = val[0].push(val[2]) result end .,., -# reduce 131 omitted - # reduce 132 omitted # reduce 133 omitted -module_eval(<<'.,.,', 'egrammar.ra', 495) - def _reduce_134(val, _values, result) +# reduce 134 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 497) + def _reduce_135(val, _values, result) result = Factory.ATTRIBUTE_OP(val[0][:value], :'=>', val[2]) loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 499) - def _reduce_135(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 501) + def _reduce_136(val, _values, result) result = Factory.ATTRIBUTE_OP(val[0][:value], :'+>', val[2]) loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 509) - def _reduce_136(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 511) + def _reduce_137(val, _values, result) result = add_definition(Factory.DEFINITION(classname(val[1][:value]), val[2], val[4])) loc result, val[0], val[5] # New lexer does not keep track of this, this is done in validation if @lexer.respond_to?(:'indefine=') @lexer.indefine = false end result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 523) - def _reduce_137(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 525) + def _reduce_138(val, _values, result) # Remove this class' name from the namestack as all nested classes have been parsed namepop result = add_definition(Factory.HOSTCLASS(classname(val[1][:value]), val[2], token_text(val[3]), val[5])) loc result, val[0], val[6] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 533) - def _reduce_138(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 535) + def _reduce_139(val, _values, result) namestack(val[0][:value]) ; result = val[0] result end .,., -# reduce 139 omitted - # reduce 140 omitted # reduce 141 omitted -module_eval(<<'.,.,', 'egrammar.ra', 542) - def _reduce_142(val, _values, result) +# reduce 142 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 544) + def _reduce_143(val, _values, result) result = val[1] result end .,., -# reduce 143 omitted - # reduce 144 omitted -module_eval(<<'.,.,', 'egrammar.ra', 559) - def _reduce_145(val, _values, result) +# reduce 145 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 561) + def _reduce_146(val, _values, result) result = add_definition(Factory.NODE(val[1], val[2], val[4])) loc result, val[0], val[5] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 563) - def _reduce_146(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 565) + def _reduce_147(val, _values, result) result = add_definition(Factory.NODE(val[1], val[2], nil)) loc result, val[0], val[4] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 573) - def _reduce_147(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 575) + def _reduce_148(val, _values, result) result = [result] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 574) - def _reduce_148(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 576) + def _reduce_149(val, _values, result) result = val[0].push(val[2]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 579) - def _reduce_149(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 581) + def _reduce_150(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 580) - def _reduce_150(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 582) + def _reduce_151(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 581) - def _reduce_151(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 583) + def _reduce_152(val, _values, result) result = Factory.literal(:default); loc result, val[0] result end .,., -# reduce 152 omitted +# reduce 153 omitted -module_eval(<<'.,.,', 'egrammar.ra', 585) - def _reduce_153(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 587) + def _reduce_154(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 586) - def _reduce_154(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 588) + def _reduce_155(val, _values, result) result = Factory.concat(val[0], '.', val[2][:value]); loc result, val[0], val[2] result end .,., -# reduce 155 omitted +# reduce 156 omitted -module_eval(<<'.,.,', 'egrammar.ra', 591) - def _reduce_156(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 593) + def _reduce_157(val, _values, result) result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 596) - def _reduce_157(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 598) + def _reduce_158(val, _values, result) result = Factory.QNAME(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 608) - def _reduce_158(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 610) + def _reduce_159(val, _values, result) result = val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 609) - def _reduce_159(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 611) + def _reduce_160(val, _values, result) error val[0], "'class' is not a valid classname" result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 613) - def _reduce_160(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 615) + def _reduce_161(val, _values, result) result = [] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 614) - def _reduce_161(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 616) + def _reduce_162(val, _values, result) result = [] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 615) - def _reduce_162(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 617) + def _reduce_163(val, _values, result) result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 619) - def _reduce_163(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 621) + def _reduce_164(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 620) - def _reduce_164(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 622) + def _reduce_165(val, _values, result) result = val[0].push(val[2]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 624) - def _reduce_165(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 626) + def _reduce_166(val, _values, result) result = Factory.PARAM(val[0][:value], val[2]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 625) - def _reduce_166(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 627) + def _reduce_167(val, _values, result) result = Factory.PARAM(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 638) - def _reduce_167(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 640) + def _reduce_168(val, _values, result) result = Factory.fqn(val[0][:value]).var ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 644) - def _reduce_168(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 646) + def _reduce_169(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 645) - def _reduce_169(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 647) + def _reduce_170(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 646) - def _reduce_170(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 648) + def _reduce_171(val, _values, result) result = Factory.literal([]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 647) - def _reduce_171(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 649) + def _reduce_172(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 648) - def _reduce_172(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 650) + def _reduce_173(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 649) - def _reduce_173(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 651) + def _reduce_174(val, _values, result) result = Factory.literal([]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 652) - def _reduce_174(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 654) + def _reduce_175(val, _values, result) result = Factory.HASH(val[1]); loc result, val[0], val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 653) - def _reduce_175(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 655) + def _reduce_176(val, _values, result) result = Factory.HASH(val[1]); loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 654) - def _reduce_176(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 656) + def _reduce_177(val, _values, result) result = Factory.literal({}) ; loc result, val[0], val[3] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 657) - def _reduce_177(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 659) + def _reduce_178(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 658) - def _reduce_178(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 660) + def _reduce_179(val, _values, result) result = val[0].push val[2] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 661) - def _reduce_179(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 663) + def _reduce_180(val, _values, result) result = Factory.KEY_ENTRY(val[0], val[2]); loc result, val[1] result end .,., -# reduce 180 omitted - # reduce 181 omitted # reduce 182 omitted -module_eval(<<'.,.,', 'egrammar.ra', 668) - def _reduce_183(val, _values, result) - result = Factory.literal(val[0][:value]) ; loc result, val[0] - result - end -.,., +# reduce 183 omitted -module_eval(<<'.,.,', 'egrammar.ra', 669) +module_eval(<<'.,.,', 'egrammar.ra', 670) def _reduce_184(val, _values, result) - result = Factory.string(val[0], *val[1]) ; loc result, val[0], val[1][-1] + result = Factory.literal(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 670) +module_eval(<<'.,.,', 'egrammar.ra', 671) def _reduce_185(val, _values, result) - result = Factory.literal(val[0][:value]); loc result, val[0] + result = Factory.string(val[0], *val[1]) ; loc result, val[0], val[1][-1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 671) +module_eval(<<'.,.,', 'egrammar.ra', 672) def _reduce_186(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 672) +module_eval(<<'.,.,', 'egrammar.ra', 673) def _reduce_187(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 673) +module_eval(<<'.,.,', 'egrammar.ra', 674) def _reduce_188(val, _values, result) - result = [val[0]] + val[1] + result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 674) +module_eval(<<'.,.,', 'egrammar.ra', 675) def _reduce_189(val, _values, result) - result = Factory.TEXT(val[0]) + result = [val[0]] + val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 677) +module_eval(<<'.,.,', 'egrammar.ra', 676) def _reduce_190(val, _values, result) - result = [val[0]] + result = Factory.TEXT(val[0]) result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 678) +module_eval(<<'.,.,', 'egrammar.ra', 679) def _reduce_191(val, _values, result) - result = [val[0]] + val[1] + result = [val[0]] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 681) +module_eval(<<'.,.,', 'egrammar.ra', 680) def _reduce_192(val, _values, result) - result = Factory.HEREDOC(val[0][:value], val[1]); loc result, val[0] + result = [val[0]] + val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 684) +module_eval(<<'.,.,', 'egrammar.ra', 683) def _reduce_193(val, _values, result) - result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] + result = Factory.HEREDOC(val[0][:value], val[1]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 685) +module_eval(<<'.,.,', 'egrammar.ra', 686) def _reduce_194(val, _values, result) result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 688) +module_eval(<<'.,.,', 'egrammar.ra', 687) def _reduce_195(val, _values, result) - result = Factory.EPP(val[1], val[2]); loc result, val[0] + result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 691) +module_eval(<<'.,.,', 'egrammar.ra', 690) def _reduce_196(val, _values, result) - result = nil + result = Factory.EPP(val[1], val[2]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 692) +module_eval(<<'.,.,', 'egrammar.ra', 693) def _reduce_197(val, _values, result) - result = [] + result = nil result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 693) +module_eval(<<'.,.,', 'egrammar.ra', 694) def _reduce_198(val, _values, result) - result = val[1] + result = [] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 696) +module_eval(<<'.,.,', 'egrammar.ra', 695) def _reduce_199(val, _values, result) - result = Factory.RENDER_STRING(val[0][:value]); loc result, val[0] + result = val[1] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 697) +module_eval(<<'.,.,', 'egrammar.ra', 698) def _reduce_200(val, _values, result) - result = Factory.RENDER_EXPR(val[1]); loc result, val[0], val[2] + result = Factory.RENDER_STRING(val[0][:value]); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 698) +module_eval(<<'.,.,', 'egrammar.ra', 699) def _reduce_201(val, _values, result) - result = Factory.RENDER_EXPR(Factory.block_or_expression(*val[2])); loc result, val[0], val[4] + result = Factory.RENDER_EXPR(val[1]); loc result, val[0], val[2] result end .,., -# reduce 202 omitted +module_eval(<<'.,.,', 'egrammar.ra', 700) + def _reduce_202(val, _values, result) + result = Factory.RENDER_EXPR(Factory.block_or_expression(*val[2])); loc result, val[0], val[4] + result + end +.,., # reduce 203 omitted -module_eval(<<'.,.,', 'egrammar.ra', 704) - def _reduce_204(val, _values, result) +# reduce 204 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 706) + def _reduce_205(val, _values, result) result = Factory.NUMBER(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 705) - def _reduce_205(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 707) + def _reduce_206(val, _values, result) result = Factory.QNAME_OR_NUMBER(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 706) - def _reduce_206(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 708) + def _reduce_207(val, _values, result) result = Factory.QREF(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 707) - def _reduce_207(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 709) + def _reduce_208(val, _values, result) result = Factory.literal(:undef); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 708) - def _reduce_208(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 710) + def _reduce_209(val, _values, result) result = Factory.literal(:default); loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 713) - def _reduce_209(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 715) + def _reduce_210(val, _values, result) result = Factory.literal(val[0][:value]) ; loc result, val[0] result end .,., -module_eval(<<'.,.,', 'egrammar.ra', 716) - def _reduce_210(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 718) + def _reduce_211(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., -# reduce 211 omitted +# reduce 212 omitted -module_eval(<<'.,.,', 'egrammar.ra', 722) - def _reduce_212(val, _values, result) +module_eval(<<'.,.,', 'egrammar.ra', 724) + def _reduce_213(val, _values, result) result = nil result end .,., -# reduce 213 omitted - # reduce 214 omitted # reduce 215 omitted # reduce 216 omitted # reduce 217 omitted # reduce 218 omitted # reduce 219 omitted # reduce 220 omitted # reduce 221 omitted # reduce 222 omitted # reduce 223 omitted # reduce 224 omitted # reduce 225 omitted # reduce 226 omitted # reduce 227 omitted # reduce 228 omitted -module_eval(<<'.,.,', 'egrammar.ra', 745) - def _reduce_229(val, _values, result) +# reduce 229 omitted + +module_eval(<<'.,.,', 'egrammar.ra', 747) + def _reduce_230(val, _values, result) result = nil result end .,., def _reduce_none(val, _values, result) val[0] end end # class Parser end # module Parser end # module Pops end # module Puppet diff --git a/spec/unit/pops/evaluator/evaluating_parser_spec.rb b/spec/unit/pops/evaluator/evaluating_parser_spec.rb index ff68ae893..e7b41848e 100644 --- a/spec/unit/pops/evaluator/evaluating_parser_spec.rb +++ b/spec/unit/pops/evaluator/evaluating_parser_spec.rb @@ -1,1070 +1,1092 @@ require 'spec_helper' require 'puppet/pops' require 'puppet/pops/evaluator/evaluator_impl' require 'puppet_spec/pops' require 'puppet_spec/scope' require 'puppet/parser/e4_parser_adapter' # relative to this spec file (./) does not work as this file is loaded by rspec #require File.join(File.dirname(__FILE__), '/evaluator_rspec_helper') describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do include PuppetSpec::Pops include PuppetSpec::Scope before(:each) do Puppet[:strict_variables] = true # These must be set since the is 3x logic that triggers on these even if the tests are explicit # about selection of parser and evaluator # Puppet[:parser] = 'future' Puppet[:evaluator] = 'future' # Puppetx cannot be loaded until the correct parser has been set (injector is turned off otherwise) require 'puppetx' end let(:parser) { Puppet::Pops::Parser::EvaluatingParser::Transitional.new } let(:node) { 'node.example.com' } let(:scope) { s = create_test_scope_for_node(node); s } types = Puppet::Pops::Types::TypeFactory context "When evaluator evaluates literals" do { "1" => 1, "010" => 8, "0x10" => 16, "3.14" => 3.14, "0.314e1" => 3.14, "31.4e-1" => 3.14, "'1'" => '1', "'banana'" => 'banana', '"banana"' => 'banana', "banana" => 'banana', "banana::split" => 'banana::split', "false" => false, "true" => true, "Array" => types.array_of_data(), "/.*/" => /.*/ }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end end context "When the evaluator evaluates Lists and Hashes" do { "[]" => [], "[1,2,3]" => [1,2,3], "[1,[2.0, 2.1, [2.2]],[3.0, 3.1]]" => [1,[2.0, 2.1, [2.2]],[3.0, 3.1]], "[2 + 2]" => [4], "[1,2,3] == [1,2,3]" => true, "[1,2,3] != [2,3,4]" => true, "[1,2,3] == [2,2,3]" => false, "[1,2,3] != [1,2,3]" => false, "[1,2,3][2]" => 3, "[1,2,3] + [4,5]" => [1,2,3,4,5], "[1,2,3] + [[4,5]]" => [1,2,3,[4,5]], "[1,2,3] + 4" => [1,2,3,4], "[1,2,3] << [4,5]" => [1,2,3,[4,5]], "[1,2,3] << {'a' => 1, 'b'=>2}" => [1,2,3,{'a' => 1, 'b'=>2}], "[1,2,3] << 4" => [1,2,3,4], "[1,2,3,4] - [2,3]" => [1,4], "[1,2,3,4] - [2,5]" => [1,3,4], "[1,2,3,4] - 2" => [1,3,4], "[1,2,3,[2],4] - 2" => [1,3,[2],4], "[1,2,3,[2,3],4] - [[2,3]]" => [1,2,3,4], "[1,2,3,3,2,4,2,3] - [2,3]" => [1,4], "[1,2,3,['a',1],['b',2]] - {'a' => 1, 'b'=>2}" => [1,2,3], "[1,2,3,{'a'=>1,'b'=>2}] - [{'a' => 1, 'b'=>2}]" => [1,2,3], }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "[1,2,3] + {'a' => 1, 'b'=>2}" => [1,2,3,['a',1],['b',2]], }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do # This test must be done with match_array since the order of the hash # is undefined and Ruby 1.8.7 and 1.9.3 produce different results. expect(parser.evaluate_string(scope, source, __FILE__)).to match_array(result) end end { "[1,2,3][a]" => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end { "{}" => {}, "{'a'=>1,'b'=>2}" => {'a'=>1,'b'=>2}, "{'a'=>1,'b'=>{'x'=>2.1,'y'=>2.2}}" => {'a'=>1,'b'=>{'x'=>2.1,'y'=>2.2}}, "{'a'=> 2 + 2}" => {'a'=> 4}, "{'a'=> 1, 'b'=>2} == {'a'=> 1, 'b'=>2}" => true, "{'a'=> 1, 'b'=>2} != {'x'=> 1, 'b'=>2}" => true, "{'a'=> 1, 'b'=>2} == {'a'=> 2, 'b'=>3}" => false, "{'a'=> 1, 'b'=>2} != {'a'=> 1, 'b'=>2}" => false, "{a => 1, b => 2}[b]" => 2, "{2+2 => sum, b => 2}[4]" => 'sum', "{'a'=>1, 'b'=>2} + {'c'=>3}" => {'a'=>1,'b'=>2,'c'=>3}, "{'a'=>1, 'b'=>2} + {'b'=>3}" => {'a'=>1,'b'=>3}, "{'a'=>1, 'b'=>2} + ['c', 3, 'b', 3]" => {'a'=>1,'b'=>3, 'c'=>3}, "{'a'=>1, 'b'=>2} + [['c', 3], ['b', 3]]" => {'a'=>1,'b'=>3, 'c'=>3}, "{'a'=>1, 'b'=>2} - {'b' => 3}" => {'a'=>1}, "{'a'=>1, 'b'=>2, 'c'=>3} - ['b', 'c']" => {'a'=>1}, "{'a'=>1, 'b'=>2, 'c'=>3} - 'c'" => {'a'=>1, 'b'=>2}, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "{'a' => 1, 'b'=>2} << 1" => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end end context "When the evaluator perform comparisons" do { "'a' == 'a'" => true, "'a' == 'b'" => false, "'a' != 'a'" => false, "'a' != 'b'" => true, "'a' < 'b' " => true, "'a' < 'a' " => false, "'b' < 'a' " => false, "'a' <= 'b'" => true, "'a' <= 'a'" => true, "'b' <= 'a'" => false, "'a' > 'b' " => false, "'a' > 'a' " => false, "'b' > 'a' " => true, "'a' >= 'b'" => false, "'a' >= 'a'" => true, "'b' >= 'a'" => true, "'a' == 'A'" => true, "'a' != 'A'" => false, "'a' > 'A'" => false, "'a' >= 'A'" => true, "'A' < 'a'" => false, "'A' <= 'a'" => true, "1 == 1" => true, "1 == 2" => false, "1 != 1" => false, "1 != 2" => true, "1 < 2 " => true, "1 < 1 " => false, "2 < 1 " => false, "1 <= 2" => true, "1 <= 1" => true, "2 <= 1" => false, "1 > 2 " => false, "1 > 1 " => false, "2 > 1 " => true, "1 >= 2" => false, "1 >= 1" => true, "2 >= 1" => true, "1 == 1.0 " => true, "1 < 1.1 " => true, "'1' < 1.1" => true, "1.0 == 1 " => true, "1.0 < 2 " => true, "1.0 < 'a'" => true, "'1.0' < 1.1" => true, "'1.0' < 'a'" => true, "'1.0' < '' " => true, "'1.0' < ' '" => true, "'a' > '1.0'" => true, "/.*/ == /.*/ " => true, "/.*/ != /a.*/" => true, "true == true " => true, "false == false" => true, "true == false" => false, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "'a' =~ /.*/" => true, "'a' =~ '.*'" => true, "/.*/ != /a.*/" => true, "'a' !~ /b.*/" => true, "'a' !~ 'b.*'" => true, '$x = a; a =~ "$x.*"' => true, "a =~ Pattern['a.*']" => true, "a =~ Regexp['a.*']" => false, # String is not subtype of Regexp. PUP-957 "$x = /a.*/ a =~ $x" => true, "$x = Pattern['a.*'] a =~ $x" => true, "1 =~ Integer" => true, "1 !~ Integer" => false, "[1,2,3] =~ Array[Integer[1,10]]" => true, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "666 =~ /6/" => :error, "[a] =~ /a/" => :error, "{a=>1} =~ /a/" => :error, "/a/ =~ /a/" => :error, "Array =~ /A/" => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end { "1 in [1,2,3]" => true, "4 in [1,2,3]" => false, "a in {x=>1, a=>2}" => true, "z in {x=>1, a=>2}" => false, "ana in bananas" => true, "xxx in bananas" => false, "/ana/ in bananas" => true, "/xxx/ in bananas" => false, "ANA in bananas" => false, # ANA is a type, not a String "'ANA' in bananas" => true, "ana in 'BANANAS'" => true, "/ana/ in 'BANANAS'" => false, "/ANA/ in 'BANANAS'" => true, "xxx in 'BANANAS'" => false, "[2,3] in [1,[2,3],4]" => true, "[2,4] in [1,[2,3],4]" => false, "[a,b] in ['A',['A','B'],'C']" => true, "[x,y] in ['A',['A','B'],'C']" => false, "a in {a=>1}" => true, "x in {a=>1}" => false, "'A' in {a=>1}" => true, "'X' in {a=>1}" => false, "a in {'A'=>1}" => true, "x in {'A'=>1}" => false, "/xxx/ in {'aaaxxxbbb'=>1}" => true, "/yyy/ in {'aaaxxxbbb'=>1}" => false, "15 in [1, 0xf]" => true, "15 in [1, '0xf']" => true, "'15' in [1, 0xf]" => true, "15 in [1, 115]" => false, "1 in [11, '111']" => false, "'1' in [11, '111']" => false, "Array[Integer] in [2, 3]" => false, "Array[Integer] in [2, [3, 4]]" => true, "Array[Integer] in [2, [a, 4]]" => false, "Integer in { 2 =>'a'}" => true, "Integer[5,10] in [1,5,3]" => true, "Integer[5,10] in [1,2,3]" => false, "Integer in {'a'=>'a'}" => false, "Integer in {'a'=>1}" => false, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { 'Object' => ['Data', 'Scalar', 'Numeric', 'Integer', 'Float', 'Boolean', 'String', 'Pattern', 'Collection', 'Array', 'Hash', 'CatalogEntry', 'Resource', 'Class', 'Undef', 'File', 'NotYetKnownResourceType'], # Note, Data > Collection is false (so not included) 'Data' => ['Scalar', 'Numeric', 'Integer', 'Float', 'Boolean', 'String', 'Pattern', 'Array', 'Hash',], 'Scalar' => ['Numeric', 'Integer', 'Float', 'Boolean', 'String', 'Pattern'], 'Numeric' => ['Integer', 'Float'], 'CatalogEntry' => ['Class', 'Resource', 'File', 'NotYetKnownResourceType'], 'Integer[1,10]' => ['Integer[2,3]'], }.each do |general, specials| specials.each do |special | it "should compute that #{general} > #{special}" do parser.evaluate_string(scope, "#{general} > #{special}", __FILE__).should == true end it "should compute that #{special} < #{general}" do parser.evaluate_string(scope, "#{special} < #{general}", __FILE__).should == true end it "should compute that #{general} != #{special}" do parser.evaluate_string(scope, "#{special} != #{general}", __FILE__).should == true end end end { 'Integer[1,10] > Integer[2,3]' => true, 'Integer[1,10] == Integer[2,3]' => false, 'Integer[1,10] > Integer[0,5]' => false, 'Integer[1,10] > Integer[1,10]' => false, 'Integer[1,10] >= Integer[1,10]' => true, 'Integer[1,10] == Integer[1,10]' => true, }.each do |source, result| it "should parse and evaluate the integer range comparison expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end end context "When the evaluator performs arithmetic" do context "on Integers" do { "2+2" => 4, "2 + 2" => 4, "7 - 3" => 4, "6 * 3" => 18, "6 / 3" => 2, "6 % 3" => 0, "10 % 3" => 1, "-(6/3)" => -2, "-6/3 " => -2, "8 >> 1" => 4, "8 << 1" => 16, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end context "on Floats" do { "2.2 + 2.2" => 4.4, "7.7 - 3.3" => 4.4, "6.1 * 3.1" => 18.91, "6.6 / 3.3" => 2.0, "-(6.0/3.0)" => -2.0, "-6.0/3.0 " => -2.0, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "3.14 << 2" => :error, "3.14 >> 2" => :error, "6.6 % 3.3" => 0.0, "10.0 % 3.0" => 1.0, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end end context "on strings requiring boxing to Numeric" do { "'2' + '2'" => 4, "'2.2' + '2.2'" => 4.4, "'0xF7' + '010'" => 0xFF, "'0xF7' + '0x8'" => 0xFF, "'0367' + '010'" => 0xFF, "'012.3' + '010'" => 20.3, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "'0888' + '010'" => :error, "'0xWTF' + '010'" => :error, "'0x12.3' + '010'" => :error, "'0x12.3' + '010'" => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end end end end # arithmetic context "When the evaluator evaluates assignment" do { "$a = 5" => 5, "$a = 5; $a" => 5, "$a = 5; $b = 6; $a" => 5, "$a = $b = 5; $a == $b" => true, "$a = [1,2,3]; [x].map |$x| { $a += x; $a }" => [[1,2,3,'x']], "$a = [a,x,c]; [x].map |$x| { $a -= x; $a }" => [['a','c']], }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "[a,b,c] = [1,2,3]; $a == 1 and $b == 2 and $c == 3" => :error, "[a,b,c] = {b=>2,c=>3,a=>1}; $a == 1 and $b == 2 and $c == 3" => :error, "$a = [1,2,3]; [x].collect |$x| { [a] += x; $a }" => :error, "$a = [a,x,c]; [x].collect |$x| { [a] -= x; $a }" => :error, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(Puppet::ParseError) end end end context "When the evaluator evaluates conditionals" do { "if true {5}" => 5, "if false {5}" => nil, "if false {2} else {5}" => 5, "if false {2} elsif true {5}" => 5, "if false {2} elsif false {5}" => nil, "unless false {5}" => 5, "unless true {5}" => nil, "unless true {2} else {5}" => 5, "$a = if true {5} $a" => 5, "$a = if false {5} $a" => nil, "$a = if false {2} else {5} $a" => 5, "$a = if false {2} elsif true {5} $a" => 5, "$a = if false {2} elsif false {5} $a" => nil, "$a = unless false {5} $a" => 5, "$a = unless true {5} $a" => nil, "$a = unless true {2} else {5} $a" => 5, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "case 1 { 1 : { yes } }" => 'yes', "case 2 { 1,2,3 : { yes} }" => 'yes', "case 2 { 1,3 : { no } 2: { yes} }" => 'yes', "case 2 { 1,3 : { no } 5: { no } default: { yes }}" => 'yes', "case 2 { 1,3 : { no } 5: { no } }" => nil, "case 'banana' { 1,3 : { no } /.*ana.*/: { yes } }" => 'yes', "case 'banana' { /.*(ana).*/: { $1 } }" => 'ana', "case [1] { Array : { yes } }" => 'yes', "case [1] { Array[String] : { no } Array[Integer]: { yes } }" => 'yes', "case 1 { Integer : { yes } Type[Integer] : { no } }" => 'yes', "case Integer { Integer : { no } Type[Integer] : { yes } }" => 'yes', }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "2 ? { 1 => no, 2 => yes}" => 'yes', "3 ? { 1 => no, 2 => no}" => nil, "3 ? { 1 => no, 2 => no, default => yes }" => 'yes', "3 ? { 1 => no, default => yes, 3 => no }" => 'yes', "'banana' ? { /.*(ana).*/ => $1 }" => 'ana', "[2] ? { Array[String] => yes, Array => yes}" => 'yes', }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end end + context "When evaluator evaluated unfold" do + { + "*[1,2,3]" => [1,2,3], + "*1" => [1], + "*'a'" => ['a'] + }.each do |source, result| + it "should parse and evaluate the expression '#{source}' to #{result}" do + parser.evaluate_string(scope, source, __FILE__).should == result + end + end + + it "should parse and evaluate the expression '*{a=>10, b=>20} to [['a',10],['b',20]]" do + result = parser.evaluate_string(scope, '*{a=>10, b=>20}', __FILE__) + expect(result).to include(['a', 10]) + expect(result).to include(['b', 20]) + end + + end context "When evaluator performs [] operations" do { "[1,2,3][0]" => 1, "[1,2,3][2]" => 3, "[1,2,3][3]" => nil, "[1,2,3][-1]" => 3, "[1,2,3][-2]" => 2, "[1,2,3][-4]" => nil, "[1,2,3,4][0,2]" => [1,2], "[1,2,3,4][1,3]" => [2,3,4], "[1,2,3,4][-2,2]" => [3,4], "[1,2,3,4][-3,2]" => [2,3], "[1,2,3,4][3,5]" => [4], "[1,2,3,4][5,2]" => [], "[1,2,3,4][0,-1]" => [1,2,3,4], "[1,2,3,4][0,-2]" => [1,2,3], "[1,2,3,4][0,-4]" => [1], "[1,2,3,4][0,-5]" => [], "[1,2,3,4][-5,2]" => [1], "[1,2,3,4][-5,-3]" => [1,2], "[1,2,3,4][-6,-3]" => [1,2], "[1,2,3,4][2,-3]" => [], + "[1,*[2,3],4]" => [1,2,3,4], + "[1,*[2,3],4][1]" => 2, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "{a=>1, b=>2, c=>3}[a]" => 1, "{a=>1, b=>2, c=>3}[c]" => 3, "{a=>1, b=>2, c=>3}[x]" => nil, "{a=>1, b=>2, c=>3}[c,b]" => [3,2], "{a=>1, b=>2, c=>3}[a,b,c]" => [1,2,3], "{a=>{b=>{c=>'it works'}}}[a][b][c]" => 'it works', "$a = {undef => 10} $a[free_lunch]" => nil, "$a = {undef => 10} $a[undef]" => 10, "$a = {undef => 10} $a[$a[free_lunch]]" => 10, "$a = {} $a[free_lunch] == undef" => true, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "'abc'[0]" => 'a', "'abc'[2]" => 'c', "'abc'[-1]" => 'c', "'abc'[-2]" => 'b', "'abc'[-3]" => 'a', "'abc'[-4]" => '', "'abc'[3]" => '', "abc[0]" => 'a', "abc[2]" => 'c', "abc[-1]" => 'c', "abc[-2]" => 'b', "abc[-3]" => 'a', "abc[-4]" => '', "abc[3]" => '', "'abcd'[0,2]" => 'ab', "'abcd'[1,3]" => 'bcd', "'abcd'[-2,2]" => 'cd', "'abcd'[-3,2]" => 'bc', "'abcd'[3,5]" => 'd', "'abcd'[5,2]" => '', "'abcd'[0,-1]" => 'abcd', "'abcd'[0,-2]" => 'abc', "'abcd'[0,-4]" => 'a', "'abcd'[0,-5]" => '', "'abcd'[-5,2]" => 'a', "'abcd'[-5,-3]" => 'ab', "'abcd'[-6,-3]" => 'ab', "'abcd'[2,-3]" => '', }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end # Type operations (full set tested by tests covering type calculator) { "Array[Integer]" => types.array_of(types.integer), "Array[Integer,1]" => types.constrain_size(types.array_of(types.integer),1, :default), "Array[Integer,1,2]" => types.constrain_size(types.array_of(types.integer),1, 2), "Array[Integer,Integer[1,2]]" => types.constrain_size(types.array_of(types.integer),1, 2), "Array[Integer,Integer[1]]" => types.constrain_size(types.array_of(types.integer),1, :default), "Hash[Integer,Integer]" => types.hash_of(types.integer, types.integer), "Hash[Integer,Integer,1]" => types.constrain_size(types.hash_of(types.integer, types.integer),1, :default), "Hash[Integer,Integer,1,2]" => types.constrain_size(types.hash_of(types.integer, types.integer),1, 2), "Hash[Integer,Integer,Integer[1,2]]" => types.constrain_size(types.hash_of(types.integer, types.integer),1, 2), "Hash[Integer,Integer,Integer[1]]" => types.constrain_size(types.hash_of(types.integer, types.integer),1, :default), "Resource[File]" => types.resource('File'), "Resource['File']" => types.resource(types.resource('File')), "File[foo]" => types.resource('file', 'foo'), "File[foo, bar]" => [types.resource('file', 'foo'), types.resource('file', 'bar')], "Pattern[a, /b/, Pattern[c], Regexp[d]]" => types.pattern('a', 'b', 'c', 'd'), "String[1,2]" => types.constrain_size(types.string,1, 2), "String[Integer[1,2]]" => types.constrain_size(types.string,1, 2), "String[Integer[1]]" => types.constrain_size(types.string,1, :default), }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end # LHS where [] not supported, and missing key(s) { "Array[]" => :error, "'abc'[]" => :error, "Resource[]" => :error, "File[]" => :error, "String[]" => :error, "1[]" => :error, "3.14[]" => :error, "/.*/[]" => :error, "$a=[1] $a[]" => :error, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(/Syntax error/) end end # Errors when wrong number/type of keys are used { "Array[0]" => 'Array-Type[] arguments must be types. Got Fixnum', "Hash[0]" => 'Hash-Type[] arguments must be types. Got Fixnum', "Hash[Integer, 0]" => 'Hash-Type[] arguments must be types. Got Fixnum', "Array[Integer,1,2,3]" => 'Array-Type[] accepts 1 to 3 arguments. Got 4', "Array[Integer,String]" => "A Type's size constraint arguments must be a single Integer type, or 1-2 integers (or default). Got a String-Type", "Hash[Integer,String, 1,2,3]" => 'Hash-Type[] accepts 1 to 4 arguments. Got 5', "'abc'[x]" => "The value 'x' cannot be converted to Numeric", "'abc'[1.0]" => "A String[] cannot use Float where Integer is expected", "'abc'[1,2,3]" => "String supports [] with one or two arguments. Got 3", "Resource[0]" => 'First argument to Resource[] must be a resource type or a String. Got Fixnum', "Resource[a, 0]" => 'Error creating type specialization of a Resource-Type, Cannot use Fixnum where String is expected', "File[0]" => 'Error creating type specialization of a File-Type, Cannot use Fixnum where String is expected', "String[a]" => "A Type's size constraint arguments must be a single Integer type, or 1-2 integers (or default). Got a String", "Pattern[0]" => 'Error creating type specialization of a Pattern-Type, Cannot use Fixnum where String or Regexp or Pattern-Type or Regexp-Type is expected', "Regexp[0]" => 'Error creating type specialization of a Regexp-Type, Cannot use Fixnum where String or Regexp is expected', "Regexp[a,b]" => 'A Regexp-Type[] accepts 1 argument. Got 2', "true[0]" => "Operator '[]' is not applicable to a Boolean", "1[0]" => "Operator '[]' is not applicable to an Integer", "3.14[0]" => "Operator '[]' is not applicable to a Float", "/.*/[0]" => "Operator '[]' is not applicable to a Regexp", "[1][a]" => "The value 'a' cannot be converted to Numeric", "[1][0.0]" => "An Array[] cannot use Float where Integer is expected", "[1]['0.0']" => "An Array[] cannot use Float where Integer is expected", "[1,2][1, 0.0]" => "An Array[] cannot use Float where Integer is expected", "[1,2][1.0, -1]" => "An Array[] cannot use Float where Integer is expected", "[1,2][1, -1.0]" => "An Array[] cannot use Float where Integer is expected", }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(Regexp.new(Regexp.quote(result))) end end context "on catalog types" do it "[n] gets resource parameter [n]" do source = "notify { 'hello': message=>'yo'} Notify[hello][message]" parser.evaluate_string(scope, source, __FILE__).should == 'yo' end it "[n] gets class parameter [n]" do source = "class wonka($produces='chocolate'){ } include wonka Class[wonka][produces]" # This is more complicated since it needs to run like 3.x and do an import_ast adapted_parser = Puppet::Parser::E4ParserAdapter.new adapted_parser.file = __FILE__ ast = adapted_parser.parse(source) scope.known_resource_types.import_ast(ast, '') ast.code.safeevaluate(scope).should == 'chocolate' end # Resource default and override expressions and resource parameter access with [] { "notify { id: message=>explicit} Notify[id][message]" => "explicit", "Notify { message=>by_default} notify {foo:} Notify[foo][message]" => "by_default", "notify {foo:} Notify[foo]{message =>by_override} Notify[foo][message]" => "by_override", "notify { foo: tag => evoe} Notify[foo][tag]" => "evoe", # Does not produce the defaults for tag "notify { foo: } Notify[foo][tag]" => nil, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end # Resource default and override expressions and resource parameter access error conditions { "notify { xid: message=>explicit} Notify[id][message]" => /Resource not found/, "notify { id: message=>explicit} Notify[id][mustard]" => /does not have a parameter called 'mustard'/, # NOTE: these meta-esque parameters are not recognized as such "notify { id: message=>explicit} Notify[id][title]" => /does not have a parameter called 'title'/, "notify { id: message=>explicit} Notify[id]['type']" => /does not have a parameter called 'type'/, }.each do |source, result| it "should parse '#{source}' and raise error matching #{result}" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(result) end end context 'with errors' do { "Class['fail-whale']" => /Illegal name/, "Class[0]" => /An Integer cannot be used where a String is expected/, "Class[/.*/]" => /A Regexp cannot be used where a String is expected/, "Class[4.1415]" => /A Float cannot be used where a String is expected/, "Class[Integer]" => /An Integer-Type cannot be used where a String is expected/, "Class[File['tmp']]" => /A File\['tmp'\] Resource-Reference cannot be used where a String is expected/, }.each do | source, error_pattern| it "an error is flagged for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(error_pattern) end end end end # end [] operations end context "When the evaluator performs boolean operations" do { "true and true" => true, "false and true" => false, "true and false" => false, "false and false" => false, "true or true" => true, "false or true" => true, "true or false" => true, "false or false" => false, "! true" => false, "!! true" => true, "!! false" => false, "! 'x'" => false, "! ''" => true, "! undef" => true, "! [a]" => false, "! []" => false, "! {a=>1}" => false, "! {}" => false, "true and false and '0xwtf' + 1" => false, "false or true or '0xwtf' + 1" => true, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do parser.evaluate_string(scope, source, __FILE__).should == result end end { "false || false || '0xwtf' + 1" => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end end context "When evaluator performs operations on literal undef" do it "computes non existing hash lookup as undef" do parser.evaluate_string(scope, "{a => 1}[b] == undef", __FILE__).should == true parser.evaluate_string(scope, "undef == {a => 1}[b]", __FILE__).should == true end end context "When evaluator performs calls" do let(:populate) do parser.evaluate_string(scope, "$a = 10 $b = [1,2,3]") end { 'sprintf( "x%iy", $a )' => "x10y", + # unfolds + 'sprintf( *["x%iy", $a] )' => "x10y", '"x%iy".sprintf( $a )' => "x10y", '$b.reduce |$memo,$x| { $memo + $x }' => 6, 'reduce($b) |$memo,$x| { $memo + $x }' => 6, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do populate parser.evaluate_string(scope, source, __FILE__).should == result end end { '"value is ${a*2} yo"' => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end it "provides location information on error in unparenthesized call logic" do expect{parser.evaluate_string(scope, "include non_existing_class", __FILE__)}.to raise_error(Puppet::ParseError, /line 1\:1/) end end context "When evaluator performs string interpolation" do let(:populate) do parser.evaluate_string(scope, "$a = 10 $b = [1,2,3]") end { '"value is $a yo"' => "value is 10 yo", '"value is \$a yo"' => "value is $a yo", '"value is ${a} yo"' => "value is 10 yo", '"value is \${a} yo"' => "value is ${a} yo", '"value is ${$a} yo"' => "value is 10 yo", '"value is ${$a*2} yo"' => "value is 20 yo", '"value is ${sprintf("x%iy",$a)} yo"' => "value is x10y yo", '"value is ${"x%iy".sprintf($a)} yo"' => "value is x10y yo", '"value is ${[1,2,3]} yo"' => "value is [1, 2, 3] yo", '"value is ${/.*/} yo"' => "value is /.*/ yo", '$x = undef "value is $x yo"' => "value is yo", '$x = default "value is $x yo"' => "value is default yo", '$x = Array[Integer] "value is $x yo"' => "value is Array[Integer] yo", '"value is ${Array[Integer]} yo"' => "value is Array[Integer] yo", }.each do |source, result| it "should parse and evaluate the expression '#{source}' to #{result}" do populate parser.evaluate_string(scope, source, __FILE__).should == result end end it "should parse and evaluate an interpolation of a hash" do source = '"value is ${{a=>1,b=>2}} yo"' # This test requires testing against two options because a hash to string # produces a result that is unordered hashstr = {'a' => 1, 'b' => 2}.to_s alt_results = ["value is {a => 1, b => 2} yo", "value is {b => 2, a => 1} yo" ] populate parse_result = parser.evaluate_string(scope, source, __FILE__) alt_results.include?(parse_result).should == true end { '"value is ${a*2} yo"' => :error, }.each do |source, result| it "should parse and raise error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(Puppet::ParseError) end end end context "When evaluating variables" do context "that are non existing an error is raised for" do it "unqualified variable" do expect { parser.evaluate_string(scope, "$quantum_gravity", __FILE__) }.to raise_error(/Unknown variable/) end it "qualified variable" do expect { parser.evaluate_string(scope, "$quantum_gravity::graviton", __FILE__) }.to raise_error(/Unknown variable/) end end it "a lex error should be raised for '$foo::::bar'" do expect { parser.evaluate_string(scope, "$foo::::bar") }.to raise_error(Puppet::LexError, /Illegal fully qualified name at line 1:7/) end { '$a = $0' => nil, '$a = $1' => nil, }.each do |source, value| it "it is ok to reference numeric unassigned variables '#{source}'" do parser.evaluate_string(scope, source, __FILE__).should == value end end { '$00 = 0' => /must be a decimal value/, '$0xf = 0' => /must be a decimal value/, '$0777 = 0' => /must be a decimal value/, '$123a = 0' => /must be a decimal value/, }.each do |source, error_pattern| it "should raise an error for '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(error_pattern) end end context "an initial underscore in the last segment of a var name is allowed" do { '$_a = 1' => 1, '$__a = 1' => 1, }.each do |source, value| it "as in this example '#{source}'" do parser.evaluate_string(scope, source, __FILE__).should == value end end end end context "When evaluating relationships" do it 'should form a relation with File[a] -> File[b]' do source = "File[a] -> File[b]" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['File', 'a', '->', 'File', 'b']) end it 'should form a relation with resource -> resource' do source = "notify{a:} -> notify{b:}" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['Notify', 'a', '->', 'Notify', 'b']) end it 'should form a relation with [File[a], File[b]] -> [File[x], File[y]]' do source = "[File[a], File[b]] -> [File[x], File[y]]" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['File', 'a', '->', 'File', 'x']) scope.compiler.should have_relationship(['File', 'b', '->', 'File', 'x']) scope.compiler.should have_relationship(['File', 'a', '->', 'File', 'y']) scope.compiler.should have_relationship(['File', 'b', '->', 'File', 'y']) end it 'should tolerate (eliminate) duplicates in operands' do source = "[File[a], File[a]] -> File[x]" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['File', 'a', '->', 'File', 'x']) scope.compiler.relationships.size.should == 1 end it 'should form a relation with <-' do source = "File[a] <- File[b]" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['File', 'b', '->', 'File', 'a']) end it 'should form a relation with <-' do source = "File[a] <~ File[b]" parser.evaluate_string(scope, source, __FILE__) scope.compiler.should have_relationship(['File', 'b', '~>', 'File', 'a']) end end context "When evaluating heredoc" do it "evaluates plain heredoc" do src = "@(END)\nThis is\nheredoc text\nEND\n" parser.evaluate_string(scope, src).should == "This is\nheredoc text\n" end it "parses heredoc with margin" do src = [ "@(END)", " This is", " heredoc text", " | END", "" ].join("\n") parser.evaluate_string(scope, src).should == "This is\nheredoc text\n" end it "parses heredoc with margin and right newline trim" do src = [ "@(END)", " This is", " heredoc text", " |- END", "" ].join("\n") parser.evaluate_string(scope, src).should == "This is\nheredoc text" end it "parses escape specification" do src = <<-CODE @(END/t) Tex\\tt\\n |- END CODE parser.evaluate_string(scope, src).should == "Tex\tt\\n" end it "parses syntax checked specification" do src = <<-CODE @(END:json) ["foo", "bar"] |- END CODE parser.evaluate_string(scope, src).should == '["foo", "bar"]' end it "parses syntax checked specification with error and reports it" do src = <<-CODE @(END:json) ['foo', "bar"] |- END CODE expect { parser.evaluate_string(scope, src)}.to raise_error(/Cannot parse invalid JSON string/) end - it "parses interpolated heredoc epression" do + it "parses interpolated heredoc expression" do src = <<-CODE $name = 'Fjodor' @("END") Hello $name |- END CODE parser.evaluate_string(scope, src).should == "Hello Fjodor" end end context "Handles Deprecations and Discontinuations" do around(:each) do |example| Puppet.override({:loaders => Puppet::Pops::Loaders.new(Puppet::Node::Environment.create(:testing, []))}, 'test') do example.run end end it 'of import statements' do source = "\nimport foo" # Error references position 5 at the opening '{' # Set file to nil to make it easier to match with line number (no file name in output) expect { parser.evaluate_string(scope, source) }.to raise_error(/'import' has been discontinued.*line 2:1/) end end context "Detailed Error messages are reported" do it 'for illegal type references' do source = '1+1 { "title": }' # Error references position 5 at the opening '{' # Set file to nil to make it easier to match with line number (no file name in output) expect { parser.parse_string(source, nil) }.to raise_error(/Expression is not valid as a resource.*line 1:5/) end it 'for non r-value producing <| |>' do expect { parser.parse_string("$a = File <| |>", nil) }.to raise_error(/A Virtual Query does not produce a value at line 1:6/) end it 'for non r-value producing <<| |>>' do expect { parser.parse_string("$a = File <<| |>>", nil) }.to raise_error(/An Exported Query does not produce a value at line 1:6/) end it 'for non r-value producing define' do Puppet.expects(:err).with("Invalid use of expression. A 'define' expression does not produce a value at line 1:6") Puppet.expects(:err).with("Classes, definitions, and nodes may only appear at toplevel or inside other classes at line 1:6") expect { parser.parse_string("$a = define foo { }", nil) }.to raise_error(/2 errors/) end it 'for non r-value producing class' do Puppet.expects(:err).with("Invalid use of expression. A Host Class Definition does not produce a value at line 1:6") Puppet.expects(:err).with("Classes, definitions, and nodes may only appear at toplevel or inside other classes at line 1:6") expect { parser.parse_string("$a = class foo { }", nil) }.to raise_error(/2 errors/) end it 'for unclosed quote with indication of start position of string' do source = <<-SOURCE.gsub(/^ {6}/,'') $a = "xx yyy SOURCE # first char after opening " reported as being in error. expect { parser.parse_string(source) }.to raise_error(/Unclosed quote after '"' followed by 'xx\\nyy\.\.\.' at line 1:7/) end it 'for multiple errors with a summary exception' do Puppet.expects(:err).with("Invalid use of expression. A Node Definition does not produce a value at line 1:6") Puppet.expects(:err).with("Classes, definitions, and nodes may only appear at toplevel or inside other classes at line 1:6") expect { parser.parse_string("$a = node x { }",nil) }.to raise_error(/2 errors/) end it 'for a bad hostname' do expect { parser.parse_string("node 'macbook+owned+by+name' { }", nil) }.to raise_error(/The hostname 'macbook\+owned\+by\+name' contains illegal characters.*at line 1:6/) end it 'for a hostname with interpolation' do source = <<-SOURCE.gsub(/^ {6}/,'') $name = 'fred' node "macbook-owned-by$name" { } SOURCE expect { parser.parse_string(source, nil) }.to raise_error(/An interpolated expression is not allowed in a hostname of a node at line 2:23/) end end matcher :have_relationship do |expected| calc = Puppet::Pops::Types::TypeCalculator.new match do |compiler| op_name = {'->' => :relationship, '~>' => :subscription} compiler.relationships.any? do | relation | relation.source.type == expected[0] && relation.source.title == expected[1] && relation.type == op_name[expected[2]] && relation.target.type == expected[3] && relation.target.title == expected[4] end end failure_message_for_should do |actual| "Relationship #{expected[0]}[#{expected[1]}] #{expected[2]} #{expected[3]}[#{expected[4]}] but was unknown to compiler" end end end diff --git a/spec/unit/pops/parser/parse_basic_expressions_spec.rb b/spec/unit/pops/parser/parse_basic_expressions_spec.rb index f5aeb2a29..2190e54bb 100644 --- a/spec/unit/pops/parser/parse_basic_expressions_spec.rb +++ b/spec/unit/pops/parser/parse_basic_expressions_spec.rb @@ -1,273 +1,278 @@ #! /usr/bin/env ruby require 'spec_helper' require 'puppet/pops' # relative to this spec file (./) does not work as this file is loaded by rspec require File.join(File.dirname(__FILE__), '/parser_rspec_helper') describe "egrammar parsing basic expressions" do include ParserRspecHelper context "When the parser parses arithmetic" do context "with Integers" do it "$a = 2 + 2" do; dump(parse("$a = 2 + 2")).should == "(= $a (+ 2 2))" ; end it "$a = 7 - 3" do; dump(parse("$a = 7 - 3")).should == "(= $a (- 7 3))" ; end it "$a = 6 * 3" do; dump(parse("$a = 6 * 3")).should == "(= $a (* 6 3))" ; end it "$a = 6 / 3" do; dump(parse("$a = 6 / 3")).should == "(= $a (/ 6 3))" ; end it "$a = 6 % 3" do; dump(parse("$a = 6 % 3")).should == "(= $a (% 6 3))" ; end it "$a = -(6/3)" do; dump(parse("$a = -(6/3)")).should == "(= $a (- (/ 6 3)))" ; end it "$a = -6/3" do; dump(parse("$a = -6/3")).should == "(= $a (/ (- 6) 3))" ; end it "$a = 8 >> 1 " do; dump(parse("$a = 8 >> 1")).should == "(= $a (>> 8 1))" ; end it "$a = 8 << 1 " do; dump(parse("$a = 8 << 1")).should == "(= $a (<< 8 1))" ; end end context "with Floats" do it "$a = 2.2 + 2.2" do; dump(parse("$a = 2.2 + 2.2")).should == "(= $a (+ 2.2 2.2))" ; end it "$a = 7.7 - 3.3" do; dump(parse("$a = 7.7 - 3.3")).should == "(= $a (- 7.7 3.3))" ; end it "$a = 6.1 * 3.1" do; dump(parse("$a = 6.1 - 3.1")).should == "(= $a (- 6.1 3.1))" ; end it "$a = 6.6 / 3.3" do; dump(parse("$a = 6.6 / 3.3")).should == "(= $a (/ 6.6 3.3))" ; end it "$a = -(6.0/3.0)" do; dump(parse("$a = -(6.0/3.0)")).should == "(= $a (- (/ 6.0 3.0)))" ; end it "$a = -6.0/3.0" do; dump(parse("$a = -6.0/3.0")).should == "(= $a (/ (- 6.0) 3.0))" ; end it "$a = 3.14 << 2" do; dump(parse("$a = 3.14 << 2")).should == "(= $a (<< 3.14 2))" ; end it "$a = 3.14 >> 2" do; dump(parse("$a = 3.14 >> 2")).should == "(= $a (>> 3.14 2))" ; end end context "with hex and octal Integer values" do it "$a = 0xAB + 0xCD" do; dump(parse("$a = 0xAB + 0xCD")).should == "(= $a (+ 0xAB 0xCD))" ; end it "$a = 0777 - 0333" do; dump(parse("$a = 0777 - 0333")).should == "(= $a (- 0777 0333))" ; end end context "with strings requiring boxing to Numeric" do # Test that numbers in string form does not turn into numbers it "$a = '2' + '2'" do; dump(parse("$a = '2' + '2'")).should == "(= $a (+ '2' '2'))" ; end it "$a = '2.2' + '0.2'" do; dump(parse("$a = '2.2' + '0.2'")).should == "(= $a (+ '2.2' '0.2'))" ; end it "$a = '0xab' + '0xcd'" do; dump(parse("$a = '0xab' + '0xcd'")).should == "(= $a (+ '0xab' '0xcd'))" ; end it "$a = '0777' + '0333'" do; dump(parse("$a = '0777' + '0333'")).should == "(= $a (+ '0777' '0333'))" ; end end context "precedence should be correct" do it "$a = 1 + 2 * 3" do; dump(parse("$a = 1 + 2 * 3")).should == "(= $a (+ 1 (* 2 3)))"; end it "$a = 1 + 2 % 3" do; dump(parse("$a = 1 + 2 % 3")).should == "(= $a (+ 1 (% 2 3)))"; end it "$a = 1 + 2 / 3" do; dump(parse("$a = 1 + 2 / 3")).should == "(= $a (+ 1 (/ 2 3)))"; end it "$a = 1 + 2 << 3" do; dump(parse("$a = 1 + 2 << 3")).should == "(= $a (<< (+ 1 2) 3))"; end it "$a = 1 + 2 >> 3" do; dump(parse("$a = 1 + 2 >> 3")).should == "(= $a (>> (+ 1 2) 3))"; end end context "parentheses alter precedence" do it "$a = (1 + 2) * 3" do; dump(parse("$a = (1 + 2) * 3")).should == "(= $a (* (+ 1 2) 3))"; end it "$a = (1 + 2) / 3" do; dump(parse("$a = (1 + 2) / 3")).should == "(= $a (/ (+ 1 2) 3))"; end end end context "When the evaluator performs boolean operations" do context "using operators AND OR NOT" do it "$a = true and true" do; dump(parse("$a = true and true")).should == "(= $a (&& true true))"; end it "$a = true or true" do; dump(parse("$a = true or true")).should == "(= $a (|| true true))" ; end it "$a = !true" do; dump(parse("$a = !true")).should == "(= $a (! true))" ; end end context "precedence should be correct" do it "$a = false or true and true" do dump(parse("$a = false or true and true")).should == "(= $a (|| false (&& true true)))" end it "$a = (false or true) and true" do dump(parse("$a = (false or true) and true")).should == "(= $a (&& (|| false true) true))" end it "$a = !true or true and true" do dump(parse("$a = !false or true and true")).should == "(= $a (|| (! false) (&& true true)))" end end # Possibly change to check of literal expressions context "on values requiring boxing to Boolean" do it "'x' == true" do dump(parse("! 'x'")).should == "(! 'x')" end it "'' == false" do dump(parse("! ''")).should == "(! '')" end it ":undef == false" do dump(parse("! undef")).should == "(! :undef)" end end end context "When parsing comparisons" do context "of string values" do it "$a = 'a' == 'a'" do; dump(parse("$a = 'a' == 'a'")).should == "(= $a (== 'a' 'a'))" ; end it "$a = 'a' != 'a'" do; dump(parse("$a = 'a' != 'a'")).should == "(= $a (!= 'a' 'a'))" ; end it "$a = 'a' < 'b'" do; dump(parse("$a = 'a' < 'b'")).should == "(= $a (< 'a' 'b'))" ; end it "$a = 'a' > 'b'" do; dump(parse("$a = 'a' > 'b'")).should == "(= $a (> 'a' 'b'))" ; end it "$a = 'a' <= 'b'" do; dump(parse("$a = 'a' <= 'b'")).should == "(= $a (<= 'a' 'b'))" ; end it "$a = 'a' >= 'b'" do; dump(parse("$a = 'a' >= 'b'")).should == "(= $a (>= 'a' 'b'))" ; end end context "of integer values" do it "$a = 1 == 1" do; dump(parse("$a = 1 == 1")).should == "(= $a (== 1 1))" ; end it "$a = 1 != 1" do; dump(parse("$a = 1 != 1")).should == "(= $a (!= 1 1))" ; end it "$a = 1 < 2" do; dump(parse("$a = 1 < 2")).should == "(= $a (< 1 2))" ; end it "$a = 1 > 2" do; dump(parse("$a = 1 > 2")).should == "(= $a (> 1 2))" ; end it "$a = 1 <= 2" do; dump(parse("$a = 1 <= 2")).should == "(= $a (<= 1 2))" ; end it "$a = 1 >= 2" do; dump(parse("$a = 1 >= 2")).should == "(= $a (>= 1 2))" ; end end context "of regular expressions (parse errors)" do # Not supported in concrete syntax it "$a = /.*/ == /.*/" do dump(parse("$a = /.*/ == /.*/")).should == "(= $a (== /.*/ /.*/))" end it "$a = /.*/ != /a.*/" do dump(parse("$a = /.*/ != /.*/")).should == "(= $a (!= /.*/ /.*/))" end end end context "When parsing Regular Expression matching" do it "$a = 'a' =~ /.*/" do; dump(parse("$a = 'a' =~ /.*/")).should == "(= $a (=~ 'a' /.*/))" ; end it "$a = 'a' =~ '.*'" do; dump(parse("$a = 'a' =~ '.*'")).should == "(= $a (=~ 'a' '.*'))" ; end it "$a = 'a' !~ /b.*/" do; dump(parse("$a = 'a' !~ /b.*/")).should == "(= $a (!~ 'a' /b.*/))" ; end it "$a = 'a' !~ 'b.*'" do; dump(parse("$a = 'a' !~ 'b.*'")).should == "(= $a (!~ 'a' 'b.*'))" ; end end + context "When parsing unfold" do + it "$a = *[1,2]" do; dump(parse("$a = *[1,2]")).should == "(= $a (unfold ([] 1 2)))" ; end + it "$a = *1" do; dump(parse("$a = *1")).should == "(= $a (unfold 1))" ; end + end + context "When parsing Lists" do it "$a = []" do dump(parse("$a = []")).should == "(= $a ([]))" end it "$a = [1]" do dump(parse("$a = [1]")).should == "(= $a ([] 1))" end it "$a = [1,2,3]" do dump(parse("$a = [1,2,3]")).should == "(= $a ([] 1 2 3))" end it "[...[...[]]] should create nested arrays without trouble" do dump(parse("$a = [1,[2.0, 2.1, [2.2]],[3.0, 3.1]]")).should == "(= $a ([] 1 ([] 2.0 2.1 ([] 2.2)) ([] 3.0 3.1)))" end it "$a = [2 + 2]" do dump(parse("$a = [2+2]")).should == "(= $a ([] (+ 2 2)))" end it "$a [1,2,3] == [1,2,3]" do dump(parse("$a = [1,2,3] == [1,2,3]")).should == "(= $a (== ([] 1 2 3) ([] 1 2 3)))" end end context "When parsing indexed access" do it "$a = $b[2]" do dump(parse("$a = $b[2]")).should == "(= $a (slice $b 2))" end it "$a = [1, 2, 3][2]" do dump(parse("$a = [1,2,3][2]")).should == "(= $a (slice ([] 1 2 3) 2))" end it "$a = {'a' => 1, 'b' => 2}['b']" do dump(parse("$a = {'a'=>1,'b' =>2}[b]")).should == "(= $a (slice ({} ('a' 1) ('b' 2)) b))" end end context "When parsing assignments" do it "Should allow simple assignment" do dump(parse("$a = 10")).should == "(= $a 10)" end it "Should allow append assignment" do dump(parse("$a += 10")).should == "(+= $a 10)" end it "Should allow without assignment" do dump(parse("$a -= 10")).should == "(-= $a 10)" end it "Should allow chained assignment" do dump(parse("$a = $b = 10")).should == "(= $a (= $b 10))" end it "Should allow chained assignment with expressions" do dump(parse("$a = 1 + ($b = 10)")).should == "(= $a (+ 1 (= $b 10)))" end end context "When parsing Hashes" do it "should create a Hash when evaluating a LiteralHash" do dump(parse("$a = {'a'=>1,'b'=>2}")).should == "(= $a ({} ('a' 1) ('b' 2)))" end it "$a = {...{...{}}} should create nested hashes without trouble" do dump(parse("$a = {'a'=>1,'b'=>{'x'=>2.1,'y'=>2.2}}")).should == "(= $a ({} ('a' 1) ('b' ({} ('x' 2.1) ('y' 2.2)))))" end it "$a = {'a'=> 2 + 2} should evaluate values in entries" do dump(parse("$a = {'a'=>2+2}")).should == "(= $a ({} ('a' (+ 2 2))))" end it "$a = {'a'=> 1, 'b'=>2} == {'a'=> 1, 'b'=>2}" do dump(parse("$a = {'a'=>1,'b'=>2} == {'a'=>1,'b'=>2}")).should == "(= $a (== ({} ('a' 1) ('b' 2)) ({} ('a' 1) ('b' 2))))" end it "$a = {'a'=> 1, 'b'=>2} != {'x'=> 1, 'y'=>3}" do dump(parse("$a = {'a'=>1,'b'=>2} != {'a'=>1,'b'=>2}")).should == "(= $a (!= ({} ('a' 1) ('b' 2)) ({} ('a' 1) ('b' 2))))" end end context "When parsing the 'in' operator" do it "with integer in a list" do dump(parse("$a = 1 in [1,2,3]")).should == "(= $a (in 1 ([] 1 2 3)))" end it "with string key in a hash" do dump(parse("$a = 'a' in {'x'=>1, 'a'=>2, 'y'=> 3}")).should == "(= $a (in 'a' ({} ('x' 1) ('a' 2) ('y' 3))))" end it "with substrings of a string" do dump(parse("$a = 'ana' in 'bananas'")).should == "(= $a (in 'ana' 'bananas'))" end it "with sublist in a list" do dump(parse("$a = [2,3] in [1,2,3]")).should == "(= $a (in ([] 2 3) ([] 1 2 3)))" end end context "When parsing string interpolation" do it "should interpolate a bare word as a variable name, \"${var}\"" do dump(parse("$a = \"$var\"")).should == "(= $a (cat '' (str $var) ''))" end it "should interpolate a variable in a text expression, \"${$var}\"" do dump(parse("$a = \"${$var}\"")).should == "(= $a (cat '' (str $var) ''))" end it "should interpolate a variable, \"yo${var}yo\"" do dump(parse("$a = \"yo${var}yo\"")).should == "(= $a (cat 'yo' (str $var) 'yo'))" end it "should interpolate any expression in a text expression, \"${$var*2}\"" do dump(parse("$a = \"yo${$var+2}yo\"")).should == "(= $a (cat 'yo' (str (+ $var 2)) 'yo'))" end it "should not interpolate names as variable in expression, \"${notvar*2}\"" do dump(parse("$a = \"yo${notvar+2}yo\"")).should == "(= $a (cat 'yo' (str (+ notvar 2)) 'yo'))" end it "should interpolate name as variable in access expression, \"${var[0]}\"" do dump(parse("$a = \"yo${var[0]}yo\"")).should == "(= $a (cat 'yo' (str (slice $var 0)) 'yo'))" end it "should interpolate name as variable in method call, \"${var.foo}\"" do dump(parse("$a = \"yo${$var.foo}yo\"")).should == "(= $a (cat 'yo' (str (call-method (. $var foo))) 'yo'))" end it "should interpolate name as variable in method call, \"${var.foo}\"" do dump(parse("$a = \"yo${var.foo}yo\"")).should == "(= $a (cat 'yo' (str (call-method (. $var foo))) 'yo'))" dump(parse("$a = \"yo${var.foo.bar}yo\"")).should == "(= $a (cat 'yo' (str (call-method (. (call-method (. $var foo)) bar))) 'yo'))" end end end