summaryrefslogtreecommitdiff
path: root/spec/unit/pops/parser
AgeCommit message (Collapse)AuthorFilesLines
2014-10-03(PUP-3363) Make transformation of unparenthesized calls handle errorsHenrik Lindberg1-5/+20
This fixes problems when a user enters commas where they are not supposed to be. As a result, an expression will be parsed as being an argument list for an unparenthesized function call. The transformation logic for such calls did not take one case into account; a non call followed by an argument list. e.g: $a = 1,10 Which resulted in a strange AST model (a literal list with an assignment and a 10). This commit adds error checking and raising of an exception in the transformation which is caught by parser_support and formatted into an error - either about an illegal comma (when the LHS cannot possibly be a call at all (as in the above exampel), or a more elaborate message about that what could be a function call requires parentheses. In order to enable positioning of the error message on the first comma in the argumet list, the comma tokens were required in the expression list fed to the transformer. Subsequently these tokens must be filtered out by the transformation, and passed on in the raised exception (since the receiver would otherwise not know which token that caused the problem (it is nested inside the stucture it passes on to be transformed). Unparenthesized function calls are a very bad idea...
2014-08-27(PUP-2349) Specify mode as an octal string consistently in spec manifest ↵Kylo Ginsberg1-35/+35
snippets In the puppet 4.0 parser, the file resource's mode property will be required to be a string containing an octal (or symbolic) representation of mode. For consistency then, this commit changes all cases where mode was specified as a Numeric to be a string containing an octal representation of mode (always prefaced with a 0, again for clarity and consistency).
2014-08-04(PUP-2898) Specify terminal semicolon for resource bodiesJosh Partlow1-0/+9
There was a regression in the future parser in d25e462 which caused resources with multiple attributeless bodies constructed like this: file { '/foo':; '/bar':; } to fail because the future parser grammar was not allowing the terminal semicolon. The acceptance suite picked this up running with parser future. It slipped past specs because, even though we have a spec testing multiple attributeless resource bodies, it lacked a terminal semicolon. Henrik Lindberg figured out the minor egrammar fix here to correct the expression, and a test case is added to catch it in specs.
2014-08-01(PUP-2898) Add 4x style resource expressionsHenrik Lindberg5-84/+228
This changes the following: * Assignment has lower precedence than resource expressions * Local defaults are supported in resource instantiation expressions * A Resource body may have a new expression AttributesOperation that must evaluate to a hash. * Stricter validation of resource titles * Changes to TreeModelDumper wrt how BlockExpression is rendered (to improve debugging output). As a consequence many tests needed adjustments. * Tests that previously passed have been modified because of stricter validation. This also includes maintenance. Removing dead code/fixing stale comments and documentation.
2014-07-27(PUP-2860) Remove future parser's old lexerHenrik Lindberg1-840/+0
The old (intermediate) lexer was still hanging around even if it was not being used. Cycles were also wasted on unit testing it. The new lexer "Lexer2" has been in use for quite some time and the old lexer is not useful even as a reference at this point. This speeds up both loading and unit testing.
2014-07-15(PUP-2714) Support explicit creation of empty programHenrik Lindberg1-0/+16
An empty program (one without any expressions except "no-op") did not produce an instance of Model::Program. This is bad because it is of value to get the lexed/parsed model with line references for comment processing and other static analysis of the source. Now, an empty program will produce a Model::Program containing a single Model::Nop instruction. This instruction has offset at "EOF", and a length of 0 (thus, any comments in the input source are guaranteed to be placed before this nop.
2014-07-14Merge pull request #2755 from hlindberg/PUP-2693_length-of-sqstring-wrongJosh Partlow1-0/+10
(PUP-2693) Fix length calculation for sq-string
2014-07-02(PUP-2858) Refactor EvaluatingParser::Transitional to EvaluatingParserHenrik Lindberg2-2/+1
This merges the behavior of the Transitional subclass of the EvaluatingParser into the main class, as the hybrid solution is no longer a supported alternative. As a consequence, all references to the Pops::Parser::EvaluatingParser::Transitional has been changed to just Pops::Parser::EvaluatingParser. This commit alters no behavior.
2014-07-02(PUP-2858) Remove use of Puppet[:evaluator] from the code baseHenrik Lindberg1-1/+0
This removes all usage of Puppet[:evaluator] from the code base since it is (in this version) enough to check if Puppet[:parser] is 'future' as the future evaluator is always used.
2014-06-26(PUP-2682) Allow trailing comma after node matchesHenrik Lindberg1-0/+4
This adds the ability to have a trailing comma after the last match in a node expression.
2014-06-17(PUP-2727) Make new keywords acceptable as attribute names.Henrik Lindberg1-0/+19
Puppet allows keywords as attribute names in defines and parameterized classes. This was missing for the added keywords: * FUNCTION * ATTR * PRIVATE * TYPE Which caused a clash with existing types. This commit adds the new keywords to the list of accepted words in the grammar.
2014-06-12(maint) Improve tests for slurp on define/classAndrew Parker1-2/+2
The tests for define and class rejecting `*` parameters put another parameter after the one specified with `*`. This created an ambiguity in the test for why it is failing, since `*` is not allowed before any other parameters. Since the assertion is that define and class simply cannot have `*` parameters, the better test is to have a single parameter with a `*`.
2014-06-12(PUP-514) Add tests for lambdasAndrew Parker1-0/+9
The work so far has not been able to deal with type checking lambdas. This adds tests for the conditions that will need to be handled for lambdas to properly type check their arguments. Currently none of these new tests pass.
2014-06-12(PUP-514) Improve testing of typed parametersHenrik Lindberg1-0/+64
This improves testing of typed parameters, and the ivolved tests in general. One test moved from being an evaluation test (it only tested parsing). Iterative function testing changed to use better matchers.
2014-06-12(maint) Remove pending tests for parsing functions in puppetHenrik Lindberg1-32/+0
2014-06-12(PUP-514) Add support for opt-in typing of define/class parametersHenrik Lindberg1-0/+4
This makes define and class parameters support optionally typed parameters when using the future parser. The type expressions are evaluated by the Pops Bridge when parameters are transformed t 3x. The 3x parameters are not aware of type information (they are encoded as arrays), and changes to all the logic that deals with parameters turned on to not be a good design. The resource type and resource is instead made aware of the opt-in types via a separate param-name to type map that it applies in the validation step that was already performed.
2014-06-12(PUP-514) Add test for parsing of typed parametersHenrik Lindberg1-0/+28
This updates the tree dumper to dump parsed type information for parameters.
2014-06-09(PUP-2693) Fix length calculation for sq-stringHenrik Lindberg1-0/+10
The calculation of string length was done wrong for dingle quoted string resulting in negative lengths.
2014-05-16Merge remote-tracking branch 'upstream/stable'Josh Partlow1-2/+10
* upstream/stable: (PUP-2568) Remove unnecessary calls (maint) Reorder code to increase clarity (PUP-2581) Make illegal names interchangeable to legal variable work (PUP-2568) Downcase class name before validating Conflicts: lib/puppet/pops/parser/eparser.rb Rebuilt eparser.
2014-05-16(PUP-2581) Make illegal names interchangeable to legal variable workHenrik Lindberg1-2/+10
In interpolation when using expression mode ${} and having an illegal name (e.g. _x) that resulted in a syntax error as the _x got translated to a STRING token (a bare word not being a name). The interpolation logic could then not transform it into a (valid) variable expression (i.e. $_x). The change is to let the lexer emit a WORD token for the illegal NAME. The interpolation then changes that to a VARIBLE if it is the only expression. If the WORD token escapes into the grammar, it is equivalent to having used a quoted string in the source text. Note that WORD only accepts unqualified input, anything with a : that is not a valid NAME is still flagged as an error. Thus _x::y, x::_y are both illegal NAME.
2014-05-06Merge pull request #2542 from hlindberg/pup-2288_list-start-unless-wsJosh Partlow1-4/+11
(PUP-2288) Make [ be liststart if first in file or preceded by WS
2014-05-07(PUP-2288) Make [ be LISTSTART if first in file or preceded by WSHenrik Lindberg1-4/+11
The problem was that there was only one special case being handled by the lexer to dis-ambiguate if an expression followed by [ meant the start of an access operations (e.g. getting an entry out of an array), or if it represented the start of a literal array. The supported special case was NAME followed by non-WS followed by [. This meant that cases like foo(3) [a,b,c] were always treated as an access operation. The fix generalizes the dis-ambiguation so that all access operations must be written without interleaved WS.
2014-04-24(PUP-2240) Add unfold of array using splat unary * operatorHenrik Lindberg1-0/+5
This adds the ability to unfold values into individual parameters and entries in lists the same way as this is done in Ruby.
2014-04-18(PUP-2080) Remove function in the puppet languageAndrew Parker1-34/+0
This is a desired feature, but a distraction from our current goals. The 'function' keyword needs to be reserved as part of PUP-1027 and so I've left it in as a portion of the grammar.
2014-04-17(PUP-2176) Add test for parsing of typed parametersHenrik Lindberg1-0/+34
This updates the tree dumper to dump parsed type information for parameters. Tests are added that puppet functions can be parsed.
2014-04-08(PUP-2129) Fix issues with false interpolation start (no-such-method)Henrik Lindberg2-1/+26
This is a fix for the reported issue that 'slurpfunc' is an unknown method. Thankfuly that problem masked a much worse problem in that any false interolation start e.g. $%a was not correctly implemented, and there were no tests that covered this. The same issue also existed for interpolation in heredoc. This commit fixes the interpolation problem, and adds tests.
2014-03-08(PUP-1897) Improve test of EPP trim, and expr after paramsHenrik Lindberg1-0/+8
This adds tests for render single expression with trim, and for sequence of expressions after opening parameters.
2014-03-08(PUP-1897) Fix failing lexer2 test, and update with additional testsHenrik Lindberg1-0/+15
Tests were failing due to additional token marking the end of an EPP render expression.
2014-03-08(PUP-979) Fix unparenthesized calls with hash to not give strange errorHenrik Lindberg1-6/+10
Previously, an unparenthesized call followed by a hash would always result in an error that the hash was a resource body without title. The change now treats the resource body without title as an opportunity to transform the expression into a hash (and subsequently into a call with a hash as an argument). At the same time, the set of functions this is available for has been reduced to realize, require, contain, include, and the logging functions notice, info, warning, error, and the fail function.
2014-03-07(PUP-1895) Change <%( )%> to <%| |%> for EPP parametersHenrik Lindberg1-3/+3
2014-03-06(PUP-30) Fix tests and issues occurring when running testsHenrik Lindberg1-8/+9
2014-03-06(PUP-30) Add tests for epp parser and make them passHenrik Lindberg1-0/+77
This adds tests for parsing epp. A typo was corrected when checking for unbalanced <% %> at the end of the epp input. This caused error not to be raised. (Tests should have been included in an earlier commit).
2014-03-06(PUP-30) Make epp parser emit EPP_START, and generate ProgramHenrik Lindberg1-1/+6
Parsing EPP now results in a Program model (if producing only an EppExpression there are no source code references). The EPP_START tokten was not emitted (and its precence was not tested for).
2014-03-06(PUP-30) Add tests for heredoc at parser and evaluator levelsHenrik Lindberg1-0/+73
This also fixes issues found by running the new tests and debugging them.
2014-03-06(PUP-30) Complete implementation of sublocated expressionHenrik Lindberg1-1/+2
This completes the implementation of SubLocatedExpression. The SubLocator refactored to Locator (instead of being nested inside the support for Heredoc). Heredoc lexing, and the grammar now cooperate to ensure that sublocated model is wrapped.
2014-02-28(PUP-1814) Make double backslash in sq string behave as documented.Henrik Lindberg1-1/+8
This makes it possible to escapce a backslash in a sq string. Previously this did not work which made it impossible to end a sq string with a backslash.
2014-02-27(PUP-1576) Make hyphen in bare words legal (future parser)Henrik Lindberg1-0/+18
This adds the ability to use a hyphen in a bare word. The result is the same as if the bare word had been quoted in single quotes. It is not allowed to start or end a bare word with a hyphen, those are always interpreted as :MINUS.
2014-01-08Merge pull request #2232 from ↵Josh Partlow1-1/+1
hlindberg/pup-716_short-lived-objects-in-filesystem (PUP-716) short lived objects in filesystem
2014-01-07(PUP-800) Clean up and improve handling of location / positionHenrik Lindberg1-1/+2
There were several issues with the implementation of location handling - primarily missing the ability to be able to serialize/de-serialize the model with retained positioning information. This changes the design to bring the two values offset and length into each model object and that location information is recored in the top level Program construct. With this change a Program is always returned as the result of a parse. The change touches many files, due to the change to always return a Model::Program. Most of the change is removal of now no longer needed constructs.
2014-01-06(PUP-716) Fix up tests after FileSystem API changeHenrik Lindberg1-1/+1
One fixed test still failing on expectations
2013-12-17(maint) Fix future parser inability to parse virtual class instantiationHenrik Lindberg1-0/+14
The future parser removed the support to name a class "class". This led to missing that it is possible to create a virtual or exported class using resource expression syntax e.g. @class { 'theunreal': }. This is now fixed by adding an explicit parer rule for the @/@@ class case.
2013-12-12(PUP-490) Remove partial import-support from future evaluatorHenrik Lindberg1-9/+0
The support is removed (basically a mapping of a function call to the function "import" to a ImportExpression + removing tests. The intermediate future parser is still using ImportExpression, so model and related logic not changed, but marked with deprecation and "to be removed in Puppet 4" (or whenever the intermediate parser is removed from the code base). The grammar/parser is modified, but this is only a removal of a comment.
2013-12-05(#22363) Fix problem with integer string to Integer on Ruby 1.8.7Henrik Lindberg1-0/+10
The problem was caused by the logic using the Kernel method Integer(string, radix) which was introduced in Ruby 1.9.2. We do not need to pass radix, since the string converted starts with 0, 0x, or 0X in all cases.
2013-12-05(#21874) Apply making name[x] and name [x] different.Henrik Lindberg1-1/+9
This also includes a cleanup of LAMBDA (unused/dead logic in grammar)
2013-12-05(perf) Move all behcmarks to one unit test and exclude it with filterHenrik Lindberg4-70/+0
All parser benchmarks are now located in one spec unit test. Thy are automatically excluded by a filter that can be turned off by setting the ENV variable BENCHMARK to true when running the tests.
2013-12-05(#22363) Add parse / validate / evaluate tests, fix evaluator issuesHenrik Lindberg1-1/+0
This adds a comprehensive parse/validate/evaluate test for the future evaluator. Several parsing and evaluation issues were found and corrected.
2013-12-05(maint) Add use of new evaluator in specialization of EvaluatingParserHenrik Lindberg1-1/+1
This makes it easier to test the new evaluator as it is being developed. Add tests using the Transitional impl.
2013-12-05(perf) Include perf benchmark for parse + validateHenrik Lindberg1-17/+17
2013-12-05(#22962) Remove alternative lambda syntaxes from testsHenrik Lindberg2-0/+37
2013-12-05(maint) Fix parsing hostnames containing '.' as sequence instead of nameHenrik Lindberg1-7/+15
There was a problem with NAME no longer allowing '.' in names (it is only supported to enable a node to use a node match based on NAME. This changes the parser to parse a node name such as kermit.example.com as a sequence of names separated by dot.