Age | Commit message (Collapse) | Author | Files | Lines |
|
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...
|
|
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).
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
(PUP-2693) Fix length calculation for sq-string
|
|
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.
|
|
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.
|
|
This adds the ability to have a trailing comma after the last
match in a node expression.
|
|
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.
|
|
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 `*`.
|
|
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.
|
|
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.
|
|
|
|
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.
|
|
This updates the tree dumper to dump parsed type information
for parameters.
|
|
The calculation of string length was done wrong for dingle
quoted string resulting in negative lengths.
|
|
* 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.
|
|
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.
|
|
(PUP-2288) Make [ be liststart if first in file or preceded by WS
|
|
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.
|
|
This adds the ability to unfold values into individual parameters
and entries in lists the same way as this is done in Ruby.
|
|
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.
|
|
This updates the tree dumper to dump parsed type information
for parameters. Tests are added that puppet functions can be parsed.
|
|
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.
|
|
This adds tests for render single expression with trim, and for
sequence of expressions after opening parameters.
|
|
Tests were failing due to additional token marking the end of
an EPP render expression.
|
|
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.
|
|
|
|
|
|
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).
|
|
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).
|
|
This also fixes issues found by running the new tests and
debugging them.
|
|
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.
|
|
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.
|
|
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.
|
|
hlindberg/pup-716_short-lived-objects-in-filesystem
(PUP-716) short lived objects in filesystem
|
|
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.
|
|
One fixed test still failing on expectations
|
|
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.
|
|
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.
|
|
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.
|
|
This also includes a cleanup of LAMBDA (unused/dead logic in grammar)
|
|
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.
|
|
This adds a comprehensive parse/validate/evaluate test for the
future evaluator. Several parsing and evaluation issues were found and
corrected.
|
|
This makes it easier to test the new evaluator as it is being
developed. Add tests using the Transitional impl.
|
|
|
|
|
|
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.
|