class Puppet::Pops::Model::Factory

Constants

BUILD_VISITOR
INFER_VISITOR
INTERPOLATION_VISITOR
KEY_BODY
KEY_EXPR
KEY_KEYS
KEY_LEFT_EXPR
KEY_LENGTH

Shared build_visitor, since there are many instances of Factory being used

KEY_LOCATOR
KEY_NAME
KEY_OFFSET
KEY_OPERATOR
KEY_PARAMETERS
KEY_RIGHT_EXPR
KEY_VALUE
MAPOFFSET_VISITOR
STATEMENT_CALLS

Attributes

model_class[R]
unfolded[R]

Public Class Methods

APPLY(arguments, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
937 def self.APPLY(arguments, body)
938   new(ApplyExpression, arguments, body)
939 end
APPLY_BLOCK(statements) click to toggle source
    # File lib/puppet/pops/model/factory.rb
941 def self.APPLY_BLOCK(statements)
942   new(ApplyBlockExpression, statements)
943 end
ARGUMENTS(args, arg) click to toggle source
    # File lib/puppet/pops/model/factory.rb
846 def self.ARGUMENTS(args, arg)
847   if !args.empty? && arg.model_class <= LiteralHash && arg.unfolded
848     last = args[args.size() - 1]
849     if last.model_class <= LiteralHash && last.unfolded
850       last['entries'].concat(arg['entries'])
851       return args
852     end
853   end
854   args.push(arg)
855 end
ATTRIBUTES_OP(expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
861 def self.ATTRIBUTES_OP(expr)
862   new(AttributesOperation, expr)
863 end
ATTRIBUTE_OP(name, op, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
857 def self.ATTRIBUTE_OP(name, op, expr)
858   new(AttributeOperation, name, op, expr)
859 end
CALL_METHOD(functor, argument_list) click to toggle source
    # File lib/puppet/pops/model/factory.rb
874 def self.CALL_METHOD(functor, argument_list)
875   new(CallMethodExpression, functor, true, nil, argument_list)
876 end
CALL_NAMED(name, rval_required, argument_list) click to toggle source
    # File lib/puppet/pops/model/factory.rb
870 def self.CALL_NAMED(name, rval_required, argument_list)
871   new(CallNamedFunctionExpression, name, rval_required, argument_list)
872 end
CASE(test_e,*options) click to toggle source
    # File lib/puppet/pops/model/factory.rb
705 def self.CASE(test_e,*options);        new(CaseExpression, test_e, options);           end
COLLECT(type_expr, query_expr, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
878 def self.COLLECT(type_expr, query_expr, attribute_operations)
879   new(CollectExpression, type_expr, query_expr, attribute_operations)
880 end
DEFINITION(name, parameters, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
929 def self.DEFINITION(name, parameters, body)
930   new(ResourceTypeDefinition, name, parameters, body)
931 end
EPP(parameters, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
779 def self.EPP(parameters, body)
780   if parameters.nil?
781     params = []
782     parameters_specified = false
783   else
784     params = parameters
785     parameters_specified = true
786   end
787   LAMBDA(params, new(EppExpression, parameters_specified, body), nil)
788 end
EXPORTED_QUERY(query_expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
842 def self.EXPORTED_QUERY(query_expr)
843   new(ExportedQuery, query_expr)
844 end
FUNCTION(name, parameters, body, return_type) click to toggle source
    # File lib/puppet/pops/model/factory.rb
945 def self.FUNCTION(name, parameters, body, return_type)
946   new(FunctionDefinition, name, parameters, body, return_type)
947 end
HASH(entries) click to toggle source
    # File lib/puppet/pops/model/factory.rb
713 def self.HASH(entries);                new(LiteralHash, entries, false);               end
HASH_UNFOLDED(entries) click to toggle source
    # File lib/puppet/pops/model/factory.rb
715 def self.HASH_UNFOLDED(entries);       new(LiteralHash, entries, true);                end
HEREDOC(name, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
717 def self.HEREDOC(name, expr);          new(HeredocExpression, name, expr);             end
HOSTCLASS(name, parameters, parent, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
925 def self.HOSTCLASS(name, parameters, parent, body)
926   new(HostClassDefinition, name, parameters, parent, body)
927 end
IF(test_e,then_e,else_e) click to toggle source
    # File lib/puppet/pops/model/factory.rb
701 def self.IF(test_e,then_e,else_e);     new(IfExpression, test_e, then_e, else_e);      end
KEY_ENTRY(key, val) click to toggle source
    # File lib/puppet/pops/model/factory.rb
711 def self.KEY_ENTRY(key, val);          new(KeyedEntry, key, val);                      end
LAMBDA(parameters, body, return_type) click to toggle source
    # File lib/puppet/pops/model/factory.rb
949 def self.LAMBDA(parameters, body, return_type)
950   new(LambdaExpression, parameters, body, return_type)
951 end
LIST(entries) click to toggle source
    # File lib/puppet/pops/model/factory.rb
721 def self.LIST(entries);                new(LiteralList, entries);                      end
MAP(match, value) click to toggle source
    # File lib/puppet/pops/model/factory.rb
709 def self.MAP(match, value);            new(SelectorEntry, match, value);               end
NAMED_ACCESS(type_name, bodies) click to toggle source
    # File lib/puppet/pops/model/factory.rb
882 def self.NAMED_ACCESS(type_name, bodies)
883   new(NamedAccessExpression, type_name, bodies)
884 end
NODE(hosts, parent, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
725 def self.NODE(hosts, parent, body);    new(NodeDefinition, hosts, parent, body);       end
NUMBER(name_or_numeric) click to toggle source
    # File lib/puppet/pops/model/factory.rb
801 def self.NUMBER(name_or_numeric)
802   n_radix = Utils.to_n_with_radix(name_or_numeric)
803   if n_radix
804     val, radix = n_radix
805     if val.is_a?(Float)
806       new(LiteralFloat, val)
807     else
808       new(LiteralInteger, val, radix)
809     end
810   else
811     # Bad number should already have been caught by lexer - this should never happen
812     #TRANSLATORS 'NUMBER' refers to a method name and the 'name_or_numeric' was the passed in value and should not be translated
813     raise ArgumentError, _("Internal Error, NUMBER token does not contain a valid number, %{name_or_numeric}") %
814         { name_or_numeric: name_or_numeric }
815   end
816 end
PARAM(name, expr=nil) click to toggle source
    # File lib/puppet/pops/model/factory.rb
723 def self.PARAM(name, expr=nil);        new(Parameter, name, expr);                     end
PLAN(name, parameters, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
933 def self.PLAN(name, parameters, body)
934   new(PlanDefinition, name, parameters, body, nil)
935 end
PROGRAM(body, definitions, locator) click to toggle source
    # File lib/puppet/pops/model/factory.rb
902 def self.PROGRAM(body, definitions, locator)
903   new(Program, body, definitions, locator)
904 end
QNAME(name) click to toggle source

TODO: This is the same a fqn factory method, don't know if callers to fqn and QNAME can live with the same result or not yet - refactor into one method when decided.

    # File lib/puppet/pops/model/factory.rb
797 def self.QNAME(name)
798   new(QualifiedName, name)
799 end
QNAME_OR_NUMBER(name) click to toggle source

Convert input string to either a qualified name, a LiteralInteger with radix, or a LiteralFloat

    # File lib/puppet/pops/model/factory.rb
820 def self.QNAME_OR_NUMBER(name)
821   n_radix = Utils.to_n_with_radix(name)
822   if n_radix
823     val, radix = n_radix
824     if val.is_a?(Float)
825       new(LiteralFloat, val)
826     else
827       new(LiteralInteger, val, radix)
828     end
829   else
830     new(QualifiedName, name)
831   end
832 end
QREF(name) click to toggle source
    # File lib/puppet/pops/model/factory.rb
834 def self.QREF(name)
835   new(QualifiedReference, name)
836 end
RENDER_EXPR(expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
775 def self.RENDER_EXPR(expr)
776   new(RenderExpression, expr)
777 end
RENDER_STRING(o) click to toggle source

TODO_EPP

    # File lib/puppet/pops/model/factory.rb
771 def self.RENDER_STRING(o)
772   new(RenderStringExpression, o)
773 end
RESERVED(name, future=false) click to toggle source
    # File lib/puppet/pops/model/factory.rb
790 def self.RESERVED(name, future=false)
791   new(ReservedWord, name, future)
792 end
RESOURCE(type_name, bodies) click to toggle source
    # File lib/puppet/pops/model/factory.rb
886 def self.RESOURCE(type_name, bodies)
887   new(ResourceExpression, type_name, bodies)
888 end
RESOURCE_BODY(resource_title, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
898 def self.RESOURCE_BODY(resource_title, attribute_operations)
899   new(ResourceBody, resource_title, attribute_operations)
900 end
RESOURCE_DEFAULTS(type_name, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
890 def self.RESOURCE_DEFAULTS(type_name, attribute_operations)
891   new(ResourceDefaultsExpression, type_name, attribute_operations)
892 end
RESOURCE_OVERRIDE(resource_ref, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
894 def self.RESOURCE_OVERRIDE(resource_ref, attribute_operations)
895   new(ResourceOverrideExpression, resource_ref, attribute_operations)
896 end
STRING(*args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
719 def self.STRING(*args);                new(ConcatenatedString, args);                  end
SUBLOCATE(token, expr_factory) click to toggle source
    # File lib/puppet/pops/model/factory.rb
753 def self.SUBLOCATE(token, expr_factory)
754   # expr is a Factory wrapped LiteralString, or ConcatenatedString
755   # The token is SUBLOCATED token which has a SubLocator as the token's locator
756   # Use the SubLocator to recalculate the offsets and lengths.
757   model = expr_factory.model
758   locator = token.locator
759   expr_factory.map_offset(model, locator)
760   model._pcore_all_contents([]) { |element| expr_factory.map_offset(element, locator) }
761 
762   # Returned the factory wrapping the now offset/length transformed expression(s)
763   expr_factory
764 end
TEXT(expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
766 def self.TEXT(expr)
767   new(TextExpression, infer(expr).interpolate)
768 end
TYPE_ASSIGNMENT(lhs, rhs) click to toggle source
    # File lib/puppet/pops/model/factory.rb
953 def self.TYPE_ASSIGNMENT(lhs, rhs)
954   if lhs.model_class <= AccessExpression
955     new(TypeMapping, lhs, rhs)
956   else
957     new(TypeAlias, lhs['cased_value'], rhs)
958   end
959 end
TYPE_DEFINITION(name, parent, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
961 def self.TYPE_DEFINITION(name, parent, body)
962   new(TypeDefinition, name, parent, body)
963 end
UNLESS(test_e,then_e,else_e) click to toggle source
    # File lib/puppet/pops/model/factory.rb
703 def self.UNLESS(test_e,then_e,else_e); new(UnlessExpression, test_e, then_e, else_e);  end
VIRTUAL_QUERY(query_expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
838 def self.VIRTUAL_QUERY(query_expr)
839   new(VirtualQuery, query_expr)
840 end
WHEN(values_list, block) click to toggle source
    # File lib/puppet/pops/model/factory.rb
707 def self.WHEN(values_list, block);     new(CaseOption, values_list, block);            end
block(*args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
695 def self.block(*args);                 new(BlockExpression, args.map { |arg| infer(arg) }); end
block_or_expression(args, left_brace = nil, right_brace = nil) click to toggle source

Builds a BlockExpression if args size > 1, else the single expression/value in args

    # File lib/puppet/pops/model/factory.rb
907 def self.block_or_expression(args, left_brace = nil, right_brace = nil)
908   if args.size > 1
909     block_expr = new(BlockExpression, args)
910 
911     # If given a left and right brace position, use those
912     # otherwise use the first and last element of the block
913     if !left_brace.nil? && !right_brace.nil?
914       block_expr.record_position(args.first[KEY_LOCATOR], left_brace, right_brace)
915     else
916       block_expr.record_position(args.first[KEY_LOCATOR], args.first, args.last)
917     end
918 
919     block_expr
920   else
921     args[0]
922   end
923 end
call_named(name, rval_required, *argument_list) click to toggle source

Same as CALL_NAMED but with inference and varargs (for testing purposes)

    # File lib/puppet/pops/model/factory.rb
866 def self.call_named(name, rval_required, *argument_list)
867   new(CallNamedFunctionExpression, fqn(name), rval_required, argument_list.map { |arg| infer(arg) })
868 end
concat(*args) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1114 def self.concat(*args)
1115   result = String.new
1116   args.each do |e|
1117     if e.instance_of?(Factory) && e.model_class <= LiteralString
1118       result << e[KEY_VALUE]
1119     elsif e.is_a?(String)
1120       result << e
1121     else
1122       raise ArgumentError, _("can only concatenate strings, got %{class_name}") % { class_name: e.class }
1123     end
1124   end
1125   infer(result)
1126 end
fqn(o) click to toggle source

Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.

    # File lib/puppet/pops/model/factory.rb
742 def self.fqn(o)
743   o.instance_of?(Factory) && o.model_class <= QualifiedName ? self : new(QualifiedName, o)
744 end
fqr(o) click to toggle source

Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.

    # File lib/puppet/pops/model/factory.rb
749 def self.fqr(o)
750   o.instance_of?(Factory) && o.model_class <= QualifiedReference ? self : new(QualifiedReference, o)
751 end
infer(o) click to toggle source
   # File lib/puppet/pops/model/factory.rb
34 def self.infer(o)
35   if o.instance_of?(Factory)
36     o
37   else
38     new(o)
39   end
40 end
literal(o) click to toggle source

Factory starting points

    # File lib/puppet/pops/model/factory.rb
687 def self.literal(o);                   infer(o);                                       end
minus(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
689 def self.minus(o);                     infer(o).minus;                                 end
name_is_statement?(name) click to toggle source

Returns true if the given name is a “statement keyword” (require, include, contain, error, notice, info, debug

    # File lib/puppet/pops/model/factory.rb
992 def self.name_is_statement?(name)
993   STATEMENT_CALLS.include?(name)
994 end
new(o, *args) click to toggle source

Initialize a factory with a single object, or a class with arguments applied to build of created instance

   # File lib/puppet/pops/model/factory.rb
84 def initialize(o, *args)
85   @init_hash = {}
86   if o.instance_of?(Class)
87     @model_class = o
88     BUILD_VISITOR.visit_this_class(self, o, args)
89   else
90     INFER_VISITOR.visit_this(self, o, EMPTY_ARRAY)
91   end
92 end
nop?(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
965 def self.nop? o
966   o.nil? || o.instance_of?(Factory) && o.model_class <= Nop
967 end
resource_shape(expr) click to toggle source

Returns symbolic information about an expected shape of a resource expression given the LHS of a resource expr.

  • `name { }` => `:resource`, create a resource of the given type

  • `Name { }` => ':defaults`, set defaults for the referenced type

  • `Name[] { }` => `:override`, overrides instances referenced by LHS

  • _any other_ => ':error', all other are considered illegal

    # File lib/puppet/pops/model/factory.rb
660 def self.resource_shape(expr)
661   if expr == 'class'
662     :class
663   elsif expr.instance_of?(self)
664     mc = expr.model_class
665     if mc <= QualifiedName
666       :resource
667     elsif mc <= QualifiedReference
668       :defaults
669     elsif mc <= AccessExpression
670       # if Resource[e], then it is not resource specific
671       lhs = expr[KEY_LEFT_EXPR]
672       if lhs.model_class <= QualifiedReference && lhs[KEY_VALUE] == 'resource' && expr[KEY_KEYS].size == 1
673         :defaults
674       else
675         :override
676       end
677     else
678       :error
679     end
680   else
681     :error
682   end
683 end
set_resource_form(expr, form) click to toggle source

Sets the form of the resource expression (:regular (the default), :virtual, or :exported). Produces true if the expression was a resource expression, false otherwise.

    # File lib/puppet/pops/model/factory.rb
646 def self.set_resource_form(expr, form)
647   # Note: Validation handles illegal combinations
648   return false unless expr.instance_of?(self) && expr.model_class <= AbstractResource
649   expr['form'] = form
650   return true
651 end
string(*args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
697 def self.string(*args);                new(ConcatenatedString, args.map { |arg| infer(arg) });           end
text(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
699 def self.text(o);                      infer(o).text;                                  end
transform_calls(expressions) click to toggle source

Transforms an array of expressions containing literal name expressions to calls if followed by an expression, or expression list.

     # File lib/puppet/pops/model/factory.rb
1007 def self.transform_calls(expressions)
1008   expressions.reduce([]) do |memo, expr|
1009     name = memo[-1]
1010     if name.instance_of?(Factory) && name.model_class <= QualifiedName && name_is_statement?(name[KEY_VALUE])
1011       if expr.is_a?(Array)
1012         expr = expr.reject { |e| e.is_a?(Parser::LexerSupport::TokenValue) }
1013       else
1014         expr = [expr]
1015       end
1016       the_call = self.CALL_NAMED(name, false, expr)
1017       # last positioned is last arg if there are several
1018       the_call.record_position(name[KEY_LOCATOR], name, expr[-1])
1019       memo[-1] = the_call
1020       if expr.is_a?(CallNamedFunctionExpression)
1021         # Patch statement function call to expression style
1022         # This is needed because it is first parsed as a "statement" and the requirement changes as it becomes
1023         # an argument to the name to call transform above.
1024         expr.rval_required = true
1025       end
1026     elsif expr.is_a?(Array)
1027       raise ArgsToNonCallError.new(expr, name)
1028     else
1029       memo << expr
1030       if expr.model_class <= CallNamedFunctionExpression
1031         # Patch rvalue expression function call to statement style.
1032         # This is not really required but done to be AST model compliant
1033         expr['rval_required'] = false
1034       end
1035     end
1036     memo
1037   end
1038 end
transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_token) click to toggle source

Transforms a left expression followed by an untitled resource (in the form of attribute_operations) @param left [Factory, Expression] the lhs followed what may be a hash

     # File lib/puppet/pops/model/factory.rb
1042 def self.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_token)
1043   # Returning nil means accepting the given as a potential resource expression
1044   return nil unless attribute_ops.is_a? Array
1045   return nil unless left.model_class <= QualifiedName
1046   keyed_entries = attribute_ops.map do |ao|
1047     return nil if ao[KEY_OPERATOR] == '+>'
1048     KEY_ENTRY(infer(ao['attribute_name']), ao['value_expr'])
1049   end
1050   a_hash = HASH(keyed_entries)
1051   a_hash.record_position(left[KEY_LOCATOR], lbrace_token, rbrace_token)
1052   result = block_or_expression(transform_calls([left, a_hash]))
1053   result
1054 end
unfold(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
691 def self.unfold(o);                    infer(o).unfold;                                end
var(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
693 def self.var(o);                       infer(o).var;                                   end

Public Instance Methods

%(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
556 def % r;      f_arithmetic('%', r);                           end
*(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
554 def * r;      f_arithmetic('*', r);                           end
+(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
548 def + r;      f_arithmetic('+', r);                           end
-(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
550 def - r;      f_arithmetic('-', r);                           end
/(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
552 def / r;      f_arithmetic('/', r);                           end
<(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
562 def < r;      f_comparison('<', r);                           end
<<(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
558 def << r;     f_arithmetic('<<', r);                          end
<=(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
564 def <= r;     f_comparison('<=', r);                          end
=~(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
574 def =~ r;     f_match('=~', r);                               end
>(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
566 def > r;      f_comparison('>', r);                           end
>=(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
568 def >= r;     f_comparison('>=', r);                          end
>>(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
560 def >> r;     f_arithmetic('>>', r);                          end
[](key) click to toggle source
   # File lib/puppet/pops/model/factory.rb
44 def [](key)
45   @init_hash[key]
46 end
[]=(key, value) click to toggle source
   # File lib/puppet/pops/model/factory.rb
48 def []=(key, value)
49   @init_hash[key] = value
50 end
access(r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
544 def access(r); f_build_binary(AccessExpression, self, r);     end
access_at(*r) click to toggle source

Same as access, but with varargs and arguments that must be inferred. For testing purposes

    # File lib/puppet/pops/model/factory.rb
589 def access_at(*r)
590   f_build_binary(AccessExpression, self, r.map { |arg| Factory.infer(arg) })
591 end
all_factories(&block) click to toggle source
   # File lib/puppet/pops/model/factory.rb
52 def all_factories(&block)
53   block.call(self)
54   @init_hash.each_value { |value| value.all_factories(&block) if value.instance_of?(Factory) }
55 end
and(r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
532 def and(r)    f_build_binary(AndExpression, self, r);         end
attributes(*args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
619 def attributes(*args)
620   @init_hash['attributes'] = args
621   self
622 end
build_AccessExpression(o, left, keys) click to toggle source
    # File lib/puppet/pops/model/factory.rb
144 def build_AccessExpression(o, left, keys)
145   @init_hash[KEY_LEFT_EXPR] = left
146   @init_hash[KEY_KEYS] = keys
147 end
build_ApplyExpression(o, args, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
263 def build_ApplyExpression(o, args, body)
264   @init_hash['arguments'] = args
265   @init_hash['body'] = body
266 end
build_ArithmeticExpression(o, op, a, b) click to toggle source

Building of Model classes

    # File lib/puppet/pops/model/factory.rb
124 def build_ArithmeticExpression(o, op, a, b)
125   @init_hash[KEY_OPERATOR] = op
126   build_BinaryExpression(o, a, b)
127 end
build_AssignmentExpression(o, op, a, b) click to toggle source
    # File lib/puppet/pops/model/factory.rb
129 def build_AssignmentExpression(o, op, a, b)
130   @init_hash[KEY_OPERATOR] = op
131   build_BinaryExpression(o, a, b)
132 end
build_AttributeOperation(o, name, op, value) click to toggle source
    # File lib/puppet/pops/model/factory.rb
134 def build_AttributeOperation(o, name, op, value)
135   @init_hash[KEY_OPERATOR] = op
136   @init_hash['attribute_name'] = name.to_s # BOOLEAN is allowed in the grammar
137   @init_hash['value_expr'] = value
138 end
build_AttributesOperation(o, value) click to toggle source
    # File lib/puppet/pops/model/factory.rb
140 def build_AttributesOperation(o, value)
141   @init_hash[KEY_EXPR] = value
142 end
build_BinaryExpression(o, left, right) click to toggle source
    # File lib/puppet/pops/model/factory.rb
149 def build_BinaryExpression(o, left, right)
150   @init_hash[KEY_LEFT_EXPR] = left
151   @init_hash[KEY_RIGHT_EXPR] = right
152 end
build_BlockExpression(o, args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
154 def build_BlockExpression(o, args)
155   @init_hash['statements'] = args
156 end
build_CallExpression(o, functor, rval_required, args) click to toggle source

@param rval_required [Boolean] if the call must produce a value

    # File lib/puppet/pops/model/factory.rb
165 def build_CallExpression(o, functor, rval_required, args)
166   @init_hash['functor_expr'] = functor
167   @init_hash['rval_required'] = rval_required
168   @init_hash['arguments'] = args
169 end
build_CallMethodExpression(o, functor, rval_required, lambda, args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
171 def build_CallMethodExpression(o, functor, rval_required, lambda, args)
172   build_CallExpression(o, functor, rval_required, args)
173   @init_hash['lambda'] = lambda
174 end
build_CaseExpression(o, test, args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
176 def build_CaseExpression(o, test, args)
177   @init_hash['test'] = test
178   @init_hash['options'] = args
179 end
build_CaseOption(o, value_list, then_expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
181 def build_CaseOption(o, value_list, then_expr)
182   value_list = [value_list] unless value_list.is_a?(Array)
183   @init_hash['values'] = value_list
184   b = f_build_body(then_expr)
185   @init_hash['then_expr'] = b unless b.nil?
186 end
build_CollectExpression(o, type_expr, query_expr, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
188 def build_CollectExpression(o, type_expr, query_expr, attribute_operations)
189   @init_hash['type_expr'] = type_expr
190   @init_hash['query'] = query_expr
191   @init_hash['operations'] = attribute_operations
192 end
build_ComparisonExpression(o, op, a, b) click to toggle source
    # File lib/puppet/pops/model/factory.rb
194 def build_ComparisonExpression(o, op, a, b)
195   @init_hash[KEY_OPERATOR] = op
196   build_BinaryExpression(o, a, b)
197 end
build_ConcatenatedString(o, args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
199 def build_ConcatenatedString(o, args)
200   # Strip empty segments
201   @init_hash['segments'] = args.reject { |arg| arg.model_class == LiteralString && arg['value'].empty? }
202 end
build_EppExpression(o, parameters_specified, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
158 def build_EppExpression(o, parameters_specified, body)
159   @init_hash['parameters_specified'] = parameters_specified
160   b = f_build_body(body)
161   @init_hash[KEY_BODY] = b unless b.nil?
162 end
build_FunctionDefinition(o, name, parameters, body, return_type) click to toggle source
    # File lib/puppet/pops/model/factory.rb
368 def build_FunctionDefinition(o, name, parameters, body, return_type)
369   @init_hash[KEY_PARAMETERS] = parameters
370   b = f_build_body(body)
371   @init_hash[KEY_BODY] = b unless b.nil?
372   @init_hash[KEY_NAME] = name
373   @init_hash['return_type'] = return_type unless return_type.nil?
374 end
build_HeredocExpression(o, name, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
204 def build_HeredocExpression(o, name, expr)
205   @init_hash['syntax'] = name
206   @init_hash['text_expr'] = expr
207 end
build_HostClassDefinition(o, name, parameters, parent_class_name, body) click to toggle source

@param name [String] a valid classname @param parameters [Array<Parameter>] may be empty @param parent_class_name [String, nil] a valid classname referencing a parent class, optional. @param body [Array<Expression>, Expression, nil] expression that constitute the body @return [HostClassDefinition] configured from the parameters

    # File lib/puppet/pops/model/factory.rb
215 def build_HostClassDefinition(o, name, parameters, parent_class_name, body)
216   build_NamedDefinition(o, name, parameters, body)
217   @init_hash['parent_class'] = parent_class_name unless parent_class_name.nil?
218 end
build_IfExpression(o, t, ift, els) click to toggle source
    # File lib/puppet/pops/model/factory.rb
257 def build_IfExpression(o, t, ift, els)
258   @init_hash['test'] = t
259   @init_hash['then_expr'] = ift
260   @init_hash['else_expr'] = els
261 end
build_KeyedEntry(o, k, v) click to toggle source
    # File lib/puppet/pops/model/factory.rb
230 def build_KeyedEntry(o, k, v)
231   @init_hash['key'] = k
232   @init_hash[KEY_VALUE] = v
233 end
build_LambdaExpression(o, parameters, body, return_type) click to toggle source
    # File lib/puppet/pops/model/factory.rb
354 def build_LambdaExpression(o, parameters, body, return_type)
355   @init_hash[KEY_PARAMETERS] = parameters
356   b = f_build_body(body)
357   @init_hash[KEY_BODY] = b unless b.nil?
358   @init_hash['return_type'] = return_type unless return_type.nil?
359 end
build_LiteralFloat(o, val) click to toggle source
    # File lib/puppet/pops/model/factory.rb
244 def build_LiteralFloat(o, val)
245   @init_hash[KEY_VALUE] = val
246 end
build_LiteralHash(o, keyed_entries, unfolded) click to toggle source
    # File lib/puppet/pops/model/factory.rb
235 def build_LiteralHash(o, keyed_entries, unfolded)
236   @init_hash['entries'] = keyed_entries
237   @unfolded = unfolded
238 end
build_LiteralInteger(o, val, radix) click to toggle source
    # File lib/puppet/pops/model/factory.rb
248 def build_LiteralInteger(o, val, radix)
249   @init_hash[KEY_VALUE] = val
250   @init_hash['radix'] = radix
251 end
build_LiteralList(o, values) click to toggle source
    # File lib/puppet/pops/model/factory.rb
240 def build_LiteralList(o, values)
241   @init_hash['values'] = values
242 end
build_LiteralString(o, value) click to toggle source
    # File lib/puppet/pops/model/factory.rb
253 def build_LiteralString(o, value)
254   @init_hash[KEY_VALUE] = val
255 end
build_MatchExpression(o, op, a, b) click to toggle source
    # File lib/puppet/pops/model/factory.rb
268 def build_MatchExpression(o, op, a, b)
269   @init_hash[KEY_OPERATOR] = op
270   build_BinaryExpression(o, a, b)
271 end
build_NamedDefinition(o, name, parameters, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
361 def build_NamedDefinition(o, name, parameters, body)
362   @init_hash[KEY_PARAMETERS] = parameters
363   b = f_build_body(body)
364   @init_hash[KEY_BODY] = b unless b.nil?
365   @init_hash[KEY_NAME] = name
366 end
build_NodeDefinition(o, hosts, parent, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
384 def build_NodeDefinition(o, hosts, parent, body)
385   @init_hash['host_matches'] = hosts
386   @init_hash['parent'] = parent unless parent.nil? # no nop here
387   b = f_build_body(body)
388   @init_hash[KEY_BODY] = b unless b.nil?
389 end
build_Parameter(o, name, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
391 def build_Parameter(o, name, expr)
392   @init_hash[KEY_NAME] = name
393   @init_hash[KEY_VALUE] = expr
394 end
build_PlanDefinition(o, name, parameters, body, return_type=nil) click to toggle source
    # File lib/puppet/pops/model/factory.rb
376 def build_PlanDefinition(o, name, parameters, body, return_type=nil)
377   @init_hash[KEY_PARAMETERS] = parameters
378   b = f_build_body(body)
379   @init_hash[KEY_BODY] = b unless b.nil?
380   @init_hash[KEY_NAME] = name
381   @init_hash['return_type'] = return_type unless return_type.nil?
382 end
build_Program(o, body, definitions, locator) click to toggle source
    # File lib/puppet/pops/model/factory.rb
487 def build_Program(o, body, definitions, locator)
488   @init_hash[KEY_BODY] = body
489   # non containment
490   @init_hash['definitions'] = definitions
491   @init_hash[KEY_LOCATOR] = locator
492 end
build_QualifiedName(o, name) click to toggle source
    # File lib/puppet/pops/model/factory.rb
494 def build_QualifiedName(o, name)
495   @init_hash[KEY_VALUE] = name
496 end
build_QualifiedReference(o, name) click to toggle source
    # File lib/puppet/pops/model/factory.rb
396 def build_QualifiedReference(o, name)
397   @init_hash['cased_value'] = name.to_s
398 end
build_QueryExpression(o, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
434 def build_QueryExpression(o, expr)
435   @init_hash[KEY_EXPR] = expr unless Factory.nop?(expr)
436 end
build_RelationshipExpression(o, op, a, b) click to toggle source
    # File lib/puppet/pops/model/factory.rb
400 def build_RelationshipExpression(o, op, a, b)
401   @init_hash[KEY_OPERATOR] = op
402   build_BinaryExpression(o, a, b)
403 end
build_RenderStringExpression(o, string) click to toggle source
    # File lib/puppet/pops/model/factory.rb
410 def build_RenderStringExpression(o, string)
411   @init_hash[KEY_VALUE] = string;
412 end
build_ReservedWord(o, name, future) click to toggle source
    # File lib/puppet/pops/model/factory.rb
225 def build_ReservedWord(o, name, future)
226   @init_hash['word'] = name
227   @init_hash['future'] = future
228 end
build_ResourceBody(o, title_expression, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
414 def build_ResourceBody(o, title_expression, attribute_operations)
415   @init_hash['title'] = title_expression
416   @init_hash['operations'] = attribute_operations
417 end
build_ResourceDefaultsExpression(o, type_ref, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
419 def build_ResourceDefaultsExpression(o, type_ref, attribute_operations)
420   @init_hash['type_ref'] = type_ref
421   @init_hash['operations'] = attribute_operations
422 end
build_ResourceExpression(o, type_name, bodies) click to toggle source
    # File lib/puppet/pops/model/factory.rb
405 def build_ResourceExpression(o, type_name, bodies)
406   @init_hash['type_name'] = type_name
407   @init_hash['bodies'] = bodies
408 end
build_ResourceOverrideExpression(o, resources, attribute_operations) click to toggle source
    # File lib/puppet/pops/model/factory.rb
220 def build_ResourceOverrideExpression(o, resources, attribute_operations)
221   @init_hash['resources'] = resources
222   @init_hash['operations'] = attribute_operations
223 end
build_SelectorEntry(o, matching, value) click to toggle source
    # File lib/puppet/pops/model/factory.rb
429 def build_SelectorEntry(o, matching, value)
430   @init_hash['matching_expr'] = matching
431   @init_hash['value_expr'] = value
432 end
build_SelectorExpression(o, left, *selectors) click to toggle source
    # File lib/puppet/pops/model/factory.rb
424 def build_SelectorExpression(o, left, *selectors)
425   @init_hash[KEY_LEFT_EXPR] = left
426   @init_hash['selectors'] = selectors
427 end
build_TokenValue(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
498 def build_TokenValue(o)
499   raise "Factory can not deal with a Lexer Token. Got token: #{o}. Probably caused by wrong index in grammar val[n]."
500 end
build_TypeAlias(o, name, type_expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
438 def build_TypeAlias(o, name, type_expr)
439   if type_expr.model_class <= KeyedEntry
440     # KeyedEntry is used for the form:
441     #
442     #   type Foo = Bar { ... }
443     #
444     # The entry contains Bar => { ... } and must be transformed into:
445     #
446     #   Object[{parent => Bar, ... }]
447     #
448     parent = type_expr['key']
449     hash = type_expr['value']
450     pn = parent['cased_value']
451     unless pn == 'Object' || pn == 'TypeSet'
452       hash['entries'] << Factory.KEY_ENTRY(Factory.QNAME('parent'), parent)
453       parent = Factory.QREF('Object')
454     end
455     type_expr = parent.access([hash])
456   elsif type_expr.model_class <= LiteralHash
457     # LiteralHash is used for the form:
458     #
459     #   type Foo = { ... }
460     #
461     # The hash must be transformed into:
462     #
463     #   Object[{ ... }]
464     #
465     type_expr = Factory.QREF('Object').access([type_expr])
466   end
467   @init_hash['type_expr'] = type_expr
468   @init_hash[KEY_NAME] = name
469 end
build_TypeDefinition(o, name, parent, body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
476 def build_TypeDefinition(o, name, parent, body)
477   b = f_build_body(body)
478   @init_hash[KEY_BODY] = b unless b.nil?
479   @init_hash['parent'] = parent
480   @init_hash[KEY_NAME] = name
481 end
build_TypeMapping(o, lhs, rhs) click to toggle source
    # File lib/puppet/pops/model/factory.rb
471 def build_TypeMapping(o, lhs, rhs)
472   @init_hash['type_expr'] = lhs
473   @init_hash['mapping_expr'] = rhs
474 end
build_UnaryExpression(o, expr) click to toggle source
    # File lib/puppet/pops/model/factory.rb
483 def build_UnaryExpression(o, expr)
484   @init_hash[KEY_EXPR] = expr unless Factory.nop?(expr)
485 end
captures_rest() click to toggle source

Mark parameter as capturing the rest of arguments

    # File lib/puppet/pops/model/factory.rb
730 def captures_rest
731   @init_hash['captures_rest'] = true
732 end
contained_current(container) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1142 def contained_current(container)
1143   if @current.nil?
1144     unless @init_hash.include?(KEY_LOCATOR)
1145       @init_hash[KEY_LOCATOR] = container[KEY_LOCATOR]
1146       @init_hash[KEY_OFFSET] = container[KEY_OFFSET] || 0
1147       @init_hash[KEY_LENGTH] = 0
1148     end
1149     @current = create_model
1150   end
1151   @current
1152 end
create_model() click to toggle source
   # File lib/puppet/pops/model/factory.rb
76 def create_model
77   @init_hash.each_pair { |key, elem| @init_hash[key] = factory_to_model(elem) }
78   model_class.from_asserted_hash(@init_hash)
79 end
current()

Backward API compatibility

Alias for: model
default(r) click to toggle source

For CaseExpression, setting the default for an already build CaseExpression

    # File lib/puppet/pops/model/factory.rb
594 def default(r)
595   @init_hash['options'] << Factory.WHEN(Factory.infer(:default), r)
596   self
597 end
dot(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
546 def dot r;    f_build_binary(NamedAccessExpression, self, r); end
eq(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
570 def eq r;     f_comparison('==', r);                          end
f_arithmetic(op, r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
515 def f_arithmetic(op, r)
516   f_build_binary_op(ArithmeticExpression, op, self, r)
517 end
f_build_binary(klazz, left, right) click to toggle source
    # File lib/puppet/pops/model/factory.rb
511 def f_build_binary(klazz, left, right)
512   Factory.new(klazz, left, right)
513 end
f_build_binary_op(klazz, op, left, right) click to toggle source
    # File lib/puppet/pops/model/factory.rb
507 def f_build_binary_op(klazz, op, left, right)
508   Factory.new(klazz, op, left, right)
509 end
f_build_body(body) click to toggle source
    # File lib/puppet/pops/model/factory.rb
341 def f_build_body(body)
342   case body
343   when NilClass
344     nil
345   when Array
346     Factory.new(BlockExpression, body)
347   when Factory
348     body
349   else
350     Factory.infer(body)
351   end
352 end
f_build_unary(klazz, expr) click to toggle source

Factory helpers

    # File lib/puppet/pops/model/factory.rb
503 def f_build_unary(klazz, expr)
504   Factory.new(klazz, expr)
505 end
f_comparison(op, r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
519 def f_comparison(op, r)
520   f_build_binary_op(ComparisonExpression, op, self, r)
521 end
f_match(op, r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
523 def f_match(op, r)
524   f_build_binary_op(MatchExpression, op, self, r)
525 end
factory_to_model(value) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1132 def factory_to_model(value)
1133   if value.instance_of?(Factory)
1134     value.contained_current(self)
1135   elsif value.instance_of?(Array)
1136     value.each_with_index { |el, idx| value[idx] = el.contained_current(self) if el.instance_of?(Factory) }
1137   else
1138     value
1139   end
1140 end
in(r) click to toggle source

Operator helpers

    # File lib/puppet/pops/model/factory.rb
528 def in(r)     f_build_binary(InExpression, self, r);          end
infer_Array(o) click to toggle source

Creates a LiteralList instruction from an Array, where the entries are built.

    # File lib/puppet/pops/model/factory.rb
327 def infer_Array(o)
328   @model_class = LiteralList
329   @init_hash['values'] = o.map { |e| Factory.infer(e) }
330 end
infer_FalseClass(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
291 def infer_FalseClass(o)
292   @model_class = LiteralBoolean
293   @init_hash[KEY_VALUE] = o
294 end
infer_Float(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
301 def infer_Float(o)
302   @model_class = LiteralFloat
303   @init_hash[KEY_VALUE] = o
304 end
infer_Hash(o) click to toggle source

Create a LiteralHash instruction from a hash, where keys and values are built The hash entries are added in sorted order based on key.to_s

    # File lib/puppet/pops/model/factory.rb
335 def infer_Hash(o)
336   @model_class = LiteralHash
337   @init_hash['entries'] = o.sort_by { |k,_| k.to_s }.map { |k, v| Factory.new(KeyedEntry, Factory.infer(k), Factory.infer(v)) }
338   @unfolded = false
339 end
infer_Integer(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
296 def infer_Integer(o)
297   @model_class = LiteralInteger
298   @init_hash[KEY_VALUE] = o
299 end
infer_NilClass(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
282 def infer_NilClass(o)
283   @model_class = Nop
284 end
infer_Regexp(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
306 def infer_Regexp(o)
307   @model_class = LiteralRegularExpression
308   @init_hash['pattern'] = o.inspect
309   @init_hash[KEY_VALUE] = o
310 end
infer_String(o) click to toggle source

Building model equivalences of Ruby objects Allows passing regular ruby objects to the factory to produce instructions that when evaluated produce the same thing.

    # File lib/puppet/pops/model/factory.rb
277 def infer_String(o)
278   @model_class = LiteralString
279   @init_hash[KEY_VALUE] = o
280 end
infer_Symbol(o) click to toggle source

Creates a String literal, unless the symbol is one of the special :undef, or :default which instead creates a LiterlUndef, or a LiteralDefault. Supports :undef because nil creates a no-op instruction.

    # File lib/puppet/pops/model/factory.rb
315 def infer_Symbol(o)
316   case o
317   when :undef
318     @model_class = LiteralUndef
319   when :default
320     @model_class = LiteralDefault
321   else
322     infer_String(o.to_s)
323   end
324 end
infer_TrueClass(o) click to toggle source
    # File lib/puppet/pops/model/factory.rb
286 def infer_TrueClass(o)
287   @model_class = LiteralBoolean
288   @init_hash[KEY_VALUE] = o
289 end
interpolate() click to toggle source

Polymorphic interpolate

    # File lib/puppet/pops/model/factory.rb
118 def interpolate()
119   INTERPOLATION_VISITOR.visit_this_class(self, @model_class, EMPTY_ARRAY)
120 end
interpolate_AccessExpression(c) click to toggle source

rewrite left expression to variable if it is name, number, and recurse if it is an access expression this is for interpolation support in new lexer (${NAME}, ${NAME[}}, ${NUMBER}, ${NUMBER[]} - all other expressions requires variables to be preceded with $

     # File lib/puppet/pops/model/factory.rb
1077 def interpolate_AccessExpression(c)
1078   lhs = @init_hash[KEY_LEFT_EXPR]
1079   if is_interop_rewriteable?(lhs)
1080     @init_hash[KEY_LEFT_EXPR] = lhs.interpolate
1081   end
1082   self
1083 end
interpolate_CallMethodExpression(c) click to toggle source

Rewrite method calls on the form ${x.each …} to ${$x.each}

     # File lib/puppet/pops/model/factory.rb
1094 def interpolate_CallMethodExpression(c)
1095   functor_expr = @init_hash['functor_expr']
1096   if is_interop_rewriteable?(functor_expr)
1097     @init_hash['functor_expr'] = functor_expr.interpolate
1098   end
1099   self
1100 end
interpolate_Factory(c) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1056 def interpolate_Factory(c)
1057   self
1058 end
interpolate_LiteralInteger(c) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1060 def interpolate_LiteralInteger(c)
1061   # convert number to a variable
1062   self.var
1063 end
interpolate_NamedAccessExpression(c) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1085 def interpolate_NamedAccessExpression(c)
1086   lhs = @init_hash[KEY_LEFT_EXPR]
1087   if is_interop_rewriteable?(lhs)
1088     @init_hash[KEY_LEFT_EXPR] = lhs.interpolate
1089   end
1090   self
1091 end
interpolate_Object(c) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1065 def interpolate_Object(c)
1066   self
1067 end
interpolate_QualifiedName(c) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1069 def interpolate_QualifiedName(c)
1070   self.var
1071 end
is_interop_rewriteable?(o) click to toggle source
     # File lib/puppet/pops/model/factory.rb
1102 def is_interop_rewriteable?(o)
1103   mc = o.model_class
1104   if mc <= AccessExpression || mc <= QualifiedName || mc <= NamedAccessExpression || mc <= CallMethodExpression
1105     true
1106   elsif mc <= LiteralInteger
1107     # Only decimal integers can represent variables, else it is a number
1108     o['radix'] == 10
1109   else
1110     false
1111   end
1112 end
lambda=(lambda) click to toggle source
    # File lib/puppet/pops/model/factory.rb
599 def lambda=(lambda)
600   @init_hash['lambda'] = lambda
601   self
602 end
length() click to toggle source
    # File lib/puppet/pops/model/factory.rb
628 def length
629   @init_hash[KEY_LENGTH]
630 end
map_offset(model, locator) click to toggle source
   # File lib/puppet/pops/model/factory.rb
94 def map_offset(model, locator)
95   MAPOFFSET_VISITOR.visit_this_1(self, model, locator)
96 end
map_offset_Factory(o, locator) click to toggle source
    # File lib/puppet/pops/model/factory.rb
102 def map_offset_Factory(o, locator)
103   map_offset(o.model, locator)
104 end
map_offset_Object(o, locator) click to toggle source
    # File lib/puppet/pops/model/factory.rb
 98 def map_offset_Object(o, locator)
 99   o
100 end
map_offset_Positioned(o, locator) click to toggle source
    # File lib/puppet/pops/model/factory.rb
106 def map_offset_Positioned(o, locator)
107   # Transpose the local offset, length to global "coordinates"
108   global_offset, global_length = locator.to_global(o.offset, o.length)
109 
110   # mutate
111   o.instance_variable_set(:'@offset', global_offset)
112   o.instance_variable_set(:'@length', global_length)
113   # Change locator since the positions were transposed to the global coordinates
114   o.instance_variable_set(:'@locator', locator.locator) if locator.is_a? Puppet::Pops::Parser::Locator::SubLocator
115 end
minus() click to toggle source
    # File lib/puppet/pops/model/factory.rb
536 def minus();  f_build_unary(UnaryMinusExpression, self);      end
minus_set(r) click to toggle source

Assignment -=

    # File lib/puppet/pops/model/factory.rb
615 def minus_set(r)
616   f_build_binary_op(AssignmentExpression, '-=', self, r)
617 end
mne(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
576 def mne r;    f_match('!~', r);                               end
model() click to toggle source
   # File lib/puppet/pops/model/factory.rb
57 def model
58   if @current.nil?
59     # Assign a default Locator if it's missing. Should only happen when the factory is used by other
60     # means than from a parser (e.g. unit tests)
61     unless @init_hash.include?(KEY_LOCATOR)
62       @init_hash[KEY_LOCATOR] = Parser::Locator.locator('<no source>', 'no file')
63       unless @model_class <= Program
64         @init_hash[KEY_OFFSET] = 0
65         @init_hash[KEY_LENGTH] = 0
66       end
67     end
68     @current = create_model
69   end
70   @current
71 end
Also aliased as: current
ne(r;) click to toggle source
    # File lib/puppet/pops/model/factory.rb
572 def ne r;     f_comparison('!=', r);                          end
not() click to toggle source
    # File lib/puppet/pops/model/factory.rb
534 def not();    f_build_unary(NotExpression, self);             end
offset() click to toggle source
    # File lib/puppet/pops/model/factory.rb
624 def offset
625   @init_hash[KEY_OFFSET]
626 end
or(r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
530 def or(r)     f_build_binary(OrExpression, self, r);          end
paren() click to toggle source
    # File lib/puppet/pops/model/factory.rb
578 def paren;    f_build_unary(ParenthesizedExpression, self);   end
plus_set(r) click to toggle source

Assignment +=

    # File lib/puppet/pops/model/factory.rb
610 def plus_set(r)
611   f_build_binary_op(AssignmentExpression, '+=', self, r)
612 end
record_position(locator, start_locatable, end_locatable) click to toggle source

Records the position (start -> end) and computes the resulting length.

    # File lib/puppet/pops/model/factory.rb
634 def record_position(locator, start_locatable, end_locatable)
635   # record information directly in the Positioned object
636   start_offset = start_locatable.offset
637   @init_hash[KEY_LOCATOR] = locator
638   @init_hash[KEY_OFFSET] = start_offset
639   @init_hash[KEY_LENGTH] = end_locatable.nil? ? start_locatable.length : end_locatable.offset + end_locatable.length - start_offset
640   self
641 end
relop(op, r) click to toggle source
    # File lib/puppet/pops/model/factory.rb
580 def relop(op, r)
581   f_build_binary_op(RelationshipExpression, op, self, r)
582 end
select(*args) click to toggle source
    # File lib/puppet/pops/model/factory.rb
584 def select(*args)
585   Factory.new(SelectorExpression, self, *args)
586 end
set(r) click to toggle source

Assignment =

    # File lib/puppet/pops/model/factory.rb
605 def set(r)
606   f_build_binary_op(AssignmentExpression, '=', self, r)
607 end
text() click to toggle source
    # File lib/puppet/pops/model/factory.rb
540 def text();   f_build_unary(TextExpression, self);            end
to_s() click to toggle source
     # File lib/puppet/pops/model/factory.rb
1128 def to_s
1129   "Factory for #{@model_class}"
1130 end
type_expr(o) click to toggle source

Set Expression that should evaluate to the parameter's type

    # File lib/puppet/pops/model/factory.rb
735 def type_expr(o)
736   @init_hash['type_expr'] = o
737 end
unfold() click to toggle source
    # File lib/puppet/pops/model/factory.rb
538 def unfold(); f_build_unary(UnfoldExpression, self);          end
var() click to toggle source
    # File lib/puppet/pops/model/factory.rb
542 def var();    f_build_unary(VariableExpression, self);        end