diff --git a/lib/puppet/pops/parser/egrammar.ra b/lib/puppet/pops/parser/egrammar.ra index e2e150141..8b386c4c0 100644 --- a/lib/puppet/pops/parser/egrammar.ra +++ b/lib/puppet/pops/parser/egrammar.ra @@ -1,759 +1,759 @@ # vim: syntax=ruby # Parser using the Pops model, expression based class Puppet::Pops::Parser::Parser token STRING DQPRE DQMID DQPOST token WORD 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 PRIVATE ATTR TYPE token LOW prechigh left HIGH left SEMIC left PIPE left LPAREN left RPAREN left DOT 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 left LBRACE left SELBRACE left RBRACE right AT ATAT right APPENDS DELETES EQUALS left IN_EDGE OUT_EDGE IN_EDGE_SUB OUT_EDGE_SUB left FARROW left COMMA nonassoc RENDER_EXPR nonassoc RENDER_STRING left LOW preclow rule # Produces [Model::Program] with a body containing what was parsed program : statements { result = create_program(Factory.block_or_expression(*val[0])) } | epp_expression { result = create_program(Factory.block_or_expression(*val[0])) } | { result = create_empty_program() } # Produces a semantic model (non validated, but semantically adjusted). statements : syntactic_statements { result = transform_calls(val[0]) } # Collects sequence of elements into a list that the statements rule can transform # (Needed because language supports function calls without parentheses around arguments). # 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 # This exists to handle multiple arguments to non parenthesized function call. If e is expression, # the a program can consists of e [e,e,e] where the first may be a name of a function to call. # syntactic_statement : assignment =LOW { result = val[0] } | syntactic_statement COMMA assignment =LOW { result = aryfy(val[0]).push(val[1]).push(val[2]) } # Assignment (is right recursive since assignment is right associative) assignment : relationship =LOW | relationship EQUALS assignment { result = val[0].set(val[2]) ; loc result, val[1] } | relationship APPENDS assignment { result = val[0].plus_set(val[2]) ; loc result, val[1] } | relationship DELETES assignment { result = val[0].minus_set(val[2]); loc result, val[1] } assignments : assignment { result = [val[0]] } | assignments COMMA assignment { result = val[0].push(val[2]) } relationship : resource =LOW | relationship IN_EDGE resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship IN_EDGE_SUB resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship OUT_EDGE resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } | relationship OUT_EDGE_SUB resource { result = val[0].relop(val[1][:value], val[2]); loc result, val[1] } #-- RESOURCE # resource : expression = LOW #---VIRTUAL | AT resource { result = val[1] unless Factory.set_resource_form(result, :virtual) # This is equivalent to a syntax error - additional semantic restrictions apply error val[0], "Virtual (@) can only be applied to a Resource Expression" end # relocate the result loc result, val[0], val[1] } #---EXPORTED | ATAT resource { result = val[1] unless Factory.set_resource_form(result, :exported) # This is equivalent to a syntax error - additional semantic restrictions apply error val[0], "Exported (@@) can only be applied to a Resource Expression" end # relocate the result loc result, val[0], val[1] } #---RESOURCE TITLED 3x and 4x | resource LBRACE expression COLON attribute_operations additional_resource_bodies RBRACE { bodies = [Factory.RESOURCE_BODY(val[2], val[4])] + val[5] result = Factory.RESOURCE(val[0], bodies) loc result, val[0], val[6] } #---CLASS RESOURCE | CLASS LBRACE resource_bodies endsemi RBRACE { result = Factory.RESOURCE(Factory.fqn(token_text(val[0])), val[2]) loc result, val[0], val[4] } # --RESOURCE 3X Expression # Handles both 3x overrides and defaults (i.e. single resource_body without title colon) # Slated for possible deprecation since it requires transformation and mix static/evaluation check # | resource 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 should 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] } resource_body : expression COLON attribute_operations endcomma { result = Factory.RESOURCE_BODY(val[0], val[2]) } resource_bodies : resource_body =HIGH { result = [val[0]] } | resource_bodies SEMIC resource_body =HIGH { result = val[0].push val[2] } # This is a rule for the intermediate state where RACC has seen enough tokens to understand that # what is expressed is a Resource Expression, it now has to get to the finishing line # additional_resource_bodies : endcomma { result = [] } | endcomma SEMIC { result = [] } | endcomma SEMIC resource_bodies endsemi { result = val[2] } #-- EXPRESSION # expression : primary_expression | call_function_expression | 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 QMARK selector_entries { result = val[0].select(*val[2]) ; loc result, val[0] } | LPAREN assignment RPAREN { result = val[1].paren() ; loc result, val[0] } #---EXPRESSIONS # (i.e. "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]) } primary_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 | reserved_word | array | hash | regex | quotedtext | type | NUMBER { result = Factory.NUMBER(val[0][:value]) ; loc result, val[0] } | BOOLEAN { result = Factory.literal(val[0][:value]) ; loc result, val[0] } | DEFAULT { result = Factory.literal(:default) ; loc result, val[0] } | UNDEF { result = Factory.literal(:undef) ; loc result, val[0] } | NAME { result = Factory.QNAME_OR_NUMBER(val[0][:value]) ; loc result, val[0] } #---CALL FUNCTION # # Produces Model::CallNamedFunction call_function_expression : expression LPAREN assignments endcomma RPAREN { result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] } | expression LPAREN RPAREN { result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] } | expression LPAREN assignments endcomma RPAREN lambda { result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] result.lambda = val[5] } | expression LPAREN RPAREN lambda { result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] result.lambda = val[3] } #---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 assignments 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] } named_access : expression DOT NAME { result = val[0].dot(Factory.fqn(val[2][:value])) loc result, val[1], val[2] } #---LAMBDA # lambda : lambda_parameter_list lambda_rest { result = Factory.LAMBDA(val[0][:value], val[1][:value]) loc result, val[0][:start], val[1][:end] } lambda_rest : LBRACE statements RBRACE { result = {:end => val[2], :value =>val[1] } } | LBRACE RBRACE { result = {:end => val[1], :value => nil } } lambda_parameter_list : PIPE PIPE { result = {:start => val[0], :value => [] } } | PIPE parameters endcomma PIPE { result = {:start => val[0], :value => val[1] } } #---CONDITIONALS #--IF # 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 # 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) + result = Factory.UNLESS(val[1], nil, val[4]) 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 # 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 COLON LBRACE options_statements RBRACE { result = Factory.WHEN(val[0], val[3]); loc result, val[1], val[4] } options_statements : nil | statements # 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] } #---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 to source.select(QUERY).apply(ATTRIBUTE_OPERATIONS) # 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) # 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] } | TIMES FARROW expression { result = Factory.ATTRIBUTES_OP(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 endcomma nodeparent LBRACE statements RBRACE { result = add_definition(Factory.NODE(val[1], val[3], val[5])) loc result, val[0], val[6] } | NODE hostnames endcomma nodeparent LBRACE RBRACE { result = add_definition(Factory.NODE(val[1], val[3], nil)) loc result, val[0], val[5] } # 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 | quotedtext | DEFAULT { result = Factory.literal(:default); loc result, val[0] } | regex dotted_name : name_or_number { result = Factory.literal(val[0][:value]); loc result, val[0] } | dotted_name DOT name_or_number { result = Factory.concat(val[0], '.', val[2][:value]); loc result, val[0], val[2] } name_or_number : NAME | NUMBER # Produces Expression, since hostname is an Expression nodeparent : nil | INHERITS hostname { result = val[1] } #---FUNCTION DEFINITION # #function_definition # 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 | WORD | CLASSREF | 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 : untyped_parameter | typed_parameter untyped_parameter : regular_parameter | splat_parameter regular_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] } splat_parameter : TIMES regular_parameter { result = val[1]; val[1].captures_rest() } typed_parameter : parameter_type untyped_parameter { val[1].type_expr(val[0]) ; result = val[1] } parameter_type : type { result = val[0] } | type LBRACK expressions RBRACK { result = val[0][*val[2]] ; loc result, val[0], val[3] } #--VARIABLE # variable : VARIABLE { result = Factory.fqn(val[0][:value]).var ; loc result, val[0] } #---RESERVED WORDS # reserved_word : FUNCTION { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] } | PRIVATE { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] } | TYPE { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] } | ATTR { result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] } #---LITERALS (dynamic and static) # array : LISTSTART assignments endcomma RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] } | LISTSTART RBRACK { result = Factory.literal([]) ; loc result, val[0], val[1] } | LBRACK assignments endcomma RBRACK { result = Factory.LIST(val[1]); loc result, val[0], val[3] } | LBRACK RBRACK { result = Factory.literal([]) ; loc result, val[0], val[1] } 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[1] } hashpairs : hashpair { result = [val[0]] } | hashpairs COMMA hashpair { result = val[0].push val[2] } hashpair : assignment FARROW assignment { 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] } | WORD { 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 : assignment { 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 optional_statements { result = Factory.EPP(val[1], val[2]); loc result, val[0] } optional_statements : | statements 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 type : CLASSREF { result = Factory.QREF(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 | TYPE | ATTR | FUNCTION | PRIVATE 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 aadd1b1b5..c35b31617 100644 --- a/lib/puppet/pops/parser/eparser.rb +++ b/lib/puppet/pops/parser/eparser.rb @@ -1,2663 +1,2663 @@ # # 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', 755) # Make emacs happy # Local Variables: # mode: ruby # End: ...end egrammar.ra/module_eval... ##### State transition tables begin ### clist = [ '58,61,319,-238,59,53,155,54,238,80,-239,-227,335,280,-129,111,320,277', '371,336,370,-241,375,101,18,104,394,99,100,239,42,280,45,135,47,12,-240', '46,36,39,251,44,37,10,11,-238,113,66,17,103,110,38,-239,-227,15,16,-129', '301,112,278,58,61,67,-241,59,53,136,54,43,111,275,81,35,62,111,64,65', '63,-240,314,48,49,51,50,18,256,52,-236,111,342,42,107,45,254,47,115', '255,46,36,39,113,44,37,79,110,113,344,66,17,110,79,38,112,279,15,16', '79,112,280,113,58,61,67,110,59,53,238,54,43,-236,79,112,35,62,111,64', '65,269,270,66,48,49,51,50,18,71,52,239,331,371,42,370,45,328,47,12,352', '46,36,39,69,44,37,10,11,113,353,66,17,110,275,38,58,61,15,16,59,112', '258,257,58,61,67,276,59,53,355,54,43,72,73,74,35,62,111,64,65,256,302', '358,48,49,51,50,18,251,52,314,363,364,42,304,45,251,47,12,250,46,36', '39,249,44,37,10,11,113,368,66,17,110,308,38,361,372,15,16,374,112,75', '77,76,78,67,318,227,230,238,381,43,228,383,238,35,62,275,64,65,238,227', '66,48,49,51,50,58,61,52,239,59,53,66,54,324,79,79,217,216,387,239,71', '121,231,390,275,121,393,152,315,18,58,61,309,267,59,42,314,45,150,47', '12,238,46,36,39,397,44,37,10,11,374,399,66,17,66,400,38,401,122,15,16', '404,239,405,406,121,79,67,71,135,414,68,132,43,416,417,418,35,62,304', '64,65,,,,48,49,51,50,58,61,52,67,59,53,,54,410,80,,,,136,62,,,,,,,,', '101,18,104,,99,100,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,103', ',38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,81,35,62,,64,65,,,,48,49,51', '50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16', ',,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,', '42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61', '67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47', '12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,', '54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36', '39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35', '62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,', ',,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,', '48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38', ',,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18', ',52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,,,67,,,,,,43', ',,,35,62,,64,65,,,,48,49,51,50,58,61,52,,59,53,,54,408,,,,,,,,,,,,,', ',,18,58,61,,,59,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,', '15,16,,,,,,,67,,135,,,132,43,,,,35,62,,64,65,,,,48,49,51,50,58,61,52', '67,59,53,,54,403,80,,,,136,62,,,,,,,,,101,18,104,,99,100,,42,,45,,47', '12,,46,36,39,,44,37,10,11,,,66,17,103,,38,,,15,16,,,,,58,61,67,,59,53', ',54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36', '39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,', '15,16,,,,,,,67,,,,,,43,,,,35,62,,64,65,,,,48,49,51,50,58,61,52,,59,53', ',54,337,80,,,,,,,,,,,,,,101,18,104,,99,100,,42,,45,,47,12,,46,36,39', ',44,37,10,11,,,66,17,103,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35', '62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,', ',,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,139,54,43,,,,35,62,,64,65', ',,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17', ',,38,,,15,16,,,,,58,61,67,,59,53,141,54,43,,,,35,62,,64,65,,,,48,49', '51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,', '15,16,,,,,,,67,,,,,,43,,,,35,62,,64,65,,,,48,49,51,50,58,61,52,,59,53', ',54,143,80,,,,,,,,,,,,,,101,18,104,,99,100,,42,,45,,47,12,,46,36,39', ',44,37,10,11,,,66,17,103,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35', '62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10', '11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,', ',,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,', '38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50', '18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16', ',,,,58,61,67,,59,53,,154,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,', ',42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67', ',59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12', ',46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54', '43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39', ',44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38', ',,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18', ',52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,', ',58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42', ',45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67', ',59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12', ',46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54', '43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39', ',44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11', ',,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38', ',,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18', ',52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,', ',58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,171', '185,177,186,47,178,188,179,36,170,,173,168,,,,,66,17,189,184,169,,,15', '167,,,,,,,67,,,,,187,172,,,,35,62,,64,65,,,,180,181,183,182,58,61,52', '80,59,53,,54,,,,,,,,,,101,,104,,99,100,,18,,,,,,42,,45,,47,115,,46,36', '39,,44,37,103,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35', '62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,', ',,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,', '48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38', ',,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18', ',52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53', ',54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36', '39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,', '15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,', '52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53', ',54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36', '39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,', '15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,', '52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53', ',54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36', '39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,', '15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,', '52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53', ',54,43,,,213,35,62,,64,65,,,,48,49,51,50,18,215,52,,,,42,,45,,47,12', ',46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54', '43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39', ',44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64', '65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17', ',,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51', '50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16', ',,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,', '42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67', ',59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115', ',46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,', '276,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39', ',44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64', '65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17', ',,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51', '50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15', '16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52', ',,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61', '67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47', '115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54', '43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39', ',44,37,,,,,66,17,,,38,,,15,16,,,,,,,67,,,,,,43,,,,35,62,,64,65,,,,48', '49,51,50,58,61,52,,59,53,,54,143,,,,,,,,,,,,,,,,18,,,,,,42,,45,,47,12', ',46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54', '43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39', ',44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64', '65,,,,48,49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66', '17,,,38,,,15,16,,,,,,,67,,,,,,43,,,,35,62,,64,65,,,,48,49,51,50,58,61', '52,,59,53,,54,312,,,,,,,,,,,,,,,,18,,,,,,42,,45,,47,12,,46,36,39,,44', '37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64', '65,,,,48,49,51,50,18,243,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11', ',,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48', '49,51,50,18,,52,,,,42,,45,,47,12,,46,36,39,,44,37,10,11,,,66,17,,,38', ',,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18', ',52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58', '61,67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45', ',47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,,,67,,,,,,43,,,', '35,62,,64,65,,,,48,49,51,50,58,61,52,,59,53,,54,376,,,,,,,,,,,,,,,,18', ',,,,,42,,45,,47,115,,46,36,39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61', '67,,59,53,,54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47', '12,,46,36,39,,44,37,10,11,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,', '54,43,,,,35,62,,64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36', '39,,44,37,,,,,66,17,,,38,,,15,16,,,,,58,61,67,,59,53,,54,43,,,,35,62', ',64,65,,,,48,49,51,50,18,,52,,,,42,,45,,47,115,,46,36,39,,44,37,,,,', '66,17,,,38,,,15,16,,,,,,,67,,,,,,43,,,,35,62,,64,65,,,,48,49,51,50,58', '61,52,,59,53,,54,322,,,,,,,,,,,,,,,,18,,,,,,42,,45,,47,12,,46,36,39', ',44,37,10,11,80,,66,17,,,38,,,15,16,,,91,101,,104,67,99,100,,92,,43', ',,,35,62,,64,65,,,,48,49,51,50,,103,52,,,,80,,,84,85,87,86,89,90,,82', '83,96,91,101,305,104,81,99,100,,92,94,93,95,,58,61,,,59,,,,,,,,88,,103', ',,,98,97,,,84,85,87,86,89,90,,82,83,80,,246,,,81,,,135,,,132,96,91,101', ',104,,99,100,,92,94,93,95,,88,,,,,67,,,,,,,,,103,136,62,,98,97,,,84', '85,87,86,89,90,,82,83,80,,245,,,81,,,,,,,96,91,101,,104,,99,100,,92', '94,93,95,,88,,,,,,,,,,,,,,103,,,,98,97,,,84,85,87,86,89,90,,82,83,80', ',244,,,81,,,,,,,96,91,101,,104,80,99,100,,92,94,93,95,,88,,,,,101,,104', ',99,100,,,,103,,,,98,97,,80,84,85,87,86,89,90,,82,83,103,,96,91,101', '81,104,,99,100,,92,94,93,95,82,83,,,,,,81,,,,88,,,,103,,,,98,97,,80', '84,85,87,86,89,90,,82,83,,,96,91,101,81,104,,99,100,,92,94,93,95,,,', ',,,,,,,,88,,,,103,,,,98,97,,80,84,85,87,86,89,90,,82,83,,,96,91,101', '81,104,,99,100,,92,94,93,95,,269,270,,,,,,,,,88,,,,103,,58,61,98,97', '59,80,84,85,87,86,89,90,,82,83,,,96,91,101,81,104,,99,100,,92,94,93', '95,,,,,,,,,,135,,88,132,,,103,,,,98,97,,80,84,85,87,86,89,90,,82,83', '67,,,,101,81,104,,99,100,136,62,,,,80,,,,,281,,,,,,88,96,91,101,103', '104,,99,100,,92,94,93,95,87,86,,,,82,83,,,,,,81,,,103,,,,98,97,,80,84', '85,87,86,89,90,,82,83,,88,96,91,101,81,104,,99,100,,92,94,93,95,,,,', ',,,,,,,88,,,,103,,,,,97,,80,84,85,87,86,89,90,,82,83,,,96,91,101,81', '104,,99,100,,92,94,93,95,80,,,,,,,,,,,88,,,101,103,104,,99,100,80,,', '84,85,87,86,89,90,,82,83,96,91,101,273,104,81,99,100,103,92,94,93,95', ',,,,,,,,,,82,83,,88,,103,,81,,98,97,,80,84,85,87,86,89,90,,82,83,,,96', '91,101,81,104,,99,100,,92,94,93,95,,,,,,,,,,,,88,,,,103,,,,98,97,,80', '84,85,87,86,89,90,,82,83,,,,,101,81,104,,99,100,,,,,,80,,,,,,,,,,,88', ',91,101,103,104,,99,100,80,92,,84,85,87,86,,,,82,83,,91,101,,104,81', '99,100,103,92,,,,80,,,84,85,87,86,89,90,,82,83,,88,101,103,104,81,99', '100,,,,84,85,87,86,89,90,80,82,83,,,,,,81,88,,103,96,91,101,,104,,99', '100,,92,94,93,95,,82,83,,88,,,,81,,,,,,,103,,,,98,97,,80,84,85,87,86', '89,90,,82,83,,,96,91,101,81,104,,99,100,,92,94,93,95,,,,,,,,,,,,88,', ',,103,,,,98,97,,80,84,85,87,86,89,90,,82,83,,,96,91,101,81,104,,99,100', ',92,94,93,95,,,,,,,,,,,,88,,,,103,,,,98,97,,80,84,85,87,86,89,90,,82', '83,,,96,91,101,81,104,,99,100,,92,94,93,95,,,,,,,,,,,,88,,,,103,,,,98', '97,,80,84,85,87,86,89,90,,82,83,,,,91,101,81,104,,99,100,,92,,80,,,', ',,,,,,,,,88,101,,104,103,99,100,,,,,,84,85,87,86,89,90,,82,83,,,,,,81', '103,,,,,80,,,84,85,87,86,89,90,,82,83,,,101,88,104,81,99,100,,,,80,', ',,,,,,,,,,,,101,88,104,103,99,100,,,,,,84,85,87,86,89,90,,82,83,,,,', ',81,103,,,,,80,,,,,87,86,,,,82,83,,,101,88,104,81,99,100,,,,80,,,,,', ',,,,,,96,91,101,88,104,103,99,100,,92,94,93,95,84,85,87,86,,,,82,83', ',,,,,81,103,,,,98,97,,,84,85,87,86,89,90,,82,83,,,,88,,81,,,293,185', '292,186,,290,188,294,,287,,289,291,,,,,,88,189,184,295,,,,288,,,,,,', ',,,,,187,296,,,,,,,,,,,,299,300,298,297,293,185,292,186,,290,188,294', ',287,,289,291,,,,,,,189,184,295,,,,288,,,,,,,,,,,,187,296,,,,,,,,,,', ',299,300,298,297,293,185,292,186,,290,188,294,,287,,289,291,,,,,,,189', '184,295,,,,288,,,,,,,,,,,,187,296,,,,,,,,,,,,299,300,298,297,293,185', '292,186,,290,188,294,,287,,289,291,,,,,,,189,184,295,,,,288,,,,,,,,', ',,,187,296,,,,,,,,,,,,299,300,298,297' ] racc_action_table = arr = ::Array.new(6785, 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,242,182,0,0,68,0,240,193,183,168,252,325,170,45,242,176,368,253', '368,181,325,193,0,193,367,193,193,240,0,367,0,250,0,0,180,0,0,0,214', '0,0,0,0,182,45,0,0,193,45,0,183,168,0,0,170,219,45,176,405,405,0,181', '405,405,250,405,0,178,166,193,0,0,115,0,0,0,180,266,0,0,0,0,405,271', '0,169,12,272,405,12,405,142,405,405,142,405,405,405,178,405,405,164', '178,115,274,405,405,115,163,405,178,191,405,405,162,115,191,12,4,4,405', '12,4,4,314,4,405,169,161,12,405,405,177,405,405,342,342,314,405,405', '405,405,4,156,405,314,248,322,4,322,4,247,4,4,282,4,4,4,4,4,4,4,4,177', '284,4,4,177,286,4,150,150,4,4,150,177,147,147,400,400,4,288,400,400', '303,400,4,7,7,7,4,4,308,4,4,145,221,306,4,4,4,4,400,140,4,310,311,313', '400,222,400,138,400,400,130,400,400,400,128,400,400,400,400,308,321', '400,400,308,225,400,308,323,400,400,324,308,7,7,7,7,400,241,127,120', '121,329,400,118,341,239,400,400,343,400,400,152,108,121,400,400,400', '400,245,245,400,121,245,245,152,245,245,106,105,102,101,351,152,70,353', '121,354,357,215,362,63,238,245,179,179,227,152,179,245,232,245,62,245', '245,227,245,245,245,371,245,245,245,245,372,374,245,245,227,375,245', '378,41,245,245,385,227,386,392,40,8,245,5,179,402,1,179,245,407,409', '411,245,245,415,245,245,,,,245,245,245,245,399,399,245,179,399,399,', '399,399,194,,,,179,179,,,,,,,,,194,399,194,,194,194,,399,,399,,399,399', ',399,399,399,,399,399,399,399,,,399,399,194,,399,,,399,399,,,,,246,246', '399,,246,246,,246,399,,,194,399,399,,399,399,,,,399,399,399,399,246', ',399,,,,246,,246,,246,246,,246,246,246,,246,246,,,,,246,246,,,246,,', '246,246,,,,,10,10,246,,10,10,,10,246,,,,246,246,,246,246,,,,246,246', '246,246,10,,246,,,,10,,10,,10,10,,10,10,10,,10,10,10,10,,,10,10,,,10', ',,10,10,,,,,11,11,10,,11,11,,11,10,,,,10,10,,10,10,,,,10,10,10,10,11', ',10,,,,11,,11,,11,11,,11,11,11,,11,11,11,11,,,11,11,,,11,,,11,11,,,', ',251,251,11,,251,251,,251,11,,,,11,11,,11,11,,,,11,11,11,11,251,,11', ',,,251,,251,,251,251,,251,251,251,,251,251,251,251,,,251,251,,,251,', ',251,251,,,,,15,15,251,,15,15,,15,251,,,,251,251,,251,251,,,,251,251', '251,251,15,,251,,,,15,,15,,15,15,,15,15,15,,15,15,,,,,15,15,,,15,,,15', '15,,,,,16,16,15,,16,16,,16,15,,,,15,15,,15,15,,,,15,15,15,15,16,,15', ',,,16,,16,,16,16,,16,16,16,,16,16,,,,,16,16,,,16,,,16,16,,,,,17,17,16', ',17,17,,17,16,,,,16,16,,16,16,,,,16,16,16,16,17,,16,,,,17,,17,,17,17', ',17,17,17,,17,17,,,,,17,17,,,17,,,17,17,,,,,18,18,17,,18,18,,18,17,', ',,17,17,,17,17,,,,17,17,17,17,18,,17,,,,18,,18,,18,18,,18,18,18,,18', '18,18,18,,,18,18,,,18,,,18,18,,,,,,,18,,,,,,18,,,,18,18,,18,18,,,,18', '18,18,18,397,397,18,,397,397,,397,397,,,,,,,,,,,,,,,,397,46,46,,,46', '397,,397,,397,397,,397,397,397,,397,397,397,397,,,397,397,,,397,,,397', '397,,,,,,,397,,46,,,46,397,,,,397,397,,397,397,,,,397,397,397,397,381', '381,397,46,381,381,,381,381,117,,,,46,46,,,,,,,,,117,381,117,,117,117', ',381,,381,,381,381,,381,381,381,,381,381,381,381,,,381,381,117,,381', ',,381,381,,,,,42,42,381,,42,42,,42,381,,,,381,381,,381,381,,,,381,381', '381,381,42,,381,,,,42,,42,,42,42,,42,42,42,,42,42,,,,,42,42,,,42,,,42', '42,,,,,43,43,42,,43,43,,43,42,,,,42,42,,42,42,,,,42,42,42,42,43,,42', ',,,43,,43,,43,43,,43,43,43,,43,43,,,,,43,43,,,43,,,43,43,,,,,44,44,43', ',44,44,,44,43,,,,43,43,,43,43,,,,43,43,43,43,44,,43,,,,44,,44,,44,44', ',44,44,44,,44,44,,,,,44,44,,,44,,,44,44,,,,,,,44,,,,,,44,,,,44,44,,44', '44,,,,44,44,44,44,255,255,44,,255,255,,255,255,192,,,,,,,,,,,,,,192', '255,192,,192,192,,255,,255,,255,255,,255,255,255,,255,255,255,255,,', '255,255,192,,255,,,255,255,,,,,213,213,255,,213,213,,213,255,,,,255', '255,,255,255,,,,255,255,255,255,213,,255,,,,213,,213,,213,213,,213,213', '213,,213,213,,,,,213,213,,,213,,,213,213,,,,,52,52,213,,52,52,52,52', '213,,,,213,213,,213,213,,,,213,213,213,213,52,,213,,,,52,,52,,52,52', ',52,52,52,,52,52,52,52,,,52,52,,,52,,,52,52,,,,,53,53,52,,53,53,53,53', '52,,,,52,52,,52,52,,,,52,52,52,52,53,,52,,,,53,,53,,53,53,,53,53,53', ',53,53,53,53,,,53,53,,,53,,,53,53,,,,,,,53,,,,,,53,,,,53,53,,53,53,', ',,53,53,53,53,54,54,53,,54,54,,54,54,114,,,,,,,,,,,,,,114,54,114,,114', '114,,54,,54,,54,54,,54,54,54,,54,54,54,54,,,54,54,114,,54,,,54,54,,', ',,60,60,54,,60,60,,60,54,,,,54,54,,54,54,,,,54,54,54,54,60,,54,,,,60', ',60,,60,60,,60,60,60,,60,60,60,60,,,60,60,,,60,,,60,60,,,,,370,370,60', ',370,370,,370,60,,,,60,60,,60,60,,,,60,60,60,60,370,,60,,,,370,,370', ',370,370,,370,370,370,,370,370,,,,,370,370,,,370,,,370,370,,,,,256,256', '370,,256,256,,256,370,,,,370,370,,370,370,,,,370,370,370,370,256,,370', ',,,256,,256,,256,256,,256,256,256,,256,256,256,256,,,256,256,,,256,', ',256,256,,,,,65,65,256,,65,65,,65,256,,,,256,256,,256,256,,,,256,256', '256,256,65,,256,,,,65,,65,,65,65,,65,65,65,,65,65,,,,,65,65,,,65,,,65', '65,,,,,358,358,65,,358,358,,358,65,,,,65,65,,65,65,,,,65,65,65,65,358', ',65,,,,358,,358,,358,358,,358,358,358,,358,358,358,358,,,358,358,,,358', ',,358,358,,,,,69,69,358,,69,69,,69,358,,,,358,358,,358,358,,,,358,358', '358,358,69,,358,,,,69,,69,,69,69,,69,69,69,,69,69,69,69,,,69,69,,,69', ',,69,69,,,,,352,352,69,,352,352,,352,69,,,,69,69,,69,69,,,,69,69,69', '69,352,,69,,,,352,,352,,352,352,,352,352,352,,352,352,,,,,352,352,,', '352,,,352,352,,,,,71,71,352,,71,71,,71,352,,,,352,352,,352,352,,,,352', '352,352,352,71,,352,,,,71,,71,,71,71,,71,71,71,,71,71,71,71,,,71,71', ',,71,,,71,71,,,,,72,72,71,,72,72,,72,71,,,,71,71,,71,71,,,,71,71,71', '71,72,,71,,,,72,,72,,72,72,,72,72,72,,72,72,72,72,,,72,72,,,72,,,72', '72,,,,,73,73,72,,73,73,,73,72,,,,72,72,,72,72,,,,72,72,72,72,73,,72', ',,,73,,73,,73,73,,73,73,73,,73,73,73,73,,,73,73,,,73,,,73,73,,,,,74', '74,73,,74,74,,74,73,,,,73,73,,73,73,,,,73,73,73,73,74,,73,,,,74,,74', ',74,74,,74,74,74,,74,74,74,74,,,74,74,,,74,,,74,74,,,,,75,75,74,,75', '75,,75,74,,,,74,74,,74,74,,,,74,74,74,74,75,,74,,,,75,,75,,75,75,,75', '75,75,,75,75,75,75,,,75,75,,,75,,,75,75,,,,,76,76,75,,76,76,,76,75,', ',,75,75,,75,75,,,,75,75,75,75,76,,75,,,,76,,76,,76,76,,76,76,76,,76', '76,76,76,,,76,76,,,76,,,76,76,,,,,77,77,76,,77,77,,77,76,,,,76,76,,76', '76,,,,76,76,76,76,77,,76,,,,77,,77,,77,77,,77,77,77,,77,77,77,77,,,77', '77,,,77,,,77,77,,,,,78,78,77,,78,78,,78,77,,,,77,77,,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,,79,78,,,,78,78,,78,78,,,,78,78,78,78,79,', '78,,,,79,79,79,79,79,79,79,79,79,79,,79,79,,,,,79,79,79,79,79,,,79,79', ',,,,,,79,,,,,79,79,,,,79,79,,79,79,,,,79,79,79,79,80,80,79,116,80,80', ',80,,,,,,,,,,116,,116,,116,116,,80,,,,,,80,,80,,80,80,,80,80,80,,80', '80,116,,,,80,80,,,80,,,80,80,,,,,81,81,80,,81,81,,81,80,,,,80,80,,80', '80,,,,80,80,80,80,81,,80,,,,81,,81,,81,81,,81,81,81,,81,81,,,,,81,81', ',,81,,,81,81,,,,,82,82,81,,82,82,,82,81,,,,81,81,,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,,83,82,,,,82,82,,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,,84,83,,,,83,83,,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,,85,84,,,,84', '84,,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,,86,85,,,,85,85,,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,,87,86,,,,86,86,,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,,88,87,,,,87,87,,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,,89,88,', ',,88,88,,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,,90,89,,,,89,89,,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,,91,90,,,,90,90,,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,,92,91,,,,91,91,,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', ',93,92,,,,92,92,,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,,94,93,,,,93,93', ',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,,95,94,,,,94,94,,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,,96,95,,,,95,95,,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,,97,96,,,,96,96,,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,,98,97,', ',,97,97,,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,,99,98,,,,98,98,,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,,100,99,,,99,99,99,,99,99,,,,99,99', '99,99,100,100,99,,,,100,,100,,100,100,,100,100,100,,100,100,100,100', ',,100,100,,,100,,,100,100,,,,,173,173,100,,173,173,,173,100,,,,100,100', ',100,100,,,,100,100,100,100,173,,100,,,,173,,173,,173,173,,173,173,173', ',173,173,,,,,173,173,,,173,,,173,173,,,,,172,172,173,,172,172,,172,173', ',,,173,173,,173,173,,,,173,173,173,173,172,,173,,,,172,,172,,172,172', ',172,172,172,,172,172,,,,,172,172,,,172,,,172,172,,,,,103,103,172,,103', '103,,103,172,,,,172,172,,172,172,,,,172,172,172,172,103,,172,,,,103', ',103,,103,103,,103,103,103,,103,103,,,,,103,103,,,103,,,103,103,,,,', '104,104,103,,104,104,,104,103,,,,103,103,,103,103,,,,103,103,103,103', '104,,103,,,,104,,104,,104,104,,104,104,104,,104,104,,,,,104,104,,,104', ',,104,104,,,,,171,171,104,,171,171,,171,104,,,,104,104,,104,104,,,,104', '104,104,104,171,,104,,,,171,,171,,171,171,,171,171,171,,171,171,,,,', '171,171,,,171,,,171,171,,,,,167,167,171,,167,167,,167,171,,167,,171', '171,,171,171,,,,171,171,171,171,167,,171,,,,167,,167,,167,167,,167,167', '167,,167,167,,,,,167,167,,,167,,,167,167,,,,,107,107,167,,107,107,,107', '167,,,,167,167,,167,167,,,,167,167,167,167,107,,167,,,,107,,107,,107', '107,,107,107,107,,107,107,,,,,107,107,,,107,,,107,107,,,,,261,261,107', ',261,261,,261,107,,,,107,107,,107,107,,,,107,107,107,107,261,,107,,', ',261,,261,,261,261,,261,261,261,,261,261,261,261,,,261,261,,,261,,,261', '261,,,,,276,276,261,,276,276,,276,261,,,,261,261,,261,261,,,,261,261', '261,261,276,,261,,,,276,,276,,276,276,,276,276,276,,276,276,,,,,276', '276,,,276,,,276,276,,,,,277,277,276,,277,277,,277,276,,,,276,276,,276', '276,,,,276,276,276,276,277,,276,,,,277,,277,,277,277,,277,277,277,,277', '277,,,,,277,277,,,277,,,277,277,,,,,278,278,277,,278,278,,278,277,,', ',277,277,,277,277,,,,277,277,277,277,278,,277,,,,278,,278,,278,278,', '278,278,278,,278,278,,,,,278,278,,,278,,,278,278,,,,,,,278,,,,,,278', ',,,278,278,,278,278,,,,278,278,278,278,154,154,278,,154,154,,154,154', ',,,,,,,,,,,,,,,154,,,,,,154,,154,,154,154,,154,154,154,,154,154,154', '154,,,154,154,,,154,,,154,154,,,,,304,304,154,,304,304,,304,154,,,,154', '154,,154,154,,,,154,154,154,154,304,,154,,,,304,,304,,304,304,,304,304', '304,,304,304,,,,,304,304,,,304,,,304,304,,,,,328,328,304,,328,328,,328', '304,,,,304,304,,304,304,,,,304,304,304,304,328,,304,,,,328,,328,,328', '328,,328,328,328,,328,328,328,328,,,328,328,,,328,,,328,328,,,,,,,328', ',,,,,328,,,,328,328,,328,328,,,,328,328,328,328,230,230,328,,230,230', ',230,230,,,,,,,,,,,,,,,,230,,,,,,230,,230,,230,230,,230,230,230,,230', '230,230,230,,,230,230,,,230,,,230,230,,,,,122,122,230,,122,122,,122', '230,,,,230,230,,230,230,,,,230,230,230,230,122,122,230,,,,122,,122,', '122,122,,122,122,122,,122,122,122,122,,,122,122,,,122,,,122,122,,,,', '151,151,122,,151,151,,151,122,,,,122,122,,122,122,,,,122,122,122,122', '151,,122,,,,151,,151,,151,151,,151,151,151,,151,151,151,151,,,151,151', ',,151,,,151,151,,,,,280,280,151,,280,280,,280,151,,,,151,151,,151,151', ',,,151,151,151,151,280,,151,,,,280,,280,,280,280,,280,280,280,,280,280', ',,,,280,280,,,280,,,280,280,,,,,281,281,280,,281,281,,281,280,,,,280', '280,,280,280,,,,280,280,280,280,281,,280,,,,281,,281,,281,281,,281,281', '281,,281,281,,,,,281,281,,,281,,,281,281,,,,,,,281,,,,,,281,,,,281,281', ',281,281,,,,281,281,281,281,326,326,281,,326,326,,326,326,,,,,,,,,,', ',,,,,326,,,,,,326,,326,,326,326,,326,326,326,,326,326,,,,,326,326,,', '326,,,326,326,,,,,319,319,326,,319,319,,319,326,,,,326,326,,326,326', ',,,326,326,326,326,319,,326,,,,319,,319,,319,319,,319,319,319,,319,319', '319,319,,,319,319,,,319,,,319,319,,,,,318,318,319,,318,318,,318,319', ',,,319,319,,319,319,,,,319,319,319,319,318,,319,,,,318,,318,,318,318', ',318,318,318,,318,318,,,,,318,318,,,318,,,318,318,,,,,315,315,318,,315', '315,,315,318,,,,318,318,,318,318,,,,318,318,318,318,315,,318,,,,315', ',315,,315,315,,315,315,315,,315,315,,,,,315,315,,,315,,,315,315,,,,', ',,315,,,,,,315,,,,315,315,,315,315,,,,315,315,315,315,244,244,315,,244', '244,,244,244,,,,,,,,,,,,,,,,244,,,,,,244,,244,,244,244,,244,244,244', ',244,244,244,244,205,,244,244,,,244,,,244,244,,,205,205,,205,244,205', '205,,205,,244,,,,244,244,,244,244,,,,244,244,244,244,,205,244,,,,223', ',,205,205,205,205,205,205,,205,205,223,223,223,223,223,205,223,223,', '223,223,223,223,,249,249,,,249,,,,,,,,205,,223,,,,223,223,,,223,223', '223,223,223,223,,223,223,126,,126,,,223,,,249,,,249,126,126,126,,126', ',126,126,,126,126,126,126,,223,,,,,249,,,,,,,,,126,249,249,,126,126', ',,126,126,126,126,126,126,,126,126,125,,125,,,126,,,,,,,125,125,125', ',125,,125,125,,125,125,125,125,,126,,,,,,,,,,,,,,125,,,,125,125,,,125', '125,125,125,125,125,,125,125,123,,123,,,125,,,,,,,123,123,123,,123,199', '123,123,,123,123,123,123,,125,,,,,199,,199,,199,199,,,,123,,,,123,123', ',9,123,123,123,123,123,123,,123,123,199,,9,9,9,123,9,,9,9,,9,9,9,9,199', '199,,,,,,199,,,,123,,,,9,,,,9,9,,153,9,9,9,9,9,9,,9,9,,,153,153,153', '9,153,,153,153,,153,153,153,153,,,,,,,,,,,,9,,,,153,,,,153,153,,190', '153,153,153,153,153,153,,153,153,,,190,190,190,153,190,,190,190,,190', '190,190,190,,153,153,,,,,,,,,153,,,,190,,331,331,190,190,331,218,190', '190,190,190,190,190,,190,190,,,218,218,218,190,218,,218,218,,218,218', '218,218,,,,,,,,,,331,,190,331,,,218,,,,218,218,,195,218,218,218,218', '218,218,,218,218,331,,,,195,218,195,,195,195,331,331,,,,210,,,,,210', ',,,,,218,210,210,210,195,210,,210,210,,210,210,210,210,195,195,,,,195', '195,,,,,,195,,,210,,,,210,210,,209,210,210,210,210,210,210,,210,210', ',195,209,209,209,210,209,,209,209,,209,209,209,209,,,,,,,,,,,,210,,', ',209,,,,,209,,208,209,209,209,209,209,209,,209,209,,,208,208,208,209', '208,,208,208,,208,208,208,208,198,,,,,,,,,,,209,,,198,208,198,,198,198', '165,,,208,208,208,208,208,208,,208,208,165,165,165,165,165,208,165,165', '198,165,165,165,165,,,,,,,,,,,198,198,,208,,165,,198,,165,165,,346,165', '165,165,165,165,165,,165,165,,,346,346,346,165,346,,346,346,,346,346', '346,346,,,,,,,,,,,,165,,,,346,,,,346,346,,200,346,346,346,346,346,346', ',346,346,,,,,200,346,200,,200,200,,,,,,207,,,,,,,,,,,346,,207,207,200', '207,,207,207,206,207,,200,200,200,200,,,,200,200,,206,206,,206,200,206', '206,207,206,,,,197,,,207,207,207,207,207,207,,207,207,,200,197,206,197', '207,197,197,,,,206,206,206,206,206,206,366,206,206,,,,,,206,207,,197', '366,366,366,,366,,366,366,,366,366,366,366,,197,197,,206,,,,197,,,,', ',,366,,,,366,366,,348,366,366,366,366,366,366,,366,366,,,348,348,348', '366,348,,348,348,,348,348,348,348,,,,,,,,,,,,366,,,,348,,,,348,348,', '349,348,348,348,348,348,348,,348,348,,,349,349,349,348,349,,349,349', ',349,349,349,349,,,,,,,,,,,,348,,,,349,,,,349,349,,350,349,349,349,349', '349,349,,349,349,,,350,350,350,349,350,,350,350,,350,350,350,350,,,', ',,,,,,,,349,,,,350,,,,350,350,,204,350,350,350,350,350,350,,350,350', ',,,204,204,350,204,,204,204,,204,,203,,,,,,,,,,,,,350,203,,203,204,203', '203,,,,,,204,204,204,204,204,204,,204,204,,,,,,204,203,,,,,202,,,203', '203,203,203,203,203,,203,203,,,202,204,202,203,202,202,,,,196,,,,,,', ',,,,,,,196,203,196,202,196,196,,,,,,202,202,202,202,202,202,,202,202', ',,,,,202,196,,,,,201,,,,,196,196,,,,196,196,,,201,202,201,196,201,201', ',,,347,,,,,,,,,,,,347,347,347,196,347,201,347,347,,347,347,347,347,201', '201,201,201,,,,201,201,,,,,,201,347,,,,347,347,,,347,347,347,347,347', '347,,347,347,,,,201,,347,,,273,273,273,273,,273,273,273,,273,,273,273', ',,,,,347,273,273,273,,,,273,,,,,,,,,,,,273,273,,,,,,,,,,,,273,273,273', '273,275,275,275,275,,275,275,275,,275,,275,275,,,,,,,275,275,275,,,', '275,,,,,,,,,,,,275,275,,,,,,,,,,,,275,275,275,275,305,305,305,305,,305', '305,305,,305,,305,305,,,,,,,305,305,305,,,,305,,,,,,,,,,,,305,305,,', ',,,,,,,,,305,305,305,305,217,217,217,217,,217,217,217,,217,,217,217', ',,,,,,217,217,217,,,,217,,,,,,,,,,,,217,217,,,,,,,,,,,,217,217,217,217' ] racc_action_check = arr = ::Array.new(6785, 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, 330, nil, nil, 118, 314, nil, 173, 316, 5605, 466, 526, 82, nil, nil, 646, 706, 766, 826, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 253, 291, 1054, 1114, 1174, 9, 935, nil, nil, nil, nil, nil, 1378, 1438, 1522, nil, nil, nil, nil, nil, 1582, nil, 221, 215, nil, 1762, nil, nil, 6, 1882, 266, 2002, 2062, 2122, 2182, 2242, 2302, 2362, 2422, 2482, 2566, 2626, 2686, 2746, 2806, 2866, 2926, 2986, 3046, 3106, 3166, 3226, 3286, 3346, 3406, 3466, 3526, 3586, 3646, 3706, 3766, 235, 266, 3946, 4006, 265, 264, 4186, 232, nil, nil, nil, nil, nil, 1526, 68, 2564, 998, 222, nil, 236, 210, 4774, 5558, nil, 5501, 5444, 218, 207, nil, 195, nil, nil, nil, nil, nil, nil, nil, 200, nil, 192, nil, 83, nil, nil, 185, nil, 174, nil, nil, 170, 4834, 221, 5652, 4510, nil, 132, nil, nil, nil, nil, 121, 107, 101, 94, 5957, 57, 4126, -1, 75, 2, 4066, 3886, 3826, nil, nil, 5, 128, 63, 287, 24, 9, -9, -2, nil, nil, nil, nil, nil, nil, 5699, 105, 1262, 2, 350, 5793, 6429, 6121, 5937, 5575, 6051, 6474, 6406, 6361, 6338, 5342, 6096, 6076, 5912, 5865, 5818, nil, nil, 1318, 27, 213, nil, 6699, 5746, 9, nil, 174, 169, 5387, nil, 192, nil, 264, nil, nil, 4714, nil, 282, nil, nil, nil, nil, nil, 271, 215, -28, 236, -11, nil, 5302, 262, 406, 144, 110, 5418, -8, 586, 4, 11, nil, 1258, 1702, nil, nil, nil, nil, 4246, nil, nil, nil, nil, 66, nil, nil, nil, nil, 73, 79, 6537, 96, 6591, 4306, 4366, 4426, nil, 4894, 4954, 143, nil, 139, nil, 157, nil, 171, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 176, 4570, 6645, 190, nil, 188, nil, 194, 198, nil, 138, 90, 5218, nil, nil, 5158, 5098, nil, 216, 116, 223, 203, 0, 5038, nil, 4630, 238, nil, 5746, nil, nil, nil, nil, nil, nil, nil, nil, nil, 179, 57, 241, nil, nil, 6004, 6497, 6197, 6244, 6291, 267, 1942, 209, 272, nil, nil, 270, 1822, nil, nil, nil, 258, nil, nil, nil, 6150, 18, -15, nil, 1642, 295, 276, nil, 301, 305, nil, nil, 306, nil, nil, 994, nil, nil, nil, 310, 280, nil, nil, nil, nil, nil, 313, nil, nil, nil, nil, 910, nil, 346, 178, nil, 319, nil, nil, 58, nil, 323, nil, 324, nil, 325, nil, nil, nil, 296, nil, nil, nil, nil ] racc_action_default = [ -3, -243, -1, -2, -4, -5, -8, -10, -16, -21, -243, -243, -243, -33, -34, -243, -243, -243, -243, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -86, -90, -243, -243, -243, -243, -243, -176, -177, -178, -179, -180, -243, -243, -243, -191, -192, -193, -194, -195, -243, -197, -243, -210, -213, -243, -218, -219, -243, -243, -7, -243, -243, -243, -243, -243, -243, -243, -243, -126, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -243, -121, -242, -242, -22, -23, -243, -242, -136, -157, -158, -159, -160, -46, -243, -47, -54, -243, -87, -243, -243, -243, -243, -97, -243, -243, -242, -220, -145, -147, -148, -149, -150, -151, -153, -154, -14, -220, -182, -220, -184, -243, -187, -188, -243, -196, -243, -201, -204, -243, -208, -243, -243, -243, 420, -6, -9, -11, -12, -13, -17, -18, -19, -20, -243, -220, -243, -79, -80, -81, -231, -237, -225, -127, -130, -243, -228, -226, -234, -177, -178, -179, -180, -224, -229, -230, -232, -233, -235, -59, -243, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -48, -49, -50, -51, -52, -53, -55, -56, -243, -57, -115, -243, -220, -83, -91, -126, -125, -243, -124, -243, -222, -243, -28, -242, -161, -243, -58, -92, -243, -95, -220, -164, -166, -167, -168, -169, -171, -243, -243, -174, -243, -89, -243, -243, -243, -243, -242, -221, -243, -221, -243, -243, -185, -243, -243, -198, -199, -200, -202, -243, -205, -206, -207, -209, -220, -211, -214, -216, -217, -8, -243, -126, -243, -221, -243, -243, -243, -35, -243, -243, -220, -117, -243, -85, -220, -129, -243, -225, -226, -227, -228, -231, -234, -236, -237, -238, -239, -240, -241, -122, -123, -243, -223, -126, -243, -139, -243, -162, -220, -243, -94, -243, -221, -243, -172, -173, -243, -243, -88, -243, -100, -243, -106, -243, -243, -110, -242, -243, -155, -243, -146, -152, -15, -181, -183, -186, -189, -190, -203, -243, -243, -220, -26, -128, -133, -131, -132, -60, -119, -243, -221, -82, -243, -25, -29, -220, -242, -140, -141, -142, -243, -93, -96, -165, -170, -243, -100, -99, -243, -243, -106, -105, -243, -243, -109, -111, -243, -137, -138, -243, -156, -212, -215, -243, -30, -116, -118, -84, -120, -27, -243, -163, -175, -98, -101, -243, -104, -243, -242, -134, -243, -144, -24, -31, -135, -243, -103, -243, -108, -243, -113, -114, -143, -222, -102, -107, -112, -32 ] racc_goto_table = [ 2, 114, 116, 117, 119, 118, 226, 222, 127, 131, 133, 191, 212, 146, 166, 268, 303, 332, 241, 232, 327, 70, 378, 411, 248, 226, 225, 326, 123, 125, 126, 219, 221, 282, 252, 396, 253, 105, 106, 137, 137, 145, 369, 138, 140, 247, 373, 148, 345, 241, 266, 153, 392, 229, 211, 356, 306, 359, 157, 158, 159, 160, 274, 329, 385, 165, 190, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 156, 137, 395, 218, 218, 214, 333, 223, 398, 365, 317, 316, 338, 382, 377, 262, 161, 162, 163, 164, 263, 3, 260, 137, 284, 261, 259, 242, 149, 151, 264, 1, nil, nil, nil, nil, nil, 307, 241, 310, 283, nil, 313, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 127, 271, 131, 133, nil, nil, 330, nil, nil, nil, nil, 265, 286, 116, 272, nil, nil, 123, 125, 126, nil, nil, 341, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 351, 285, nil, nil, 354, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 210, nil, nil, nil, nil, 384, nil, 362, nil, 343, 419, nil, 241, 131, 133, 340, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 380, nil, nil, nil, 311, nil, 190, nil, nil, nil, nil, nil, 334, 386, 357, nil, 145, 339, 321, 323, nil, nil, 148, 367, nil, nil, nil, 391, nil, nil, 380, nil, nil, nil, nil, nil, 346, 347, 348, 388, 349, 350, nil, nil, nil, 360, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 223, nil, nil, nil, 131, 133, nil, nil, 412, nil, nil, 366, nil, nil, 190, 415, 334, nil, nil, nil, nil, nil, 190, nil, nil, nil, nil, 389, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 210, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 123, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 402, nil, nil, nil, nil, nil, nil, nil, nil, nil, 223, nil, nil, nil, nil, nil, 407, nil, 409, 413 ] racc_goto_check = [ 2, 10, 10, 10, 37, 6, 49, 13, 57, 35, 34, 19, 50, 80, 11, 88, 14, 65, 36, 42, 47, 5, 59, 48, 15, 49, 58, 46, 10, 10, 10, 53, 53, 51, 15, 43, 15, 9, 9, 6, 6, 6, 44, 8, 8, 58, 45, 6, 54, 36, 42, 10, 59, 41, 20, 16, 61, 62, 6, 6, 6, 6, 15, 64, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 6, 44, 10, 10, 8, 67, 10, 45, 68, 69, 71, 75, 65, 47, 76, 9, 9, 9, 9, 77, 3, 81, 6, 15, 82, 84, 8, 85, 86, 87, 1, nil, nil, nil, nil, nil, 49, 36, 42, 50, nil, 15, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 57, 6, 35, 34, nil, nil, 49, nil, nil, nil, nil, 2, 11, 10, 2, nil, nil, 10, 10, 10, nil, nil, 15, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 15, 37, nil, nil, 15, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 10, nil, nil, nil, nil, 88, nil, 15, nil, 11, 14, nil, 36, 35, 34, 80, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 49, nil, nil, nil, 2, nil, 10, nil, nil, nil, nil, nil, 6, 15, 11, nil, 6, 6, 2, 2, nil, nil, 6, 19, nil, nil, nil, 15, nil, nil, 49, nil, nil, nil, nil, nil, 10, 10, 10, 50, 10, 10, nil, nil, nil, 57, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 10, nil, nil, nil, 35, 34, nil, nil, 49, nil, nil, 10, nil, nil, 10, 13, 6, nil, nil, nil, nil, nil, 10, nil, nil, nil, nil, 37, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 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, 10, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, 10, nil, nil, nil, nil, nil, 2, nil, 2, 2 ] racc_goto_pointer = [ nil, 117, 0, 107, nil, 17, -13, nil, -9, 27, -14, -65, -279, -100, -206, -104, -249, nil, nil, -69, -45, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, -36, -37, -103, -36, nil, nil, nil, -67, -102, -335, -280, -278, -219, -226, -377, -102, -87, -180, nil, -72, -227, nil, nil, -37, -82, -306, nil, -169, -251, nil, -185, -232, nil, -158, -219, -144, nil, -142, nil, nil, nil, -157, -49, -44, nil, nil, -47, -39, -36, nil, -35, 52, 52, -35, -138 ] racc_goto_default = [ nil, nil, 379, nil, 4, 5, 6, 7, nil, 8, 9, nil, nil, nil, nil, nil, 224, 13, 14, 325, nil, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, nil, 40, 41, 120, nil, nil, 124, nil, nil, nil, nil, nil, 220, nil, nil, 102, nil, 174, 176, 175, 109, nil, nil, 108, nil, nil, 128, nil, 129, 130, 134, 233, 234, 235, 236, 237, 240, 142, 144, 55, 56, 57, 60, nil, nil, nil, 147, nil, nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, 1, 92, :_reduce_1, 1, 92, :_reduce_2, 0, 92, :_reduce_3, 1, 93, :_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, 3, 97, :_reduce_11, 3, 97, :_reduce_12, 3, 97, :_reduce_13, 1, 99, :_reduce_14, 3, 99, :_reduce_15, 1, 98, :_reduce_none, 3, 98, :_reduce_17, 3, 98, :_reduce_18, 3, 98, :_reduce_19, 3, 98, :_reduce_20, 1, 100, :_reduce_none, 2, 100, :_reduce_22, 2, 100, :_reduce_23, 7, 100, :_reduce_24, 5, 100, :_reduce_25, 5, 100, :_reduce_26, 4, 107, :_reduce_27, 1, 104, :_reduce_28, 3, 104, :_reduce_29, 1, 103, :_reduce_30, 2, 103, :_reduce_31, 4, 103, :_reduce_32, 1, 101, :_reduce_none, 1, 101, :_reduce_none, 4, 101, :_reduce_35, 3, 101, :_reduce_36, 3, 101, :_reduce_37, 3, 101, :_reduce_38, 3, 101, :_reduce_39, 3, 101, :_reduce_40, 3, 101, :_reduce_41, 3, 101, :_reduce_42, 3, 101, :_reduce_43, 3, 101, :_reduce_44, 3, 101, :_reduce_45, 2, 101, :_reduce_46, 2, 101, :_reduce_47, 3, 101, :_reduce_48, 3, 101, :_reduce_49, 3, 101, :_reduce_50, 3, 101, :_reduce_51, 3, 101, :_reduce_52, 3, 101, :_reduce_53, 2, 101, :_reduce_54, 3, 101, :_reduce_55, 3, 101, :_reduce_56, 3, 101, :_reduce_57, 3, 101, :_reduce_58, 1, 110, :_reduce_59, 3, 110, :_reduce_60, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_none, 1, 108, :_reduce_77, 1, 108, :_reduce_78, 1, 108, :_reduce_79, 1, 108, :_reduce_80, 1, 108, :_reduce_81, 5, 109, :_reduce_82, 3, 109, :_reduce_83, 6, 109, :_reduce_84, 4, 109, :_reduce_85, 1, 113, :_reduce_86, 2, 113, :_reduce_87, 4, 129, :_reduce_88, 3, 129, :_reduce_89, 1, 129, :_reduce_90, 3, 130, :_reduce_91, 2, 128, :_reduce_92, 3, 132, :_reduce_93, 2, 132, :_reduce_94, 2, 131, :_reduce_95, 4, 131, :_reduce_96, 2, 116, :_reduce_97, 5, 134, :_reduce_98, 4, 134, :_reduce_99, 0, 135, :_reduce_none, 2, 135, :_reduce_101, 4, 135, :_reduce_102, 3, 135, :_reduce_103, 6, 117, :_reduce_104, 5, 117, :_reduce_105, 0, 136, :_reduce_none, 4, 136, :_reduce_107, 3, 136, :_reduce_108, 5, 115, :_reduce_109, 1, 137, :_reduce_110, 2, 137, :_reduce_111, 5, 138, :_reduce_112, 1, 139, :_reduce_none, 1, 139, :_reduce_none, 1, 111, :_reduce_none, 4, 111, :_reduce_116, 1, 142, :_reduce_117, 3, 142, :_reduce_118, 3, 141, :_reduce_119, 6, 114, :_reduce_120, 2, 114, :_reduce_121, 3, 143, :_reduce_122, 3, 143, :_reduce_123, 1, 144, :_reduce_none, 1, 144, :_reduce_none, 0, 102, :_reduce_126, 1, 102, :_reduce_127, 3, 102, :_reduce_128, 1, 146, :_reduce_none, 1, 146, :_reduce_none, 3, 145, :_reduce_131, 3, 145, :_reduce_132, 3, 145, :_reduce_133, 6, 118, :_reduce_134, 7, 119, :_reduce_135, 1, 151, :_reduce_136, 1, 150, :_reduce_none, 1, 150, :_reduce_none, 1, 152, :_reduce_none, 2, 152, :_reduce_140, 1, 153, :_reduce_none, 1, 153, :_reduce_none, 7, 120, :_reduce_143, 6, 120, :_reduce_144, 1, 154, :_reduce_145, 3, 154, :_reduce_146, 1, 156, :_reduce_none, 1, 156, :_reduce_none, 1, 156, :_reduce_149, 1, 156, :_reduce_none, 1, 157, :_reduce_151, 3, 157, :_reduce_152, 1, 158, :_reduce_none, 1, 158, :_reduce_none, 1, 155, :_reduce_none, 2, 155, :_reduce_156, 1, 148, :_reduce_none, 1, 148, :_reduce_none, 1, 148, :_reduce_none, 1, 148, :_reduce_160, 1, 149, :_reduce_161, 2, 149, :_reduce_162, 4, 149, :_reduce_163, 1, 133, :_reduce_164, 3, 133, :_reduce_165, 1, 159, :_reduce_none, 1, 159, :_reduce_none, 1, 160, :_reduce_none, 1, 160, :_reduce_none, 3, 162, :_reduce_170, 1, 162, :_reduce_171, 2, 163, :_reduce_172, 2, 161, :_reduce_173, 1, 164, :_reduce_174, 4, 164, :_reduce_175, 1, 112, :_reduce_176, 1, 122, :_reduce_177, 1, 122, :_reduce_178, 1, 122, :_reduce_179, 1, 122, :_reduce_180, 4, 123, :_reduce_181, 2, 123, :_reduce_182, 4, 123, :_reduce_183, 2, 123, :_reduce_184, 3, 124, :_reduce_185, 4, 124, :_reduce_186, 2, 124, :_reduce_187, 1, 165, :_reduce_188, 3, 165, :_reduce_189, 3, 166, :_reduce_190, 1, 126, :_reduce_none, 1, 126, :_reduce_none, 1, 126, :_reduce_none, 1, 167, :_reduce_194, 1, 167, :_reduce_195, 2, 168, :_reduce_196, 1, 170, :_reduce_197, 1, 172, :_reduce_198, 1, 173, :_reduce_199, 2, 171, :_reduce_200, 1, 174, :_reduce_201, 1, 175, :_reduce_202, 2, 175, :_reduce_203, 2, 169, :_reduce_204, 2, 176, :_reduce_205, 2, 176, :_reduce_206, 3, 94, :_reduce_207, 0, 178, :_reduce_none, 1, 178, :_reduce_none, 0, 177, :_reduce_210, 2, 177, :_reduce_211, 4, 177, :_reduce_212, 1, 121, :_reduce_213, 3, 121, :_reduce_214, 5, 121, :_reduce_215, 1, 179, :_reduce_none, 1, 179, :_reduce_none, 1, 127, :_reduce_218, 1, 125, :_reduce_219, 0, 106, :_reduce_none, 1, 106, :_reduce_221, 0, 105, :_reduce_none, 1, 105, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 1, 147, :_reduce_none, 0, 140, :_reduce_242 ] racc_reduce_n = 243 racc_shift_n = 420 racc_token_table = { false => 0, :error => 1, :STRING => 2, :DQPRE => 3, :DQMID => 4, :DQPOST => 5, :WORD => 6, :LBRACK => 7, :RBRACK => 8, :LBRACE => 9, :RBRACE => 10, :SYMBOL => 11, :FARROW => 12, :COMMA => 13, :TRUE => 14, :FALSE => 15, :EQUALS => 16, :APPENDS => 17, :DELETES => 18, :LESSEQUAL => 19, :NOTEQUAL => 20, :DOT => 21, :COLON => 22, :LLCOLLECT => 23, :RRCOLLECT => 24, :QMARK => 25, :LPAREN => 26, :RPAREN => 27, :ISEQUAL => 28, :GREATEREQUAL => 29, :GREATERTHAN => 30, :LESSTHAN => 31, :IF => 32, :ELSE => 33, :DEFINE => 34, :ELSIF => 35, :VARIABLE => 36, :CLASS => 37, :INHERITS => 38, :NODE => 39, :BOOLEAN => 40, :NAME => 41, :SEMIC => 42, :CASE => 43, :DEFAULT => 44, :AT => 45, :ATAT => 46, :LCOLLECT => 47, :RCOLLECT => 48, :CLASSREF => 49, :NOT => 50, :OR => 51, :AND => 52, :UNDEF => 53, :PARROW => 54, :PLUS => 55, :MINUS => 56, :TIMES => 57, :DIV => 58, :LSHIFT => 59, :RSHIFT => 60, :UMINUS => 61, :MATCH => 62, :NOMATCH => 63, :REGEX => 64, :IN_EDGE => 65, :OUT_EDGE => 66, :IN_EDGE_SUB => 67, :OUT_EDGE_SUB => 68, :IN => 69, :UNLESS => 70, :PIPE => 71, :LAMBDA => 72, :SELBRACE => 73, :NUMBER => 74, :HEREDOC => 75, :SUBLOCATE => 76, :RENDER_STRING => 77, :RENDER_EXPR => 78, :EPP_START => 79, :EPP_END => 80, :EPP_END_TRIM => 81, :FUNCTION => 82, :PRIVATE => 83, :ATTR => 84, :TYPE => 85, :LOW => 86, :HIGH => 87, :LISTSTART => 88, :SPLAT => 89, :MODULO => 90 } racc_nt_base = 91 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", "WORD", "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", "PRIVATE", "ATTR", "TYPE", "LOW", "HIGH", "LISTSTART", "SPLAT", "MODULO", "$start", "program", "statements", "epp_expression", "syntactic_statements", "syntactic_statement", "assignment", "relationship", "assignments", "resource", "expression", "attribute_operations", "additional_resource_bodies", "resource_bodies", "endsemi", "endcomma", "resource_body", "primary_expression", "call_function_expression", "expressions", "selector_entries", "variable", "call_method_with_lambda_expression", "collection_expression", "case_expression", "if_expression", "unless_expression", "definition_expression", "hostclass_expression", "node_definition_expression", "epp_render_expression", "reserved_word", "array", "hash", "regex", "quotedtext", "type", "lambda", "call_method_expression", "named_access", "lambda_parameter_list", "lambda_rest", "parameters", "if_part", "else", "unless_else", "case_options", "case_option", "options_statements", "nil", "selector_entry", "selector_entry_list", "collect_query", "optional_query", "attribute_operation", "attribute_name", "keyword", "classname", "parameter_list", "opt_statements", "stacked_classname", "classparent", "classnameordefault", "hostnames", "nodeparent", "hostname", "dotted_name", "name_or_number", "parameter", "untyped_parameter", "typed_parameter", "regular_parameter", "splat_parameter", "parameter_type", "hashpairs", "hashpair", "string", "dq_string", "heredoc", "dqpre", "dqrval", "dqpost", "dqmid", "text_expression", "dqtail", "sublocated_text", "epp_parameters_list", "optional_statements", "epp_end" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted module_eval(<<'.,.,', 'egrammar.ra', 65) def _reduce_1(val, _values, result) result = create_program(Factory.block_or_expression(*val[0])) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 66) def _reduce_2(val, _values, result) result = create_program(Factory.block_or_expression(*val[0])) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 67) def _reduce_3(val, _values, result) result = create_empty_program() result end .,., module_eval(<<'.,.,', 'egrammar.ra', 71) def _reduce_4(val, _values, result) result = transform_calls(val[0]) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 78) def _reduce_5(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 79) def _reduce_6(val, _values, result) result = val[0].push val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 80) def _reduce_7(val, _values, result) result = val[0].push val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 87) def _reduce_8(val, _values, result) result = val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 88) def _reduce_9(val, _values, result) result = aryfy(val[0]).push(val[1]).push(val[2]) result end .,., # reduce 10 omitted module_eval(<<'.,.,', 'egrammar.ra', 93) def _reduce_11(val, _values, result) result = val[0].set(val[2]) ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 94) def _reduce_12(val, _values, result) result = val[0].plus_set(val[2]) ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 95) def _reduce_13(val, _values, result) result = val[0].minus_set(val[2]); loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 98) def _reduce_14(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 99) def _reduce_15(val, _values, result) result = val[0].push(val[2]) result end .,., # reduce 16 omitted module_eval(<<'.,.,', 'egrammar.ra', 103) def _reduce_17(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 104) def _reduce_18(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 105) def _reduce_19(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 106) def _reduce_20(val, _values, result) result = val[0].relop(val[1][:value], val[2]); loc result, val[1] result end .,., # reduce 21 omitted module_eval(<<'.,.,', 'egrammar.ra', 115) def _reduce_22(val, _values, result) result = val[1] unless Factory.set_resource_form(result, :virtual) # This is equivalent to a syntax error - additional semantic restrictions apply error val[0], "Virtual (@) can only be applied to a Resource Expression" end # relocate the result loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 126) def _reduce_23(val, _values, result) result = val[1] unless Factory.set_resource_form(result, :exported) # This is equivalent to a syntax error - additional semantic restrictions apply error val[0], "Exported (@@) can only be applied to a Resource Expression" end # relocate the result loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 137) def _reduce_24(val, _values, result) bodies = [Factory.RESOURCE_BODY(val[2], val[4])] + val[5] result = Factory.RESOURCE(val[0], bodies) loc result, val[0], val[6] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 144) def _reduce_25(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', 153) def _reduce_26(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 should 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', 175) def _reduce_27(val, _values, result) result = Factory.RESOURCE_BODY(val[0], val[2]) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 178) def _reduce_28(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 179) def _reduce_29(val, _values, result) result = val[0].push val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 185) def _reduce_30(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 186) def _reduce_31(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 187) def _reduce_32(val, _values, result) result = val[2] result end .,., # reduce 33 omitted # reduce 34 omitted module_eval(<<'.,.,', 'egrammar.ra', 194) def _reduce_35(val, _values, result) result = val[0][*val[2]] ; loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 195) def _reduce_36(val, _values, result) result = val[0].in val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 196) def _reduce_37(val, _values, result) result = val[0] =~ val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 197) def _reduce_38(val, _values, result) result = val[0].mne val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 198) def _reduce_39(val, _values, result) result = val[0] + val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 199) def _reduce_40(val, _values, result) result = val[0] - val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 200) def _reduce_41(val, _values, result) result = val[0] / val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 201) def _reduce_42(val, _values, result) result = val[0] * val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 202) def _reduce_43(val, _values, result) result = val[0] % val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 203) def _reduce_44(val, _values, result) result = val[0] << val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 204) def _reduce_45(val, _values, result) result = val[0] >> val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 205) def _reduce_46(val, _values, result) result = val[1].minus() ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 206) def _reduce_47(val, _values, result) result = val[1].unfold() ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 207) def _reduce_48(val, _values, result) result = val[0].ne val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 208) def _reduce_49(val, _values, result) result = val[0] == val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 209) def _reduce_50(val, _values, result) result = val[0] > val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 210) def _reduce_51(val, _values, result) result = val[0] >= val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 211) def _reduce_52(val, _values, result) result = val[0] < val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 212) def _reduce_53(val, _values, result) result = val[0] <= val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 213) def _reduce_54(val, _values, result) result = val[1].not ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 214) def _reduce_55(val, _values, result) result = val[0].and val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 215) def _reduce_56(val, _values, result) result = val[0].or val[2] ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 216) def _reduce_57(val, _values, result) result = val[0].select(*val[2]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 217) def _reduce_58(val, _values, result) result = val[1].paren() ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 227) def _reduce_59(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 228) def _reduce_60(val, _values, result) result = val[0].push(val[2]) result end .,., # reduce 61 omitted # reduce 62 omitted # reduce 63 omitted # reduce 64 omitted # reduce 65 omitted # reduce 66 omitted # reduce 67 omitted # reduce 68 omitted # reduce 69 omitted # reduce 70 omitted # reduce 71 omitted # reduce 72 omitted # reduce 73 omitted # reduce 74 omitted # reduce 75 omitted # reduce 76 omitted module_eval(<<'.,.,', 'egrammar.ra', 247) def _reduce_77(val, _values, result) result = Factory.NUMBER(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 248) def _reduce_78(val, _values, result) result = Factory.literal(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 249) def _reduce_79(val, _values, result) result = Factory.literal(:default) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 250) def _reduce_80(val, _values, result) result = Factory.literal(:undef) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 251) def _reduce_81(val, _values, result) result = Factory.QNAME_OR_NUMBER(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 260) def _reduce_82(val, _values, result) result = Factory.CALL_NAMED(val[0], true, val[2]) loc result, val[0], val[4] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 264) def _reduce_83(val, _values, result) result = Factory.CALL_NAMED(val[0], true, []) loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 268) def _reduce_84(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', 273) def _reduce_85(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', 281) def _reduce_86(val, _values, result) result = val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 282) def _reduce_87(val, _values, result) result = val[0]; val[0].lambda = val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 285) def _reduce_88(val, _values, result) result = Factory.CALL_METHOD(val[0], val[2]); loc result, val[1], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 286) def _reduce_89(val, _values, result) result = Factory.CALL_METHOD(val[0], []); loc result, val[1], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 287) def _reduce_90(val, _values, result) result = Factory.CALL_METHOD(val[0], []); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 291) def _reduce_91(val, _values, result) result = val[0].dot(Factory.fqn(val[2][:value])) loc result, val[1], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 299) def _reduce_92(val, _values, result) result = Factory.LAMBDA(val[0][:value], val[1][:value]) loc result, val[0][:start], val[1][:end] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 304) def _reduce_93(val, _values, result) result = {:end => val[2], :value =>val[1] } result end .,., module_eval(<<'.,.,', 'egrammar.ra', 305) def _reduce_94(val, _values, result) result = {:end => val[1], :value => nil } result end .,., module_eval(<<'.,.,', 'egrammar.ra', 309) def _reduce_95(val, _values, result) result = {:start => val[0], :value => [] } result end .,., module_eval(<<'.,.,', 'egrammar.ra', 310) def _reduce_96(val, _values, result) result = {:start => val[0], :value => val[1] } result end .,., module_eval(<<'.,.,', 'egrammar.ra', 318) def _reduce_97(val, _values, result) result = val[1] loc(result, val[0], val[1]) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 325) def _reduce_98(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', 329) def _reduce_99(val, _values, result) result = Factory.IF(val[0], nil, val[3]) loc(result, val[0], (val[3] ? val[3] : val[2])) result end .,., # reduce 100 omitted module_eval(<<'.,.,', 'egrammar.ra', 337) def _reduce_101(val, _values, result) result = val[1] loc(result, val[0], val[1]) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 341) def _reduce_102(val, _values, result) result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 345) def _reduce_103(val, _values, result) result = nil # don't think a nop is needed here either result end .,., module_eval(<<'.,.,', 'egrammar.ra', 352) def _reduce_104(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', 356) def _reduce_105(val, _values, result) - result = Factory.UNLESS(val[1], nil, nil) + result = Factory.UNLESS(val[1], nil, val[4]) loc result, val[0], val[4] result end .,., # reduce 106 omitted module_eval(<<'.,.,', 'egrammar.ra', 366) def _reduce_107(val, _values, result) result = Factory.block_or_expression(*val[2]) loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 370) def _reduce_108(val, _values, result) result = nil # don't think a nop is needed here either result end .,., module_eval(<<'.,.,', 'egrammar.ra', 377) def _reduce_109(val, _values, result) result = Factory.CASE(val[1], *val[3]) loc result, val[0], val[4] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 383) def _reduce_110(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 384) def _reduce_111(val, _values, result) result = val[0].push val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 389) def _reduce_112(val, _values, result) result = Factory.WHEN(val[0], val[3]); loc result, val[1], val[4] result end .,., # reduce 113 omitted # reduce 114 omitted # reduce 115 omitted module_eval(<<'.,.,', 'egrammar.ra', 405) def _reduce_116(val, _values, result) result = val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 410) def _reduce_117(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 411) def _reduce_118(val, _values, result) result = val[0].push val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 416) def _reduce_119(val, _values, result) result = Factory.MAP(val[0], val[2]) ; loc result, val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 426) def _reduce_120(val, _values, result) result = Factory.COLLECT(val[0], val[1], val[3]) loc result, val[0], val[5] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 430) def _reduce_121(val, _values, result) result = Factory.COLLECT(val[0], val[1], []) loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 435) def _reduce_122(val, _values, result) result = Factory.VIRTUAL_QUERY(val[1]) ; loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 436) def _reduce_123(val, _values, result) result = Factory.EXPORTED_QUERY(val[1]) ; loc result, val[0], val[2] result end .,., # reduce 124 omitted # reduce 125 omitted module_eval(<<'.,.,', 'egrammar.ra', 445) def _reduce_126(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 446) def _reduce_127(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 447) def _reduce_128(val, _values, result) result = val[0].push(val[2]) result end .,., # reduce 129 omitted # reduce 130 omitted module_eval(<<'.,.,', 'egrammar.ra', 463) def _reduce_131(val, _values, result) result = Factory.ATTRIBUTE_OP(val[0][:value], :'=>', val[2]) loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 467) def _reduce_132(val, _values, result) result = Factory.ATTRIBUTE_OP(val[0][:value], :'+>', val[2]) loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 471) def _reduce_133(val, _values, result) result = Factory.ATTRIBUTES_OP(val[2]) ; loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 480) def _reduce_134(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', 494) def _reduce_135(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', 504) def _reduce_136(val, _values, result) namestack(val[0][:value]) ; result = val[0] result end .,., # reduce 137 omitted # reduce 138 omitted # reduce 139 omitted module_eval(<<'.,.,', 'egrammar.ra', 513) def _reduce_140(val, _values, result) result = val[1] result end .,., # reduce 141 omitted # reduce 142 omitted module_eval(<<'.,.,', 'egrammar.ra', 530) def _reduce_143(val, _values, result) result = add_definition(Factory.NODE(val[1], val[3], val[5])) loc result, val[0], val[6] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 534) def _reduce_144(val, _values, result) result = add_definition(Factory.NODE(val[1], val[3], nil)) loc result, val[0], val[5] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 544) def _reduce_145(val, _values, result) result = [result] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 545) def _reduce_146(val, _values, result) result = val[0].push(val[2]) result end .,., # reduce 147 omitted # reduce 148 omitted module_eval(<<'.,.,', 'egrammar.ra', 552) def _reduce_149(val, _values, result) result = Factory.literal(:default); loc result, val[0] result end .,., # reduce 150 omitted module_eval(<<'.,.,', 'egrammar.ra', 556) def _reduce_151(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 557) def _reduce_152(val, _values, result) result = Factory.concat(val[0], '.', val[2][:value]); loc result, val[0], val[2] result end .,., # reduce 153 omitted # reduce 154 omitted # reduce 155 omitted module_eval(<<'.,.,', 'egrammar.ra', 566) def _reduce_156(val, _values, result) result = val[1] result end .,., # reduce 157 omitted # reduce 158 omitted # reduce 159 omitted module_eval(<<'.,.,', 'egrammar.ra', 585) def _reduce_160(val, _values, result) error val[0], "'class' is not a valid classname" result end .,., module_eval(<<'.,.,', 'egrammar.ra', 589) def _reduce_161(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 590) def _reduce_162(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 591) def _reduce_163(val, _values, result) result = val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 595) def _reduce_164(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 596) def _reduce_165(val, _values, result) result = val[0].push(val[2]) result end .,., # reduce 166 omitted # reduce 167 omitted # reduce 168 omitted # reduce 169 omitted module_eval(<<'.,.,', 'egrammar.ra', 608) def _reduce_170(val, _values, result) result = Factory.PARAM(val[0][:value], val[2]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 609) def _reduce_171(val, _values, result) result = Factory.PARAM(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 612) def _reduce_172(val, _values, result) result = val[1]; val[1].captures_rest() result end .,., module_eval(<<'.,.,', 'egrammar.ra', 615) def _reduce_173(val, _values, result) val[1].type_expr(val[0]) ; result = val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 618) def _reduce_174(val, _values, result) result = val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 619) def _reduce_175(val, _values, result) result = val[0][*val[2]] ; loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 624) def _reduce_176(val, _values, result) result = Factory.fqn(val[0][:value]).var ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 629) def _reduce_177(val, _values, result) result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 630) def _reduce_178(val, _values, result) result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 631) def _reduce_179(val, _values, result) result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 632) def _reduce_180(val, _values, result) result = Factory.RESERVED(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 638) def _reduce_181(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 639) def _reduce_182(val, _values, result) result = Factory.literal([]) ; loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 640) def _reduce_183(val, _values, result) result = Factory.LIST(val[1]); loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 641) def _reduce_184(val, _values, result) result = Factory.literal([]) ; loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 644) def _reduce_185(val, _values, result) result = Factory.HASH(val[1]); loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 645) def _reduce_186(val, _values, result) result = Factory.HASH(val[1]); loc result, val[0], val[3] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 646) def _reduce_187(val, _values, result) result = Factory.literal({}) ; loc result, val[0], val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 649) def _reduce_188(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 650) def _reduce_189(val, _values, result) result = val[0].push val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 653) def _reduce_190(val, _values, result) result = Factory.KEY_ENTRY(val[0], val[2]); loc result, val[1] result end .,., # reduce 191 omitted # reduce 192 omitted # reduce 193 omitted module_eval(<<'.,.,', 'egrammar.ra', 661) def _reduce_194(val, _values, result) result = Factory.literal(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 662) def _reduce_195(val, _values, result) result = Factory.literal(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 664) def _reduce_196(val, _values, result) result = Factory.string(val[0], *val[1]) ; loc result, val[0], val[1][-1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 665) def _reduce_197(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 666) def _reduce_198(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 667) def _reduce_199(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 668) def _reduce_200(val, _values, result) result = [val[0]] + val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 669) def _reduce_201(val, _values, result) result = Factory.TEXT(val[0]) result end .,., module_eval(<<'.,.,', 'egrammar.ra', 672) def _reduce_202(val, _values, result) result = [val[0]] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 673) def _reduce_203(val, _values, result) result = [val[0]] + val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 676) def _reduce_204(val, _values, result) result = Factory.HEREDOC(val[0][:value], val[1]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 679) def _reduce_205(val, _values, result) result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 680) def _reduce_206(val, _values, result) result = Factory.SUBLOCATE(val[0], val[1]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 683) def _reduce_207(val, _values, result) result = Factory.EPP(val[1], val[2]); loc result, val[0] result end .,., # reduce 208 omitted # reduce 209 omitted module_eval(<<'.,.,', 'egrammar.ra', 690) def _reduce_210(val, _values, result) result = nil result end .,., module_eval(<<'.,.,', 'egrammar.ra', 691) def _reduce_211(val, _values, result) result = [] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 692) def _reduce_212(val, _values, result) result = val[1] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 695) def _reduce_213(val, _values, result) result = Factory.RENDER_STRING(val[0][:value]); loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 696) def _reduce_214(val, _values, result) result = Factory.RENDER_EXPR(val[1]); loc result, val[0], val[2] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 697) def _reduce_215(val, _values, result) result = Factory.RENDER_EXPR(Factory.block_or_expression(*val[2])); loc result, val[0], val[4] result end .,., # reduce 216 omitted # reduce 217 omitted module_eval(<<'.,.,', 'egrammar.ra', 703) def _reduce_218(val, _values, result) result = Factory.QREF(val[0][:value]) ; loc result, val[0] result end .,., module_eval(<<'.,.,', 'egrammar.ra', 706) def _reduce_219(val, _values, result) result = Factory.literal(val[0][:value]); loc result, val[0] result end .,., # reduce 220 omitted module_eval(<<'.,.,', 'egrammar.ra', 712) def _reduce_221(val, _values, result) result = nil result end .,., # reduce 222 omitted # reduce 223 omitted # reduce 224 omitted # reduce 225 omitted # reduce 226 omitted # reduce 227 omitted # reduce 228 omitted # reduce 229 omitted # reduce 230 omitted # reduce 231 omitted # reduce 232 omitted # reduce 233 omitted # reduce 234 omitted # reduce 235 omitted # reduce 236 omitted # reduce 237 omitted # reduce 238 omitted # reduce 239 omitted # reduce 240 omitted # reduce 241 omitted module_eval(<<'.,.,', 'egrammar.ra', 739) def _reduce_242(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 424f6a409..f379f4284 100644 --- a/spec/unit/pops/evaluator/evaluating_parser_spec.rb +++ b/spec/unit/pops/evaluator/evaluating_parser_spec.rb @@ -1,1365 +1,1366 @@ require 'spec_helper' require 'puppet/pops' require 'puppet/pops/evaluator/evaluator_impl' require 'puppet/loaders' 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 3x logic switches some behaviors on these even if the tests explicitly # use the 4x parser and evaluator. # Puppet[:parser] = 'future' # Puppetx cannot be loaded until the correct parser has been set (injector is turned off otherwise) require 'puppetx' # Tests needs a known configuration of node/scope/compiler since it parses and evaluates # snippets as the compiler will evaluate them, butwithout the overhead of compiling a complete # catalog for each tested expression. # @parser = Puppet::Pops::Parser::EvaluatingParser.new @node = Puppet::Node.new('node.example.com') @node.environment = Puppet::Node::Environment.create(:testing, []) @compiler = Puppet::Parser::Compiler.new(@node) @scope = Puppet::Parser::Scope.new(@compiler) @scope.source = Puppet::Resource::Type.new(:node, 'node.example.com') @scope.parent = @compiler.topscope end let(:parser) { @parser } let(:scope) { @scope } 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.0 == 1 " => true, "1.0 < 2 " => true, "'1.0' < 'a'" => true, "'1.0' < '' " => false, "'1.0' < ' '" => false, "'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 > 1" => /String > Integer/, "a >= 1" => /String >= Integer/, "a < 1" => /String < Integer/, "a <= 1" => /String <= Integer/, "1 > a" => /Integer > String/, "1 >= a" => /Integer >= String/, "1 < a" => /Integer < String/, "1 <= a" => /Integer <= String/, }.each do | source, error| it "should not allow comparison of String and Number '#{source}'" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(error) 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 "String[1] in bananas" => false, # Philosophically true though :-) "'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']" => false, "'15' in [1, 0xf]" => false, "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 { "if /(ana)/ in bananas {$1}" => 'ana', "if /(xyz)/ in bananas {$1} else {$1}" => nil, "$a = bananas =~ /(ana)/; $b = /(xyz)/ in bananas; $1" => 'ana', "$a = xyz =~ /(xyz)/; $b = /(ana)/ in bananas; $1" => 'ana', "if /p/ in [pineapple, bananas] {$0}" => 'p', "if /b/ in [pineapple, bananas] {$0}" => 'b', }.each do |source, result| it "sets match variables for a regexp search using in such that '#{source}' produces '#{result}'" do parser.evaluate_string(scope, source, __FILE__).should == result end end { 'Any' => ['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'" => 0, "'- 2' + '2'" => 0, '"-\t 2" + "2"' => 0, "'+2' + '2'" => 4, "'+ 2' + '2'" => 4, "'2.2' + '2.2'" => 4.4, "'-2.2' + '2.2'" => 0.0, "'0xF7' + '010'" => 0xFF, "'0xF7' + '0x8'" => 0xFF, "'0367' + '010'" => 0xFF, "'012.3' + '010'" => 20.3, "'-0x2' + '0x4'" => 2, "'+0x2' + '0x4'" => 6, "'-02' + '04'" => 2, "'+02' + '04'" => 6, }.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, '"-\n 2" + "2"' => :error, '"-\v 2" + "2"' => :error, '"-2\n" + "2"' => :error, '"-2\n " + "2"' => :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, }.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]" => /attempt to assign to 'an Array Expression'/, "[a,b,c] = {b=>2,c=>3,a=>1}" => /attempt to assign to 'an Array Expression'/, }.each do |source, result| it "should parse and evaluate the expression '#{source}' to error with #{result}" do expect { parser.evaluate_string(scope, source, __FILE__)}.to raise_error(Puppet::ParseError, result) 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, + "unless true {} 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', # supports unfold "case ringo { *[paul, john, ringo, george] : { 'beatle' } }" => 'beatle', "case undef { undef : { 'yes' } }" => 'yes', "case undef { *undef : { 'no' } default :{ '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, default => yes }" => 'yes', "3 ? { 1 => no, default => yes, 3 => no }" => 'no', "3 ? { 1 => no, 3 => no, default => yes }" => 'no', "4 ? { 1 => no, default => yes, 3 => no }" => 'yes', "4 ? { 1 => no, 3 => no, default => yes }" => 'yes', "'banana' ? { /.*(ana).*/ => $1 }" => 'ana', "[2] ? { Array[String] => yes, Array => yes}" => 'yes', "ringo ? *[paul, john, ringo, george] => 'beatle'" => 'beatle', "undef ? undef => 'yes'" => 'yes', "undef ? {*undef => 'no', default => '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 it 'fails if a selector does not match' do expect{parser.evaluate_string(scope, "2 ? 3 => 4")}.to raise_error(/No matching entry for selector parameter with value '2'/) 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 2 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 Integer', "Resource[a, 0]" => 'Error creating type specialization of a Resource-Type, Cannot use Integer where a resource title String is expected', "File[0]" => 'Error creating type specialization of a File-Type, Cannot use Integer where a resource title 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 Integer where String or Regexp or Pattern-Type or Regexp-Type is expected', "Regexp[0]" => 'Error creating type specialization of a Regexp-Type, Cannot use Integer 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) Puppet.override({:global_scope => scope}, "test") do scope.known_resource_types.import_ast(ast, '') ast.code.safeevaluate(scope).should == 'chocolate' end end # Resource default and override expressions and resource parameter access with [] { # Properties "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", # Parameters "notify { id: withpath=>explicit} Notify[id][withpath]" => "explicit", "Notify { withpath=>by_default } notify { foo: } Notify[foo][withpath]" => "by_default", "notify {foo:} Notify[foo]{withpath=>by_override} Notify[foo][withpath]" => "by_override", # Metaparameters "notify { foo: tag => evoe} Notify[foo][tag]" => "evoe", # Does not produce the defaults for tag parameter (title, type or names of scopes) "notify { foo: } Notify[foo][tag]" => nil, # But a default may be specified on the type "Notify { tag=>by_default } notify { foo: } Notify[foo][tag]" => "by_default", "Notify { tag=>by_default } notify { foo: } Notify[foo]{ tag=>by_override } Notify[foo][tag]" => "by_override", }.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 # Virtual and realized resource default and overridden resource parameter access with [] { # Properties "@notify { id: message=>explicit } Notify[id][message]" => "explicit", "@notify { id: message=>explicit } realize Notify[id] Notify[id][message]" => "explicit", "Notify { message=>by_default } @notify { id: } Notify[id][message]" => "by_default", "Notify { message=>by_default } @notify { id: tag=>thisone } Notify <| tag == thisone |>; Notify[id][message]" => "by_default", "@notify { id: } Notify[id]{message=>by_override} Notify[id][message]" => "by_override", # Parameters "@notify { id: withpath=>explicit } Notify[id][withpath]" => "explicit", "Notify { withpath=>by_default } @notify { id: } Notify[id][withpath]" => "by_default", "@notify { id: } realize Notify[id] Notify[id]{withpath=>by_override} Notify[id][withpath]" => "by_override", # Metaparameters "@notify { id: tag=>explicit } Notify[id][tag]" => "explicit", }.each do |source, result| it "parses and evaluates virtual and realized resources in the expression '#{source}' to #{result}" do expect(parser.evaluate_string(scope, source, __FILE__)).to eq(result) end end # Exported resource attributes { "@@notify { id: message=>explicit } Notify[id][message]" => "explicit", "@@notify { id: message=>explicit, tag=>thisone } Notify <<| tag == thisone |>> Notify[id][message]" => "explicit", }.each do |source, result| it "parses and evaluates exported resources in the expression '#{source}' to #{result}" do expect(parser.evaluate_string(scope, source, __FILE__)).to eq(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'/, "notify { id: message=>explicit } Notify[id]{message=>override}" => /'message' is already set on Notify\[id\]/ }.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, "! ''" => false, "! 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 it 'defaults can be given in a lambda and used only when arg is missing' do env_loader = @compiler.loaders.public_environment_loader fc = Puppet::Functions.create_function(:test) do dispatch :test do param 'Integer', 'count' required_block_param end def test(count) yield(*[].fill(10, 0, count)) end end the_func = fc.new({}, env_loader) env_loader.add_entry(:function, 'test', the_func, __FILE__) expect(parser.evaluate_string(scope, "test(1) |$x, $y=20| { $x + $y}")).to eql(30) expect(parser.evaluate_string(scope, "test(2) |$x, $y=20| { $x + $y}")).to eql(20) end it 'a given undef does not select the default value' do env_loader = @compiler.loaders.public_environment_loader fc = Puppet::Functions.create_function(:test) do dispatch :test do param 'Any', 'lambda_arg' required_block_param end def test(lambda_arg) yield(lambda_arg) end end the_func = fc.new({}, env_loader) env_loader.add_entry(:function, 'test', the_func, __FILE__) expect(parser.evaluate_string(scope, "test(undef) |$x=20| { $x == undef}")).to eql(true) end it 'a given undef is given as nil' do env_loader = @compiler.loaders.public_environment_loader fc = Puppet::Functions.create_function(:assert_no_undef) do dispatch :assert_no_undef do param 'Any', 'x' end def assert_no_undef(x) case x when Array return unless x.include?(:undef) when Hash return unless x.keys.include?(:undef) || x.values.include?(:undef) else return unless x == :undef end raise "contains :undef" end end the_func = fc.new({}, env_loader) env_loader.add_entry(:function, 'assert_no_undef', the_func, __FILE__) expect{parser.evaluate_string(scope, "assert_no_undef(undef)")}.to_not raise_error() expect{parser.evaluate_string(scope, "assert_no_undef([undef])")}.to_not raise_error() expect{parser.evaluate_string(scope, "assert_no_undef({undef => 1})")}.to_not raise_error() expect{parser.evaluate_string(scope, "assert_no_undef({1 => undef})")}.to_not raise_error() end context 'using the 3x function api' do it 'can call a 3x function' do Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0] } parser.evaluate_string(scope, "bazinga(42)", __FILE__).should == 42 end it 'maps :undef to empty string' do Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0] } parser.evaluate_string(scope, "$a = {} bazinga($a[nope])", __FILE__).should == '' parser.evaluate_string(scope, "bazinga(undef)", __FILE__).should == '' end it 'does not map :undef to empty string in arrays' do Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0][0] } parser.evaluate_string(scope, "$a = {} $b = [$a[nope]] bazinga($b)", __FILE__).should == :undef parser.evaluate_string(scope, "bazinga([undef])", __FILE__).should == :undef end it 'does not map :undef to empty string in hashes' do Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0]['a'] } parser.evaluate_string(scope, "$a = {} $b = {a => $a[nope]} bazinga($b)", __FILE__).should == :undef parser.evaluate_string(scope, "bazinga({a => undef})", __FILE__).should == :undef end 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 it 'should accept a variable with leading underscore when used directly' do source = '$_x = 10; "$_x"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('10') end it 'should accept a variable with leading underscore when used as an expression' do source = '$_x = 10; "${_x}"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('10') end it 'should accept a numeric variable expressed as $n' do source = '$x = "abc123def" =~ /(abc)(123)(def)/; "${$2}"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('123') end it 'should accept a numeric variable expressed as just an integer' do source = '$x = "abc123def" =~ /(abc)(123)(def)/; "${2}"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('123') end it 'should accept a numeric variable expressed as $n in an access operation' do source = '$x = "abc123def" =~ /(abc)(123)(def)/; "${$0[4,3]}"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('23d') end it 'should accept a numeric variable expressed as just an integer in an access operation' do source = '$x = "abc123def" =~ /(abc)(123)(def)/; "${0[4,3]}"' expect(parser.evaluate_string(scope, source, __FILE__)).to eql('23d') 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 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 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.evaluate_string(scope, source) }.to raise_error( /Illegal Resource Type expression, expected result to be a type name, or untitled Resource.*line 1:2/) 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::Util::Log.expects(:create).with(has_entries(:level => :err, :message => "Invalid use of expression. A 'define' expression does not produce a value", :line => 1, :pos => 6)) Puppet::Util::Log.expects(:create).with(has_entries(:level => :err, :message => 'Classes, definitions, and nodes may only appear at toplevel or inside other classes', :line => 1, :pos => 6)) expect { parser.parse_string("$a = define foo { }", nil) }.to raise_error(/2 errors/) end it 'for non r-value producing class' do Puppet::Util::Log.expects(:create).with(has_entries(:level => :err, :message => 'Invalid use of expression. A Host Class Definition does not produce a value', :line => 1, :pos => 6)) Puppet::Util::Log.expects(:create).with(has_entries(:level => :err, :message => 'Classes, definitions, and nodes may only appear at toplevel or inside other classes', :line => 1, :pos => 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::Util::Log.expects(:create).with(has_entries(:level => :err, :message => 'Invalid use of expression. A Node Definition does not produce a value', :line => 1, :pos => 6)) Puppet::Util::Log.expects(:create).with(has_entries(:level => :err, :message => 'Classes, definitions, and nodes may only appear at toplevel or inside other classes', :line => 1, :pos => 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 context 'does not leak variables' do it 'local variables are gone when lambda ends' do source = <<-SOURCE [1,2,3].each |$x| { $y = $x} $a = $y SOURCE expect do parser.evaluate_string(scope, source) end.to raise_error(/Unknown variable: 'y'/) end it 'lambda parameters are gone when lambda ends' do source = <<-SOURCE [1,2,3].each |$x| { $y = $x} $a = $x SOURCE expect do parser.evaluate_string(scope, source) end.to raise_error(/Unknown variable: 'x'/) end it 'does not leak match variables' do source = <<-SOURCE if 'xyz' =~ /(x)(y)(z)/ { notice $2 } case 'abc' { /(a)(b)(c)/ : { $x = $2 } } "-$x-$2-" SOURCE expect(parser.evaluate_string(scope, source)).to eq('-b--') 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