puppet 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +6 -6
- data/LICENSE +1 -1
- data/README.md +8 -9
- data/conf/auth.conf +2 -2
- data/ext/README.environment +1 -1
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +1 -1
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppetmaster.README.debian +11 -9
- data/ext/emacs/puppet-mode.el +1 -1
- data/ext/envpuppet +2 -2
- data/ext/ips/puppetagent.xml +1 -1
- data/ext/ips/puppetmaster.xml +1 -1
- data/ext/project_data.yaml +8 -0
- data/ext/puppet-test +3 -3
- data/ext/rack/example-passenger-vhost.conf +1 -1
- data/ext/redhat/puppet.spec.erb +2 -2
- data/ext/regexp_nodes/regexp_nodes.rb +1 -1
- data/ext/solaris/pkginfo +1 -1
- data/ext/solaris/smf/puppet.xml +1 -1
- data/ext/suse/puppet.spec +2 -2
- data/ext/upload_facts.rb +1 -1
- data/ext/windows/puppet_interactive.bat +6 -0
- data/ext/windows/puppet_shell.bat +9 -0
- data/ext/windows/run_puppet_interactive.bat +9 -0
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +30 -20
- data/lib/hiera/scope.rb +1 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application/agent.rb +4 -2
- data/lib/puppet/application/apply.rb +7 -4
- data/lib/puppet/application/cert.rb +1 -1
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/lookup.rb +45 -47
- data/lib/puppet/application/master.rb +2 -2
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/configurer.rb +100 -22
- data/lib/puppet/data_providers/hiera_config.rb +28 -3
- data/lib/puppet/data_providers/hiera_interpolate.rb +30 -15
- data/lib/puppet/data_providers/hiera_support.rb +1 -1
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -2
- data/lib/puppet/data_providers/lookup_adapter.rb +73 -26
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -2
- data/lib/puppet/defaults.rb +69 -22
- data/lib/puppet/environments.rb +3 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/epp.rb +1 -1
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/face/parser.rb +12 -9
- data/lib/puppet/face/status.rb +2 -1
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/telnet.rb +9 -0
- data/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/lib/puppet/file_serving/metadata.rb +18 -2
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system/file_impl.rb +2 -2
- data/lib/puppet/file_system/memory_impl.rb +1 -1
- data/lib/puppet/file_system/uniquefile.rb +1 -1
- data/lib/puppet/file_system.rb +2 -2
- data/lib/puppet/forge/repository.rb +1 -31
- data/lib/puppet/forge.rb +1 -1
- data/lib/puppet/functions/assert_type.rb +9 -9
- data/lib/puppet/functions/each.rb +5 -13
- data/lib/puppet/functions/filter.rb +5 -14
- data/lib/puppet/functions/lookup.rb +126 -150
- data/lib/puppet/functions/map.rb +6 -14
- data/lib/puppet/functions/match.rb +1 -0
- data/lib/puppet/functions/reduce.rb +5 -13
- data/lib/puppet/functions/reverse_each.rb +82 -0
- data/lib/puppet/functions/scanf.rb +15 -18
- data/lib/puppet/functions/slice.rb +22 -36
- data/lib/puppet/functions/split.rb +2 -2
- data/lib/puppet/functions/step.rb +88 -0
- data/lib/puppet/functions/type.rb +70 -0
- data/lib/puppet/functions.rb +45 -6
- data/lib/puppet/graph/rb_tree_map.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +188 -5
- data/lib/puppet/indirector/facts/facter.rb +2 -13
- data/lib/puppet/indirector/file_content/http.rb +15 -0
- data/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/lib/puppet/indirector/generic_http.rb +16 -0
- data/lib/puppet/indirector/hiera.rb +3 -1
- data/lib/puppet/indirector/indirection.rb +6 -2
- data/lib/puppet/indirector/json.rb +2 -2
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/rest.rb +2 -1
- data/lib/puppet/info_service/class_information_service.rb +13 -12
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +9 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +2 -2
- data/lib/puppet/module_tool/tar/mini.rb +3 -3
- data/lib/puppet/network/http/pool.rb +9 -0
- data/lib/puppet/node/environment.rb +11 -2
- data/lib/puppet/node.rb +11 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +19 -22
- data/lib/puppet/parser/compiler.rb +4 -11
- data/lib/puppet/parser/environment_compiler.rb +0 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +128 -149
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -0
- data/lib/puppet/parser/functions/scanf.rb +15 -26
- data/lib/puppet/parser/functions/slice.rb +17 -24
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions.rb +28 -16
- data/lib/puppet/parser/resource.rb +19 -17
- data/lib/puppet/parser/scope.rb +176 -5
- data/lib/puppet/plugins/data_providers/data_provider.rb +56 -14
- data/lib/puppet/pops/adaptable.rb +4 -1
- data/lib/puppet/pops/adapters.rb +80 -12
- data/lib/puppet/pops/binder/binder.rb +21 -17
- data/lib/puppet/pops/binder/binder_issues.rb +8 -6
- data/lib/puppet/pops/binder/bindings_checker.rb +12 -8
- data/lib/puppet/pops/binder/bindings_composer.rb +16 -12
- data/lib/puppet/pops/binder/bindings_factory.rb +108 -104
- data/lib/puppet/pops/binder/bindings_model.rb +49 -47
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +10 -6
- data/lib/puppet/pops/binder/injector.rb +53 -48
- data/lib/puppet/pops/binder/key_factory.rb +10 -6
- data/lib/puppet/pops/binder/producers.rb +67 -62
- data/lib/puppet/pops/evaluator/access_operator.rb +98 -96
- data/lib/puppet/pops/evaluator/closure.rb +122 -106
- data/lib/puppet/pops/evaluator/collector_transformer.rb +34 -14
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +0 -1
- data/lib/puppet/pops/evaluator/compare_operator.rb +13 -9
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +9 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +78 -76
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +85 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +13 -11
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +5 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +47 -42
- data/lib/puppet/pops/functions/function.rb +6 -2
- data/lib/puppet/pops/issue_reporter.rb +6 -4
- data/lib/puppet/pops/issues.rb +50 -11
- data/lib/puppet/pops/loader/base_loader.rb +1 -1
- data/lib/puppet/pops/loader/loader.rb +1 -1
- data/lib/puppet/pops/loader/loader_paths.rb +15 -0
- data/lib/puppet/pops/loader/module_loaders.rb +17 -13
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +18 -13
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +16 -3
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +55 -0
- data/lib/puppet/pops/loaders.rb +51 -9
- data/lib/puppet/pops/lookup/explainer.rb +73 -3
- data/lib/puppet/pops/lookup/invocation.rb +21 -19
- data/lib/puppet/pops/lookup.rb +17 -12
- data/lib/puppet/pops/merge_strategy.rb +16 -19
- data/lib/puppet/pops/model/factory.rb +179 -157
- data/lib/puppet/pops/model/model.rb +17 -8
- data/lib/puppet/pops/model/model_label_provider.rb +14 -7
- data/lib/puppet/pops/model/model_meta.rb +17 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +8 -0
- data/lib/puppet/pops/parser/egrammar.ra +38 -14
- data/lib/puppet/pops/parser/eparser.rb +1353 -1276
- data/lib/puppet/pops/parser/epp_support.rb +11 -7
- data/lib/puppet/pops/parser/evaluating_parser.rb +17 -13
- data/lib/puppet/pops/parser/heredoc_support.rb +15 -11
- data/lib/puppet/pops/parser/lexer2.rb +428 -403
- data/lib/puppet/pops/parser/lexer_support.rb +85 -7
- data/lib/puppet/pops/parser/locator.rb +21 -0
- data/lib/puppet/pops/parser/parser_support.rb +19 -16
- data/lib/puppet/pops/parser/slurp_support.rb +16 -8
- data/lib/puppet/pops/types/class_loader.rb +23 -19
- data/lib/puppet/pops/types/enumeration.rb +9 -26
- data/lib/puppet/pops/types/iterable.rb +308 -0
- data/lib/puppet/pops/types/recursion_guard.rb +82 -0
- data/lib/puppet/pops/types/type_acceptor.rb +25 -0
- data/lib/puppet/pops/types/type_asserter.rb +10 -9
- data/lib/puppet/pops/types/type_calculator.rb +140 -387
- data/lib/puppet/pops/types/type_factory.rb +91 -57
- data/lib/puppet/pops/types/type_formatter.rb +334 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +226 -59
- data/lib/puppet/pops/types/type_parser.rb +159 -112
- data/lib/puppet/pops/types/types.rb +2057 -1253
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation/checker4_0.rb +115 -63
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +8 -4
- data/lib/puppet/pops/validation.rb +11 -9
- data/lib/puppet/pops.rb +0 -8
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +2 -2
- data/lib/puppet/provider/macauthorization/macauthorization.rb +10 -9
- data/lib/puppet/provider/nameservice/directoryservice.rb +35 -50
- data/lib/puppet/provider/package/appdmg.rb +3 -2
- data/lib/puppet/provider/package/dnf.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +16 -9
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -2
- data/lib/puppet/provider/package/pkgng.rb +13 -4
- data/lib/puppet/provider/package/rpm.rb +0 -1
- data/lib/puppet/provider/package/windows.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/package/zypper.rb +19 -0
- data/lib/puppet/provider/service/debian.rb +7 -20
- data/lib/puppet/provider/service/init.rb +7 -0
- data/lib/puppet/provider/service/launchd.rb +6 -12
- data/lib/puppet/provider/service/systemd.rb +9 -2
- data/lib/puppet/provider/sshkey/parsed.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +33 -58
- data/lib/puppet/provider/user/windows_adsi.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +6 -3
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/resource/capability_finder.rb +20 -13
- data/lib/puppet/resource/catalog.rb +60 -3
- data/lib/puppet/resource/status.rb +11 -2
- data/lib/puppet/resource/type.rb +33 -42
- data/lib/puppet/resource.rb +15 -12
- data/lib/puppet/settings/config_file.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +13 -5
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/validator/default_validator.rb +1 -1
- data/lib/puppet/test/test_helper.rb +16 -4
- data/lib/puppet/transaction/additional_resource_generator.rb +23 -5
- data/lib/puppet/transaction/report.rb +31 -1
- data/lib/puppet/transaction/resource_harness.rb +0 -25
- data/lib/puppet/transaction.rb +15 -2
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/cron.rb +12 -12
- data/lib/puppet/type/file/checksum_value.rb +53 -0
- data/lib/puppet/type/file/content.rb +26 -111
- data/lib/puppet/type/file/data_sync.rb +84 -0
- data/lib/puppet/type/file/ensure.rb +17 -14
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/file/source.rb +103 -18
- data/lib/puppet/type/file.rb +91 -39
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +6 -2
- data/lib/puppet/type/interface.rb +8 -3
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/package.rb +6 -0
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/user.rb +19 -17
- data/lib/puppet/type/yumrepo.rb +20 -0
- data/lib/puppet/type.rb +11 -11
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/execution.rb +1 -1
- data/lib/puppet/util/http_proxy.rb +72 -0
- data/lib/puppet/util/log.rb +2 -0
- data/lib/puppet/util/logging.rb +43 -1
- data/lib/puppet/util/monkey_patches.rb +2 -2
- data/lib/puppet/util/multi_match.rb +51 -0
- data/lib/puppet/util/network_device/cisco/device.rb +10 -2
- data/lib/puppet/util/network_device/cisco/interface.rb +21 -8
- data/lib/puppet/util/network_device/transport/ssh.rb +7 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +39 -36
- data/lib/puppet/util/plist.rb +130 -0
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/skip_tags.rb +9 -0
- data/lib/puppet/util/windows/access_control_entry.rb +1 -1
- data/lib/puppet/util/windows/access_control_list.rb +3 -3
- data/lib/puppet/util/windows/adsi.rb +65 -28
- data/lib/puppet/util/windows/api_types.rb +24 -18
- data/lib/puppet/util/windows/com.rb +3 -3
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/file.rb +8 -8
- data/lib/puppet/util/windows/principal.rb +190 -0
- data/lib/puppet/util/windows/process.rb +78 -11
- data/lib/puppet/util/windows/registry.rb +22 -16
- data/lib/puppet/util/windows/root_certs.rb +5 -5
- data/lib/puppet/util/windows/security.rb +33 -35
- data/lib/puppet/util/windows/security_descriptor.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +84 -15
- data/lib/puppet/util/windows/taskscheduler.rb +15 -15
- data/lib/puppet/util/windows/user.rb +10 -10
- data/lib/puppet/util/windows.rb +4 -0
- data/lib/puppet/util.rb +109 -22
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +1 -1
- data/lib/puppet/vendor/pathspec/LICENSE +2 -2
- data/lib/puppet/vendor/pathspec/README.md +1 -1
- data/lib/puppet/vendor/rgen/README.rdoc +1 -1
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +14 -0
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +17 -0
- data/lib/semver.rb +17 -1
- data/man/man5/puppet.conf.5 +12 -12
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +2 -2
- data/man/man8/puppet-catalog.8 +2 -2
- data/man/man8/puppet-cert.8 +2 -2
- data/man/man8/puppet-certificate.8 +2 -2
- data/man/man8/puppet-certificate_request.8 +2 -2
- data/man/man8/puppet-certificate_revocation_list.8 +2 -2
- data/man/man8/puppet-config.8 +3 -3
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +2 -2
- data/man/man8/puppet-facts.8 +2 -2
- data/man/man8/puppet-file.8 +2 -2
- data/man/man8/puppet-filebucket.8 +2 -2
- data/man/man8/puppet-help.8 +2 -2
- data/man/man8/puppet-inspect.8 +2 -2
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-man.8 +2 -2
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +9 -9
- data/man/man8/puppet-node.8 +2 -2
- data/man/man8/puppet-parser.8 +2 -2
- data/man/man8/puppet-plugin.8 +2 -2
- data/man/man8/puppet-report.8 +2 -2
- data/man/man8/puppet-resource.8 +2 -2
- data/man/man8/puppet-resource_type.8 +2 -2
- data/man/man8/puppet-status.8 +3 -3
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/module.tar.gz +0 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +4 -0
- data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/data.pp +10 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/data/empty.json +0 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +2 -1
- data/spec/fixtures/unit/module/trailing-comma.json +1 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +8 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/types/zero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +81 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseeone.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseezero.pp +1 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-broken-notices.txt +187 -0
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +8 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +197 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +205 -0
- data/spec/integration/defaults_spec.rb +14 -2
- data/spec/integration/file_system/uniquefile_spec.rb +29 -0
- data/spec/integration/module_tool/tar/mini_spec.rb +28 -0
- data/spec/integration/node/environment_spec.rb +13 -0
- data/spec/integration/parser/collection_spec.rb +8 -0
- data/spec/integration/parser/dynamic_scoping_spec.rb +67 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +336 -0
- data/spec/integration/parser/undef_param_spec.rb +8 -0
- data/spec/integration/provider/yumrepo_spec.rb +1 -1
- data/spec/integration/test/test_helper_spec.rb +28 -0
- data/spec/integration/transaction/report_spec.rb +16 -0
- data/spec/integration/transaction_spec.rb +11 -0
- data/spec/integration/type/file_spec.rb +194 -4
- data/spec/integration/type/package_spec.rb +5 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/util/execution_spec.rb +22 -0
- data/spec/integration/util/windows/principal_spec.rb +201 -0
- data/spec/integration/util/windows/process_spec.rb +31 -0
- data/spec/{unit → integration}/util/windows/registry_spec.rb +91 -1
- data/spec/integration/util/windows/security_spec.rb +8 -8
- data/spec/integration/util/windows/user_spec.rb +1 -1
- data/spec/integration/util_spec.rb +49 -27
- data/spec/lib/puppet_spec/compiler.rb +17 -0
- data/spec/lib/puppet_spec/files.rb +2 -2
- data/spec/lib/puppet_spec/pops.rb +13 -0
- data/spec/shared_behaviours/iterative_functions.rb +1 -1
- data/spec/shared_contexts/types_setup.rb +96 -0
- data/spec/unit/agent_spec.rb +1 -0
- data/spec/unit/application/agent_spec.rb +10 -0
- data/spec/unit/application/apply_spec.rb +9 -0
- data/spec/unit/application/lookup_spec.rb +138 -28
- data/spec/unit/configurer/downloader_spec.rb +5 -5
- data/spec/unit/configurer_spec.rb +271 -39
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +182 -5
- data/spec/unit/data_providers/hiera_interpolation_spec.rb +57 -0
- data/spec/unit/defaults_spec.rb +15 -0
- data/spec/unit/environments_spec.rb +24 -4
- data/spec/unit/face/epp_face_spec.rb +2 -2
- data/spec/unit/face/parser_spec.rb +43 -2
- data/spec/unit/file_serving/http_metadata_spec.rb +85 -0
- data/spec/unit/file_serving/metadata_spec.rb +50 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +12 -2
- data/spec/unit/file_system_spec.rb +26 -0
- data/spec/unit/functions/assert_type_spec.rb +36 -2
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +17 -9
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lookup_spec.rb +88 -16
- data/spec/unit/functions/regsubst_spec.rb +1 -1
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions4_spec.rb +62 -6
- data/spec/unit/hiera/scope_spec.rb +5 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +705 -4
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/indirection_spec.rb +1 -1
- data/spec/unit/indirector/json_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +94 -32
- data/spec/unit/module_spec.rb +14 -0
- data/spec/unit/module_tool/applications/builder_spec.rb +4 -4
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +1 -0
- data/spec/unit/network/http/pool_spec.rb +30 -0
- data/spec/unit/node_spec.rb +8 -0
- data/spec/unit/parser/compiler_spec.rb +16 -18
- data/spec/unit/parser/scope_spec.rb +28 -11
- data/spec/unit/pops/evaluator/access_ops_spec.rb +7 -7
- data/spec/unit/pops/evaluator/comparison_ops_spec.rb +3 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -2
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +4 -4
- data/spec/unit/pops/evaluator/json_strict_literal_evaluator_spec.rb +63 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +6 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +53 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +127 -2
- data/spec/unit/pops/parser/lexer2_spec.rb +118 -3
- data/spec/unit/pops/parser/parse_calls_spec.rb +8 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/parser/parser_spec.rb +10 -0
- data/spec/unit/pops/parser/source_pos_adapter_spec.rb +26 -0
- data/spec/unit/pops/types/iterable_spec.rb +262 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +91 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +105 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +43 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +275 -390
- data/spec/unit/pops/types/type_formatter_spec.rb +280 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +152 -0
- data/spec/unit/pops/types/type_parser_spec.rb +58 -13
- data/spec/unit/pops/types/types_spec.rb +241 -0
- data/spec/unit/pops/validator/validator_spec.rb +159 -15
- data/spec/unit/provider/cron/parsed_spec.rb +1 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +8 -8
- data/spec/unit/provider/macauthorization_spec.rb +5 -2
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +14 -19
- data/spec/unit/provider/package/appdmg_spec.rb +3 -3
- data/spec/unit/provider/package/dnf_spec.rb +16 -0
- data/spec/unit/provider/package/pip3_spec.rb +60 -42
- data/spec/unit/provider/package/pip_spec.rb +88 -47
- data/spec/unit/provider/package/pkgdmg_spec.rb +18 -9
- data/spec/unit/provider/package/pkgng_spec.rb +4 -2
- data/spec/unit/provider/package/rpm_spec.rb +2 -25
- data/spec/unit/provider/package/yum_spec.rb +12 -1
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/service/debian_spec.rb +6 -24
- data/spec/unit/provider/service/init_spec.rb +11 -1
- data/spec/unit/provider/service/launchd_spec.rb +18 -25
- data/spec/unit/provider/service/systemd_spec.rb +25 -12
- data/spec/unit/provider/service/upstart_spec.rb +57 -0
- data/spec/unit/provider/sshkey/parsed_spec.rb +20 -19
- data/spec/unit/provider/user/directoryservice_spec.rb +40 -59
- data/spec/unit/provider/user/windows_adsi_spec.rb +5 -5
- data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
- data/spec/unit/resource/capability_finder_spec.rb +28 -15
- data/spec/unit/resource/catalog_spec.rb +33 -1
- data/spec/unit/resource/type_spec.rb +149 -7
- data/spec/unit/resource_spec.rb +99 -50
- data/spec/unit/settings/environment_conf_spec.rb +18 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/transaction/report_spec.rb +27 -0
- data/spec/unit/transaction/resource_harness_spec.rb +0 -47
- data/spec/unit/transaction_spec.rb +5 -0
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/checksum_value_spec.rb +286 -0
- data/spec/unit/type/file/content_spec.rb +12 -193
- data/spec/unit/type/file/source_spec.rb +211 -119
- data/spec/unit/type/file_spec.rb +133 -34
- data/spec/unit/type/interface_spec.rb +32 -0
- data/spec/unit/type/macauthorization_spec.rb +4 -1
- data/spec/unit/type/yumrepo_spec.rb +2 -2
- data/spec/unit/util/filetype_spec.rb +1 -1
- data/spec/unit/util/http_proxy_spec.rb +2 -2
- data/spec/unit/util/log/destinations_spec.rb +0 -2
- data/spec/unit/util/logging_spec.rb +69 -0
- data/spec/unit/util/multi_match_spec.rb +39 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +253 -216
- data/spec/unit/util/network_device/transport/telnet_spec.rb +60 -58
- data/spec/unit/util/plist_spec.rb +110 -0
- data/spec/unit/util/resource_template_spec.rb +2 -2
- data/spec/unit/util/run_mode_spec.rb +27 -3
- data/spec/unit/util/windows/adsi_spec.rb +46 -38
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/security_descriptor_spec.rb +3 -3
- data/spec/unit/util/windows/sid_spec.rb +48 -11
- data/spec/unit/util_spec.rb +123 -13
- data/tasks/cfpropertylist.rake +15 -0
- metadata +3342 -3195
- data/lib/puppet/vendor/load_plist.rb +0 -1
- data/lib/puppet/vendor/plist/CHANGELOG +0 -82
- data/lib/puppet/vendor/plist/MIT-LICENSE +0 -21
- data/lib/puppet/vendor/plist/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/plist/README +0 -36
- data/lib/puppet/vendor/plist/Rakefile +0 -144
- data/lib/puppet/vendor/plist/docs/USAGE +0 -104
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +0 -591
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +0 -224
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +0 -225
- data/lib/puppet/vendor/plist/lib/plist.rb +0 -22
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +0 -203
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +0 -104
- data/lib/puppet/vendor/plist/test/assets/commented.plist +0 -9
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +0 -259
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +0 -24
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +0 -13
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +0 -115
- data/lib/puppet/vendor/plist/test/test_generator.rb +0 -59
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +0 -58
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +0 -82
- data/lib/puppet/vendor/plist/test/test_parser.rb +0 -90
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
- /data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
|
@@ -12,12 +12,14 @@ require 'puppet/pops/parser/interpolation_support'
|
|
|
12
12
|
require 'puppet/pops/parser/epp_support'
|
|
13
13
|
require 'puppet/pops/parser/slurp_support'
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
include
|
|
19
|
-
include
|
|
20
|
-
include
|
|
15
|
+
module Puppet::Pops
|
|
16
|
+
module Parser
|
|
17
|
+
class Lexer2
|
|
18
|
+
include LexerSupport
|
|
19
|
+
include HeredocSupport
|
|
20
|
+
include InterpolationSupport
|
|
21
|
+
include SlurpSupport
|
|
22
|
+
include EppSupport
|
|
21
23
|
|
|
22
24
|
# ALl tokens have three slots, the token name (a Symbol), the token text (String), and a token text length.
|
|
23
25
|
# All operator and punctuation tokens reuse singleton arrays Tokens that require unique values create
|
|
@@ -111,26 +113,26 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
111
113
|
# Booleans are pre-calculated (rather than evaluating the strings "false" "true" repeatedly.
|
|
112
114
|
#
|
|
113
115
|
KEYWORDS = {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
'case' => [:CASE, 'case', 4],
|
|
117
|
+
'class' => [:CLASS, 'class', 5],
|
|
118
|
+
'default' => [:DEFAULT, 'default', 7],
|
|
119
|
+
'define' => [:DEFINE, 'define', 6],
|
|
120
|
+
'if' => [:IF, 'if', 2],
|
|
121
|
+
'elsif' => [:ELSIF, 'elsif', 5],
|
|
122
|
+
'else' => [:ELSE, 'else', 4],
|
|
123
|
+
'inherits' => [:INHERITS, 'inherits', 8],
|
|
124
|
+
'node' => [:NODE, 'node', 4],
|
|
125
|
+
'and' => [:AND, 'and', 3],
|
|
126
|
+
'or' => [:OR, 'or', 2],
|
|
127
|
+
'undef' => [:UNDEF, 'undef', 5],
|
|
128
|
+
'false' => [:BOOLEAN, false, 5],
|
|
129
|
+
'true' => [:BOOLEAN, true, 4],
|
|
130
|
+
'in' => [:IN, 'in', 2],
|
|
131
|
+
'unless' => [:UNLESS, 'unless', 6],
|
|
132
|
+
'function' => [:FUNCTION, 'function', 8],
|
|
133
|
+
'type' => [:TYPE, 'type', 4],
|
|
134
|
+
'attr' => [:ATTR, 'attr', 4],
|
|
135
|
+
'private' => [:PRIVATE, 'private', 7],
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
KEYWORDS.each {|k,v| v[1].freeze; v.freeze }
|
|
@@ -142,16 +144,16 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
142
144
|
# hit the appmgmt-specific code paths
|
|
143
145
|
APP_MANAGEMENT_TOKENS = {
|
|
144
146
|
:with_appm => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
'application' => [:APPLICATION, 'application', 11],
|
|
148
|
+
'consumes' => [:CONSUMES, 'consumes', 8],
|
|
149
|
+
'produces' => [:PRODUCES, 'produces', 8],
|
|
150
|
+
'site' => [:SITE, 'site', 4]
|
|
149
151
|
},
|
|
150
152
|
:without_appm => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
'application' => [:APPLICATION_R, 'application', 11],
|
|
154
|
+
'consumes' => [:CONSUMES_R, 'consumes', 8],
|
|
155
|
+
'produces' => [:PRODUCES_R, 'produces', 8],
|
|
156
|
+
'site' => [:SITE_R, 'site', 4]
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -205,6 +207,382 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
205
207
|
attr_reader :locator
|
|
206
208
|
|
|
207
209
|
def initialize()
|
|
210
|
+
@selector = {
|
|
211
|
+
'.' => lambda { emit(TOKEN_DOT, @scanner.pos) },
|
|
212
|
+
',' => lambda { emit(TOKEN_COMMA, @scanner.pos) },
|
|
213
|
+
'[' => lambda do
|
|
214
|
+
before = @scanner.pos
|
|
215
|
+
if (before == 0 || @scanner.string[locator.char_offset(before)-1,1] =~ /[[:blank:]\r\n]+/)
|
|
216
|
+
emit(TOKEN_LISTSTART, before)
|
|
217
|
+
else
|
|
218
|
+
emit(TOKEN_LBRACK, before)
|
|
219
|
+
end
|
|
220
|
+
end,
|
|
221
|
+
']' => lambda { emit(TOKEN_RBRACK, @scanner.pos) },
|
|
222
|
+
'(' => lambda { emit(TOKEN_LPAREN, @scanner.pos) },
|
|
223
|
+
')' => lambda { emit(TOKEN_RPAREN, @scanner.pos) },
|
|
224
|
+
';' => lambda { emit(TOKEN_SEMIC, @scanner.pos) },
|
|
225
|
+
'?' => lambda { emit(TOKEN_QMARK, @scanner.pos) },
|
|
226
|
+
'*' => lambda { emit(TOKEN_TIMES, @scanner.pos) },
|
|
227
|
+
'%' => lambda do
|
|
228
|
+
scn = @scanner
|
|
229
|
+
before = scn.pos
|
|
230
|
+
la = scn.peek(2)
|
|
231
|
+
if la[1] == '>' && @lexing_context[:epp_mode]
|
|
232
|
+
scn.pos += 2
|
|
233
|
+
if @lexing_context[:epp_mode] == :expr
|
|
234
|
+
enqueue_completed(TOKEN_EPPEND, before)
|
|
235
|
+
end
|
|
236
|
+
@lexing_context[:epp_mode] = :text
|
|
237
|
+
interpolate_epp
|
|
238
|
+
else
|
|
239
|
+
emit(TOKEN_MODULO, before)
|
|
240
|
+
end
|
|
241
|
+
end,
|
|
242
|
+
'{' => lambda do
|
|
243
|
+
# The lexer needs to help the parser since the technology used cannot deal with
|
|
244
|
+
# lookahead of same token with different precedence. This is solved by making left brace
|
|
245
|
+
# after ? into a separate token.
|
|
246
|
+
#
|
|
247
|
+
@lexing_context[:brace_count] += 1
|
|
248
|
+
emit(if @lexing_context[:after] == :QMARK
|
|
249
|
+
TOKEN_SELBRACE
|
|
250
|
+
else
|
|
251
|
+
TOKEN_LBRACE
|
|
252
|
+
end, @scanner.pos)
|
|
253
|
+
end,
|
|
254
|
+
'}' => lambda do
|
|
255
|
+
@lexing_context[:brace_count] -= 1
|
|
256
|
+
emit(TOKEN_RBRACE, @scanner.pos)
|
|
257
|
+
end,
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
# TOKENS @, @@, @(
|
|
261
|
+
'@' => lambda do
|
|
262
|
+
scn = @scanner
|
|
263
|
+
la = scn.peek(2)
|
|
264
|
+
if la[1] == '@'
|
|
265
|
+
emit(TOKEN_ATAT, scn.pos) # TODO; Check if this is good for the grammar
|
|
266
|
+
elsif la[1] == '('
|
|
267
|
+
heredoc
|
|
268
|
+
else
|
|
269
|
+
emit(TOKEN_AT, scn.pos)
|
|
270
|
+
end
|
|
271
|
+
end,
|
|
272
|
+
|
|
273
|
+
# TOKENS |, |>, |>>
|
|
274
|
+
'|' => lambda do
|
|
275
|
+
scn = @scanner
|
|
276
|
+
la = scn.peek(3)
|
|
277
|
+
emit(la[1] == '>' ? (la[2] == '>' ? TOKEN_RRCOLLECT : TOKEN_RCOLLECT) : TOKEN_PIPE, scn.pos)
|
|
278
|
+
end,
|
|
279
|
+
|
|
280
|
+
# TOKENS =, =>, ==, =~
|
|
281
|
+
'=' => lambda do
|
|
282
|
+
scn = @scanner
|
|
283
|
+
la = scn.peek(2)
|
|
284
|
+
emit(case la[1]
|
|
285
|
+
when '='
|
|
286
|
+
TOKEN_ISEQUAL
|
|
287
|
+
when '>'
|
|
288
|
+
TOKEN_FARROW
|
|
289
|
+
when '~'
|
|
290
|
+
TOKEN_MATCH
|
|
291
|
+
else
|
|
292
|
+
TOKEN_EQUALS
|
|
293
|
+
end, scn.pos)
|
|
294
|
+
end,
|
|
295
|
+
|
|
296
|
+
# TOKENS '+', '+=', and '+>'
|
|
297
|
+
'+' => lambda do
|
|
298
|
+
scn = @scanner
|
|
299
|
+
la = scn.peek(2)
|
|
300
|
+
emit(case la[1]
|
|
301
|
+
when '='
|
|
302
|
+
TOKEN_APPENDS
|
|
303
|
+
when '>'
|
|
304
|
+
TOKEN_PARROW
|
|
305
|
+
else
|
|
306
|
+
TOKEN_PLUS
|
|
307
|
+
end, scn.pos)
|
|
308
|
+
end,
|
|
309
|
+
|
|
310
|
+
# TOKENS '-', '->', and epp '-%>' (end of interpolation with trim)
|
|
311
|
+
'-' => lambda do
|
|
312
|
+
scn = @scanner
|
|
313
|
+
la = scn.peek(3)
|
|
314
|
+
before = scn.pos
|
|
315
|
+
if @lexing_context[:epp_mode] && la[1] == '%' && la[2] == '>'
|
|
316
|
+
scn.pos += 3
|
|
317
|
+
if @lexing_context[:epp_mode] == :expr
|
|
318
|
+
enqueue_completed(TOKEN_EPPEND_TRIM, before)
|
|
319
|
+
end
|
|
320
|
+
interpolate_epp(:with_trim)
|
|
321
|
+
else
|
|
322
|
+
emit(case la[1]
|
|
323
|
+
when '>'
|
|
324
|
+
TOKEN_IN_EDGE
|
|
325
|
+
when '='
|
|
326
|
+
TOKEN_DELETES
|
|
327
|
+
else
|
|
328
|
+
TOKEN_MINUS
|
|
329
|
+
end, before)
|
|
330
|
+
end
|
|
331
|
+
end,
|
|
332
|
+
|
|
333
|
+
# TOKENS !, !=, !~
|
|
334
|
+
'!' => lambda do
|
|
335
|
+
scn = @scanner
|
|
336
|
+
la = scn.peek(2)
|
|
337
|
+
emit(case la[1]
|
|
338
|
+
when '='
|
|
339
|
+
TOKEN_NOTEQUAL
|
|
340
|
+
when '~'
|
|
341
|
+
TOKEN_NOMATCH
|
|
342
|
+
else
|
|
343
|
+
TOKEN_NOT
|
|
344
|
+
end, scn.pos)
|
|
345
|
+
end,
|
|
346
|
+
|
|
347
|
+
# TOKENS ~>, ~
|
|
348
|
+
'~' => lambda do
|
|
349
|
+
scn = @scanner
|
|
350
|
+
la = scn.peek(2)
|
|
351
|
+
emit(la[1] == '>' ? TOKEN_IN_EDGE_SUB : TOKEN_TILDE, scn.pos)
|
|
352
|
+
end,
|
|
353
|
+
|
|
354
|
+
'#' => lambda { @scanner.skip(PATTERN_COMMENT); nil },
|
|
355
|
+
|
|
356
|
+
# TOKENS '/', '/*' and '/ regexp /'
|
|
357
|
+
'/' => lambda do
|
|
358
|
+
scn = @scanner
|
|
359
|
+
la = scn.peek(2)
|
|
360
|
+
if la[1] == '*'
|
|
361
|
+
lex_error(Issues::UNCLOSED_MLCOMMENT) if scn.skip(PATTERN_MLCOMMENT).nil?
|
|
362
|
+
nil
|
|
363
|
+
else
|
|
364
|
+
before = scn.pos
|
|
365
|
+
# regexp position is a regexp, else a div
|
|
366
|
+
if regexp_acceptable? && value = scn.scan(PATTERN_REGEX)
|
|
367
|
+
# Ensure an escaped / was not matched
|
|
368
|
+
while value[-2..-2] == STRING_BSLASH_BSLASH # i.e. \\
|
|
369
|
+
value += scn.scan_until(PATTERN_REGEX_END)
|
|
370
|
+
end
|
|
371
|
+
regex = value.sub(PATTERN_REGEX_A, '').sub(PATTERN_REGEX_Z, '').gsub(PATTERN_REGEX_ESC, '/')
|
|
372
|
+
emit_completed([:REGEX, Regexp.new(regex), scn.pos-before], before)
|
|
373
|
+
else
|
|
374
|
+
emit(TOKEN_DIV, before)
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
end,
|
|
378
|
+
|
|
379
|
+
# TOKENS <, <=, <|, <<|, <<, <-, <~
|
|
380
|
+
'<' => lambda do
|
|
381
|
+
scn = @scanner
|
|
382
|
+
la = scn.peek(3)
|
|
383
|
+
emit(case la[1]
|
|
384
|
+
when '<'
|
|
385
|
+
if la[2] == '|'
|
|
386
|
+
TOKEN_LLCOLLECT
|
|
387
|
+
else
|
|
388
|
+
TOKEN_LSHIFT
|
|
389
|
+
end
|
|
390
|
+
when '='
|
|
391
|
+
TOKEN_LESSEQUAL
|
|
392
|
+
when '|'
|
|
393
|
+
TOKEN_LCOLLECT
|
|
394
|
+
when '-'
|
|
395
|
+
TOKEN_OUT_EDGE
|
|
396
|
+
when '~'
|
|
397
|
+
TOKEN_OUT_EDGE_SUB
|
|
398
|
+
else
|
|
399
|
+
TOKEN_LESSTHAN
|
|
400
|
+
end, scn.pos)
|
|
401
|
+
end,
|
|
402
|
+
|
|
403
|
+
# TOKENS >, >=, >>
|
|
404
|
+
'>' => lambda do
|
|
405
|
+
scn = @scanner
|
|
406
|
+
la = scn.peek(2)
|
|
407
|
+
emit(case la[1]
|
|
408
|
+
when '>'
|
|
409
|
+
TOKEN_RSHIFT
|
|
410
|
+
when '='
|
|
411
|
+
TOKEN_GREATEREQUAL
|
|
412
|
+
else
|
|
413
|
+
TOKEN_GREATERTHAN
|
|
414
|
+
end, scn.pos)
|
|
415
|
+
end,
|
|
416
|
+
|
|
417
|
+
# TOKENS :, ::CLASSREF, ::NAME
|
|
418
|
+
':' => lambda do
|
|
419
|
+
scn = @scanner
|
|
420
|
+
la = scn.peek(3)
|
|
421
|
+
before = scn.pos
|
|
422
|
+
if la[1] == ':'
|
|
423
|
+
# PERFORMANCE NOTE: This could potentially be speeded up by using a case/when listing all
|
|
424
|
+
# upper case letters. Alternatively, the 'A', and 'Z' comparisons may be faster if they are
|
|
425
|
+
# frozen.
|
|
426
|
+
#
|
|
427
|
+
la2 = la[2]
|
|
428
|
+
if la2 >= 'A' && la2 <= 'Z'
|
|
429
|
+
# CLASSREF or error
|
|
430
|
+
value = scn.scan(PATTERN_CLASSREF)
|
|
431
|
+
if value && scn.peek(2) != '::'
|
|
432
|
+
after = scn.pos
|
|
433
|
+
emit_completed([:CLASSREF, value.freeze, after-before], before)
|
|
434
|
+
else
|
|
435
|
+
# move to faulty position ('::<uc-letter>' was ok)
|
|
436
|
+
scn.pos = scn.pos + 3
|
|
437
|
+
lex_error(Issues::ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE)
|
|
438
|
+
end
|
|
439
|
+
else
|
|
440
|
+
value = scn.scan(PATTERN_BARE_WORD)
|
|
441
|
+
if value
|
|
442
|
+
if value =~ PATTERN_NAME
|
|
443
|
+
emit_completed([:NAME, value.freeze, scn.pos - before], before)
|
|
444
|
+
else
|
|
445
|
+
emit_completed([:WORD, value.freeze, scn.pos - before], before)
|
|
446
|
+
end
|
|
447
|
+
else
|
|
448
|
+
# move to faulty position ('::' was ok)
|
|
449
|
+
scn.pos = scn.pos + 2
|
|
450
|
+
lex_error(Issues::ILLEGAL_FULLY_QUALIFIED_NAME)
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
else
|
|
454
|
+
emit(TOKEN_COLON, before)
|
|
455
|
+
end
|
|
456
|
+
end,
|
|
457
|
+
|
|
458
|
+
'$' => lambda do
|
|
459
|
+
scn = @scanner
|
|
460
|
+
before = scn.pos
|
|
461
|
+
if value = scn.scan(PATTERN_DOLLAR_VAR)
|
|
462
|
+
emit_completed([:VARIABLE, value[1..-1].freeze, scn.pos - before], before)
|
|
463
|
+
else
|
|
464
|
+
# consume the $ and let higher layer complain about the error instead of getting a syntax error
|
|
465
|
+
emit(TOKEN_VARIABLE_EMPTY, before)
|
|
466
|
+
end
|
|
467
|
+
end,
|
|
468
|
+
|
|
469
|
+
'"' => lambda do
|
|
470
|
+
# Recursive string interpolation, 'interpolate' either returns a STRING token, or
|
|
471
|
+
# a DQPRE with the rest of the string's tokens placed in the @token_queue
|
|
472
|
+
interpolate_dq
|
|
473
|
+
end,
|
|
474
|
+
|
|
475
|
+
"'" => lambda do
|
|
476
|
+
scn = @scanner
|
|
477
|
+
before = scn.pos
|
|
478
|
+
emit_completed([:STRING, slurp_sqstring.freeze, scn.pos - before], before)
|
|
479
|
+
end,
|
|
480
|
+
|
|
481
|
+
"\n" => lambda do
|
|
482
|
+
# If heredoc_cont is in effect there are heredoc text lines to skip over
|
|
483
|
+
# otherwise just skip the newline.
|
|
484
|
+
#
|
|
485
|
+
ctx = @lexing_context
|
|
486
|
+
if ctx[:newline_jump]
|
|
487
|
+
@scanner.pos = ctx[:newline_jump]
|
|
488
|
+
ctx[:newline_jump] = nil
|
|
489
|
+
else
|
|
490
|
+
@scanner.pos += 1
|
|
491
|
+
end
|
|
492
|
+
nil
|
|
493
|
+
end,
|
|
494
|
+
'' => lambda { nil } # when the peek(1) returns empty
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
[ ' ', "\t", "\r" ].each { |c| @selector[c] = lambda { @scanner.skip(PATTERN_WS); nil } }
|
|
498
|
+
|
|
499
|
+
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].each do |c|
|
|
500
|
+
@selector[c] = lambda do
|
|
501
|
+
scn = @scanner
|
|
502
|
+
before = scn.pos
|
|
503
|
+
value = scn.scan(PATTERN_NUMBER)
|
|
504
|
+
if value
|
|
505
|
+
length = scn.pos - before
|
|
506
|
+
assert_numeric(value, before)
|
|
507
|
+
emit_completed([:NUMBER, value.freeze, length], before)
|
|
508
|
+
else
|
|
509
|
+
invalid_number = scn.scan_until(PATTERN_NON_WS)
|
|
510
|
+
if before > 1
|
|
511
|
+
after = scn.pos
|
|
512
|
+
scn.pos = before - 1
|
|
513
|
+
if scn.peek(1) == '.'
|
|
514
|
+
# preceded by a dot. Is this a bad decimal number then?
|
|
515
|
+
scn.pos = before - 2
|
|
516
|
+
while scn.peek(1) =~ /^\d$/
|
|
517
|
+
invalid_number = nil
|
|
518
|
+
before = scn.pos
|
|
519
|
+
break if before == 0
|
|
520
|
+
scn.pos = scn.pos - 1
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
scn.pos = before
|
|
524
|
+
invalid_number = scn.peek(after - before) unless invalid_number
|
|
525
|
+
end
|
|
526
|
+
length = scn.pos - before
|
|
527
|
+
assert_numeric(invalid_number, before)
|
|
528
|
+
scn.pos = before + 1
|
|
529
|
+
lex_error(Issues::ILLEGAL_NUMBER, {:value => invalid_number})
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
534
|
+
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_'].each do |c|
|
|
535
|
+
@selector[c] = lambda do
|
|
536
|
+
|
|
537
|
+
scn = @scanner
|
|
538
|
+
before = scn.pos
|
|
539
|
+
value = scn.scan(PATTERN_BARE_WORD)
|
|
540
|
+
if value && value =~ PATTERN_NAME
|
|
541
|
+
emit_completed(KEYWORDS[value] || @appm_keywords[value] || [:NAME, value.freeze, scn.pos - before], before)
|
|
542
|
+
elsif value
|
|
543
|
+
emit_completed([:WORD, value.freeze, scn.pos - before], before)
|
|
544
|
+
else
|
|
545
|
+
# move to faulty position ([a-z_] was ok)
|
|
546
|
+
scn.pos = scn.pos + 1
|
|
547
|
+
fully_qualified = scn.match?(/::/)
|
|
548
|
+
if fully_qualified
|
|
549
|
+
lex_error(Issues::ILLEGAL_FULLY_QUALIFIED_NAME)
|
|
550
|
+
else
|
|
551
|
+
lex_error(Issues::ILLEGAL_NAME_OR_BARE_WORD)
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
558
|
+
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'].each do |c|
|
|
559
|
+
@selector[c] = lambda do
|
|
560
|
+
scn = @scanner
|
|
561
|
+
before = scn.pos
|
|
562
|
+
value = @scanner.scan(PATTERN_CLASSREF)
|
|
563
|
+
if value && @scanner.peek(2) != '::'
|
|
564
|
+
emit_completed([:CLASSREF, value.freeze, scn.pos - before], before)
|
|
565
|
+
else
|
|
566
|
+
# move to faulty position ([A-Z] was ok)
|
|
567
|
+
scn.pos = scn.pos + 1
|
|
568
|
+
lex_error(Issues::ILLEGAL_CLASS_REFERENCE)
|
|
569
|
+
end
|
|
570
|
+
end
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
@selector.default = lambda do
|
|
574
|
+
# In case of unicode spaces of various kinds that are captured by a regexp, but not by the
|
|
575
|
+
# simpler case expression above (not worth handling those special cases with better performance).
|
|
576
|
+
scn = @scanner
|
|
577
|
+
if scn.skip(PATTERN_WS)
|
|
578
|
+
nil
|
|
579
|
+
else
|
|
580
|
+
# "unrecognized char"
|
|
581
|
+
emit([:OTHER, scn.peek(0), 1], scn.pos)
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
@selector.each { |k,v| k.freeze }
|
|
585
|
+
@selector.freeze
|
|
208
586
|
end
|
|
209
587
|
|
|
210
588
|
# Clears the lexer state (it is not required to call this as it will be garbage collected
|
|
@@ -228,20 +606,22 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
228
606
|
|
|
229
607
|
def lex_string(string, path='')
|
|
230
608
|
initvars
|
|
609
|
+
assert_not_bom(string)
|
|
231
610
|
@scanner = StringScanner.new(string)
|
|
232
|
-
@locator =
|
|
611
|
+
@locator = Locator.locator(string, path)
|
|
233
612
|
end
|
|
234
613
|
|
|
235
614
|
# Lexes an unquoted string.
|
|
236
615
|
# @param string [String] the string to lex
|
|
237
|
-
# @param locator [
|
|
616
|
+
# @param locator [Locator] the locator to use (a default is used if nil is given)
|
|
238
617
|
# @param escapes [Array<String>] array of character strings representing the escape sequences to transform
|
|
239
618
|
# @param interpolate [Boolean] whether interpolation of expressions should be made or not.
|
|
240
619
|
#
|
|
241
620
|
def lex_unquoted_string(string, locator, escapes, interpolate)
|
|
242
621
|
initvars
|
|
622
|
+
assert_not_bom(string)
|
|
243
623
|
@scanner = StringScanner.new(string)
|
|
244
|
-
@locator = locator ||
|
|
624
|
+
@locator = locator || Locator.locator(string, '')
|
|
245
625
|
@lexing_context[:escapes] = escapes || UQ_ESCAPES
|
|
246
626
|
@lexing_context[:uq_slurp_pattern] = interpolate ? (escapes.include?('$') ? SLURP_UQ_PATTERN : SLURP_UQNE_PATTERN) : SLURP_ALL_PATTERN
|
|
247
627
|
end
|
|
@@ -264,9 +644,10 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
264
644
|
#
|
|
265
645
|
def lex_file(file)
|
|
266
646
|
initvars
|
|
267
|
-
contents = Puppet::FileSystem.exist?(file) ? Puppet::FileSystem.read(file) :
|
|
647
|
+
contents = Puppet::FileSystem.exist?(file) ? Puppet::FileSystem.read(file, :encoding => 'utf-8') : ''
|
|
648
|
+
assert_not_bom(contents)
|
|
268
649
|
@scanner = StringScanner.new(contents.freeze)
|
|
269
|
-
@locator =
|
|
650
|
+
@locator = Locator.locator(contents, file)
|
|
270
651
|
end
|
|
271
652
|
|
|
272
653
|
def initvars
|
|
@@ -285,7 +666,7 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
285
666
|
#
|
|
286
667
|
def fullscan
|
|
287
668
|
result = []
|
|
288
|
-
scan {|token
|
|
669
|
+
scan {|token| result.push(token) }
|
|
289
670
|
result
|
|
290
671
|
end
|
|
291
672
|
|
|
@@ -303,16 +684,17 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
303
684
|
# every token in the lexed content.
|
|
304
685
|
#
|
|
305
686
|
scn = @scanner
|
|
687
|
+
lex_error_without_pos(Issues::NO_INPUT_TO_LEXER) unless scn
|
|
688
|
+
|
|
306
689
|
ctx = @lexing_context
|
|
307
690
|
queue = @token_queue
|
|
308
|
-
|
|
309
|
-
lex_error_without_pos(Puppet::Pops::Issues::NO_INPUT_TO_LEXER) unless scn
|
|
691
|
+
selector = @selector
|
|
310
692
|
|
|
311
693
|
scn.skip(PATTERN_WS)
|
|
312
694
|
|
|
313
695
|
# This is the lexer's main loop
|
|
314
696
|
until queue.empty? && scn.eos? do
|
|
315
|
-
if token = queue.shift ||
|
|
697
|
+
if token = queue.shift || selector[scn.peek(1)].call
|
|
316
698
|
ctx[:after] = token[0]
|
|
317
699
|
yield token
|
|
318
700
|
end
|
|
@@ -326,366 +708,7 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
326
708
|
# PERFORMANCE NOTE: Any change to this logic should be performance measured.
|
|
327
709
|
#
|
|
328
710
|
def lex_token
|
|
329
|
-
|
|
330
|
-
scn = @scanner
|
|
331
|
-
ctx = @lexing_context
|
|
332
|
-
before = @scanner.pos
|
|
333
|
-
|
|
334
|
-
# A look ahead of 3 characters is used since the longest operator ambiguity is resolved at that point.
|
|
335
|
-
# PERFORMANCE NOTE: It is faster to peek once and use three separate variables for lookahead 0, 1 and 2.
|
|
336
|
-
#
|
|
337
|
-
la = scn.peek(3)
|
|
338
|
-
return nil if la.empty?
|
|
339
|
-
|
|
340
|
-
# PERFORMANCE NOTE.
|
|
341
|
-
# It is slightly faster to use these local variables than accessing la[0], la[1] etc. in ruby 1.9.3
|
|
342
|
-
# But not big enough to warrant two completely different implementations.
|
|
343
|
-
#
|
|
344
|
-
la0 = la[0]
|
|
345
|
-
la1 = la[1]
|
|
346
|
-
la2 = la[2]
|
|
347
|
-
|
|
348
|
-
# PERFORMANCE NOTE:
|
|
349
|
-
# A case when, where all the cases are literal values is the fastest way to map from data to code.
|
|
350
|
-
# It is much faster than using a hash with lambdas, hash with symbol used to then invoke send etc.
|
|
351
|
-
# This case statement is evaluated for most character positions in puppet source, and great care must
|
|
352
|
-
# be taken to not introduce performance regressions.
|
|
353
|
-
#
|
|
354
|
-
case la0
|
|
355
|
-
|
|
356
|
-
when '.'
|
|
357
|
-
emit(TOKEN_DOT, before)
|
|
358
|
-
|
|
359
|
-
when ','
|
|
360
|
-
emit(TOKEN_COMMA, before)
|
|
361
|
-
|
|
362
|
-
when '['
|
|
363
|
-
if (before == 0 || scn.string[locator.char_offset(before)-1,1] =~ /[[:blank:]\r\n]+/)
|
|
364
|
-
emit(TOKEN_LISTSTART, before)
|
|
365
|
-
else
|
|
366
|
-
emit(TOKEN_LBRACK, before)
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
when ']'
|
|
370
|
-
emit(TOKEN_RBRACK, before)
|
|
371
|
-
|
|
372
|
-
when '('
|
|
373
|
-
emit(TOKEN_LPAREN, before)
|
|
374
|
-
|
|
375
|
-
when ')'
|
|
376
|
-
emit(TOKEN_RPAREN, before)
|
|
377
|
-
|
|
378
|
-
when ';'
|
|
379
|
-
emit(TOKEN_SEMIC, before)
|
|
380
|
-
|
|
381
|
-
when '?'
|
|
382
|
-
emit(TOKEN_QMARK, before)
|
|
383
|
-
|
|
384
|
-
when '*'
|
|
385
|
-
emit(TOKEN_TIMES, before)
|
|
386
|
-
|
|
387
|
-
when '%'
|
|
388
|
-
if la1 == '>' && ctx[:epp_mode]
|
|
389
|
-
scn.pos += 2
|
|
390
|
-
if ctx[:epp_mode] == :expr
|
|
391
|
-
enqueue_completed(TOKEN_EPPEND, before)
|
|
392
|
-
end
|
|
393
|
-
ctx[:epp_mode] = :text
|
|
394
|
-
interpolate_epp
|
|
395
|
-
else
|
|
396
|
-
emit(TOKEN_MODULO, before)
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
when '{'
|
|
400
|
-
# The lexer needs to help the parser since the technology used cannot deal with
|
|
401
|
-
# lookahead of same token with different precedence. This is solved by making left brace
|
|
402
|
-
# after ? into a separate token.
|
|
403
|
-
#
|
|
404
|
-
ctx[:brace_count] += 1
|
|
405
|
-
emit(if ctx[:after] == :QMARK
|
|
406
|
-
TOKEN_SELBRACE
|
|
407
|
-
else
|
|
408
|
-
TOKEN_LBRACE
|
|
409
|
-
end, before)
|
|
410
|
-
|
|
411
|
-
when '}'
|
|
412
|
-
ctx[:brace_count] -= 1
|
|
413
|
-
emit(TOKEN_RBRACE, before)
|
|
414
|
-
|
|
415
|
-
# TOKENS @, @@, @(
|
|
416
|
-
when '@'
|
|
417
|
-
case la1
|
|
418
|
-
when '@'
|
|
419
|
-
emit(TOKEN_ATAT, before) # TODO; Check if this is good for the grammar
|
|
420
|
-
when '('
|
|
421
|
-
heredoc
|
|
422
|
-
else
|
|
423
|
-
emit(TOKEN_AT, before)
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
# TOKENS |, |>, |>>
|
|
427
|
-
when '|'
|
|
428
|
-
emit(case la1
|
|
429
|
-
when '>'
|
|
430
|
-
la2 == '>' ? TOKEN_RRCOLLECT : TOKEN_RCOLLECT
|
|
431
|
-
else
|
|
432
|
-
TOKEN_PIPE
|
|
433
|
-
end, before)
|
|
434
|
-
|
|
435
|
-
# TOKENS =, =>, ==, =~
|
|
436
|
-
when '='
|
|
437
|
-
emit(case la1
|
|
438
|
-
when '='
|
|
439
|
-
TOKEN_ISEQUAL
|
|
440
|
-
when '>'
|
|
441
|
-
TOKEN_FARROW
|
|
442
|
-
when '~'
|
|
443
|
-
TOKEN_MATCH
|
|
444
|
-
else
|
|
445
|
-
TOKEN_EQUALS
|
|
446
|
-
end, before)
|
|
447
|
-
|
|
448
|
-
# TOKENS '+', '+=', and '+>'
|
|
449
|
-
when '+'
|
|
450
|
-
emit(case la1
|
|
451
|
-
when '='
|
|
452
|
-
TOKEN_APPENDS
|
|
453
|
-
when '>'
|
|
454
|
-
TOKEN_PARROW
|
|
455
|
-
else
|
|
456
|
-
TOKEN_PLUS
|
|
457
|
-
end, before)
|
|
458
|
-
|
|
459
|
-
# TOKENS '-', '->', and epp '-%>' (end of interpolation with trim)
|
|
460
|
-
when '-'
|
|
461
|
-
if ctx[:epp_mode] && la1 == '%' && la2 == '>'
|
|
462
|
-
scn.pos += 3
|
|
463
|
-
if ctx[:epp_mode] == :expr
|
|
464
|
-
enqueue_completed(TOKEN_EPPEND_TRIM, before)
|
|
465
|
-
end
|
|
466
|
-
interpolate_epp(:with_trim)
|
|
467
|
-
else
|
|
468
|
-
emit(case la1
|
|
469
|
-
when '>'
|
|
470
|
-
TOKEN_IN_EDGE
|
|
471
|
-
when '='
|
|
472
|
-
TOKEN_DELETES
|
|
473
|
-
else
|
|
474
|
-
TOKEN_MINUS
|
|
475
|
-
end, before)
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
# TOKENS !, !=, !~
|
|
479
|
-
when '!'
|
|
480
|
-
emit(case la1
|
|
481
|
-
when '='
|
|
482
|
-
TOKEN_NOTEQUAL
|
|
483
|
-
when '~'
|
|
484
|
-
TOKEN_NOMATCH
|
|
485
|
-
else
|
|
486
|
-
TOKEN_NOT
|
|
487
|
-
end, before)
|
|
488
|
-
|
|
489
|
-
# TOKENS ~>, ~
|
|
490
|
-
when '~'
|
|
491
|
-
emit(la1 == '>' ? TOKEN_IN_EDGE_SUB : TOKEN_TILDE, before)
|
|
492
|
-
|
|
493
|
-
when '#'
|
|
494
|
-
scn.skip(PATTERN_COMMENT)
|
|
495
|
-
nil
|
|
496
|
-
|
|
497
|
-
# TOKENS '/', '/*' and '/ regexp /'
|
|
498
|
-
when '/'
|
|
499
|
-
case la1
|
|
500
|
-
when '*'
|
|
501
|
-
scn.skip(PATTERN_MLCOMMENT)
|
|
502
|
-
nil
|
|
503
|
-
|
|
504
|
-
else
|
|
505
|
-
# regexp position is a regexp, else a div
|
|
506
|
-
if regexp_acceptable? && value = scn.scan(PATTERN_REGEX)
|
|
507
|
-
# Ensure an escaped / was not matched
|
|
508
|
-
while value[-2..-2] == STRING_BSLASH_BSLASH # i.e. \\
|
|
509
|
-
value += scn.scan_until(PATTERN_REGEX_END)
|
|
510
|
-
end
|
|
511
|
-
regex = value.sub(PATTERN_REGEX_A, '').sub(PATTERN_REGEX_Z, '').gsub(PATTERN_REGEX_ESC, '/')
|
|
512
|
-
emit_completed([:REGEX, Regexp.new(regex), scn.pos-before], before)
|
|
513
|
-
else
|
|
514
|
-
emit(TOKEN_DIV, before)
|
|
515
|
-
end
|
|
516
|
-
end
|
|
517
|
-
|
|
518
|
-
# TOKENS <, <=, <|, <<|, <<, <-, <~
|
|
519
|
-
when '<'
|
|
520
|
-
emit(case la1
|
|
521
|
-
when '<'
|
|
522
|
-
if la2 == '|'
|
|
523
|
-
TOKEN_LLCOLLECT
|
|
524
|
-
else
|
|
525
|
-
TOKEN_LSHIFT
|
|
526
|
-
end
|
|
527
|
-
when '='
|
|
528
|
-
TOKEN_LESSEQUAL
|
|
529
|
-
when '|'
|
|
530
|
-
TOKEN_LCOLLECT
|
|
531
|
-
when '-'
|
|
532
|
-
TOKEN_OUT_EDGE
|
|
533
|
-
when '~'
|
|
534
|
-
TOKEN_OUT_EDGE_SUB
|
|
535
|
-
else
|
|
536
|
-
TOKEN_LESSTHAN
|
|
537
|
-
end, before)
|
|
538
|
-
|
|
539
|
-
# TOKENS >, >=, >>
|
|
540
|
-
when '>'
|
|
541
|
-
emit(case la1
|
|
542
|
-
when '>'
|
|
543
|
-
TOKEN_RSHIFT
|
|
544
|
-
when '='
|
|
545
|
-
TOKEN_GREATEREQUAL
|
|
546
|
-
else
|
|
547
|
-
TOKEN_GREATERTHAN
|
|
548
|
-
end, before)
|
|
549
|
-
|
|
550
|
-
# TOKENS :, ::CLASSREF, ::NAME
|
|
551
|
-
when ':'
|
|
552
|
-
if la1 == ':'
|
|
553
|
-
before = scn.pos
|
|
554
|
-
# PERFORMANCE NOTE: This could potentially be speeded up by using a case/when listing all
|
|
555
|
-
# upper case letters. Alternatively, the 'A', and 'Z' comparisons may be faster if they are
|
|
556
|
-
# frozen.
|
|
557
|
-
#
|
|
558
|
-
if la2 >= 'A' && la2 <= 'Z'
|
|
559
|
-
# CLASSREF or error
|
|
560
|
-
value = scn.scan(PATTERN_CLASSREF)
|
|
561
|
-
if value && scn.peek(2) != '::'
|
|
562
|
-
after = scn.pos
|
|
563
|
-
emit_completed([:CLASSREF, value.freeze, after-before], before)
|
|
564
|
-
else
|
|
565
|
-
# move to faulty position ('::<uc-letter>' was ok)
|
|
566
|
-
scn.pos = scn.pos + 3
|
|
567
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE)
|
|
568
|
-
end
|
|
569
|
-
else
|
|
570
|
-
value = scn.scan(PATTERN_BARE_WORD)
|
|
571
|
-
if value
|
|
572
|
-
if value =~ PATTERN_NAME
|
|
573
|
-
emit_completed([:NAME, value.freeze, scn.pos-before], before)
|
|
574
|
-
else
|
|
575
|
-
emit_completed([:WORD, value.freeze, scn.pos - before], before)
|
|
576
|
-
end
|
|
577
|
-
else
|
|
578
|
-
# move to faulty position ('::' was ok)
|
|
579
|
-
scn.pos = scn.pos + 2
|
|
580
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_FULLY_QUALIFIED_NAME)
|
|
581
|
-
end
|
|
582
|
-
end
|
|
583
|
-
else
|
|
584
|
-
emit(TOKEN_COLON, before)
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
when '$'
|
|
588
|
-
if value = scn.scan(PATTERN_DOLLAR_VAR)
|
|
589
|
-
emit_completed([:VARIABLE, value[1..-1].freeze, scn.pos - before], before)
|
|
590
|
-
else
|
|
591
|
-
# consume the $ and let higher layer complain about the error instead of getting a syntax error
|
|
592
|
-
emit(TOKEN_VARIABLE_EMPTY, before)
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
when '"'
|
|
596
|
-
# Recursive string interpolation, 'interpolate' either returns a STRING token, or
|
|
597
|
-
# a DQPRE with the rest of the string's tokens placed in the @token_queue
|
|
598
|
-
interpolate_dq
|
|
599
|
-
|
|
600
|
-
when "'"
|
|
601
|
-
emit_completed([:STRING, slurp_sqstring.freeze, scn.pos - before], before)
|
|
602
|
-
|
|
603
|
-
when '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
|
604
|
-
value = scn.scan(PATTERN_NUMBER)
|
|
605
|
-
if value
|
|
606
|
-
length = scn.pos - before
|
|
607
|
-
assert_numeric(value, before)
|
|
608
|
-
emit_completed([:NUMBER, value.freeze, length], before)
|
|
609
|
-
else
|
|
610
|
-
invalid_number = scn.scan_until(PATTERN_NON_WS)
|
|
611
|
-
if before > 1
|
|
612
|
-
after = scn.pos
|
|
613
|
-
scn.pos = before - 1
|
|
614
|
-
if scn.peek(1) == '.'
|
|
615
|
-
# preceded by a dot. Is this a bad decimal number then?
|
|
616
|
-
scn.pos = before - 2
|
|
617
|
-
while scn.peek(1) =~ /^\d$/
|
|
618
|
-
invalid_number = nil
|
|
619
|
-
before = scn.pos
|
|
620
|
-
break if before == 0
|
|
621
|
-
scn.pos = scn.pos - 1
|
|
622
|
-
end
|
|
623
|
-
end
|
|
624
|
-
scn.pos = before
|
|
625
|
-
invalid_number = scn.peek(after - before) unless invalid_number
|
|
626
|
-
end
|
|
627
|
-
length = scn.pos - before
|
|
628
|
-
assert_numeric(invalid_number, before)
|
|
629
|
-
scn.pos = before + 1
|
|
630
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_NUMBER, {:value => invalid_number})
|
|
631
|
-
end
|
|
632
|
-
|
|
633
|
-
when 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
634
|
-
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_'
|
|
635
|
-
|
|
636
|
-
value = scn.scan(PATTERN_BARE_WORD)
|
|
637
|
-
if value && value =~ PATTERN_NAME
|
|
638
|
-
emit_completed(KEYWORDS[value] || @appm_keywords[value] || [:NAME, value.freeze, scn.pos - before], before)
|
|
639
|
-
elsif value
|
|
640
|
-
emit_completed([:WORD, value.freeze, scn.pos - before], before)
|
|
641
|
-
else
|
|
642
|
-
# move to faulty position ([a-z_] was ok)
|
|
643
|
-
scn.pos = scn.pos + 1
|
|
644
|
-
fully_qualified = scn.match?(/::/)
|
|
645
|
-
if fully_qualified
|
|
646
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_FULLY_QUALIFIED_NAME)
|
|
647
|
-
else
|
|
648
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_NAME_OR_BARE_WORD)
|
|
649
|
-
end
|
|
650
|
-
end
|
|
651
|
-
|
|
652
|
-
when 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
653
|
-
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
|
654
|
-
value = scn.scan(PATTERN_CLASSREF)
|
|
655
|
-
if value && scn.peek(2) != '::'
|
|
656
|
-
emit_completed([:CLASSREF, value.freeze, scn.pos - before], before)
|
|
657
|
-
else
|
|
658
|
-
# move to faulty position ([A-Z] was ok)
|
|
659
|
-
scn.pos = scn.pos + 1
|
|
660
|
-
lex_error(Puppet::Pops::Issues::ILLEGAL_CLASS_REFERENCE)
|
|
661
|
-
end
|
|
662
|
-
|
|
663
|
-
when "\n"
|
|
664
|
-
# If heredoc_cont is in effect there are heredoc text lines to skip over
|
|
665
|
-
# otherwise just skip the newline.
|
|
666
|
-
#
|
|
667
|
-
if ctx[:newline_jump]
|
|
668
|
-
scn.pos = ctx[:newline_jump]
|
|
669
|
-
ctx[:newline_jump] = nil
|
|
670
|
-
else
|
|
671
|
-
scn.pos += 1
|
|
672
|
-
end
|
|
673
|
-
return nil
|
|
674
|
-
|
|
675
|
-
when ' ', "\t", "\r"
|
|
676
|
-
scn.skip(PATTERN_WS)
|
|
677
|
-
return nil
|
|
678
|
-
|
|
679
|
-
else
|
|
680
|
-
# In case of unicode spaces of various kinds that are captured by a regexp, but not by the
|
|
681
|
-
# simpler case expression above (not worth handling those special cases with better performance).
|
|
682
|
-
if scn.skip(PATTERN_WS)
|
|
683
|
-
nil
|
|
684
|
-
else
|
|
685
|
-
# "unrecognized char"
|
|
686
|
-
emit([:OTHER, la0, 1], before)
|
|
687
|
-
end
|
|
688
|
-
end
|
|
711
|
+
@selector[@scanner.peek(1)].call
|
|
689
712
|
end
|
|
690
713
|
|
|
691
714
|
# Emits (produces) a token [:tokensymbol, TokenValue] and moves the scanner's position past the token
|
|
@@ -741,3 +764,5 @@ class Puppet::Pops::Parser::Lexer2
|
|
|
741
764
|
end
|
|
742
765
|
|
|
743
766
|
end
|
|
767
|
+
end
|
|
768
|
+
end
|