Commit Graph

4 Commits

Author SHA1 Message Date
Philip Conrad 63e1877c48 linters+testdata: Reformat all yaml testcases for linting. (#6511)
This commit adds a config for yamllint, mass-reformats all of
the existing Yaml testcases to pass linting, and adds a Yaml
linting job to the pull-request Github Actions workflow. A few 
careful exceptions and ignores were added to the linter's
config to allow keeping our existing Yaml files with minimal
reformatting.

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
2024-01-10 13:16:01 -05:00
Anders Eknert dfd4be45b3 Remove any data attrubutes not used in the "YAML tests" (#4817)
Fixes #4813

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-06-28 10:18:35 +02:00
Stephan Renatus c4ab4b35c9 ast/parser: parse 'with' on 'some x in xs' expression (#4371)
Fixes #4226.

Also
* adds a YAML test to ensure that this works fine end-to-end.
* ci(pull-request): show input on failure

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2022-02-22 13:43:02 +01:00
Stephan Renatus f8286be64e ast, topdown: add 'in' operator via internal builtins and future imports
There are four variants to this: with or without 'some', and with
only one or two lhs arguments:

 a) x in xs
 b) k, v in xs
 c) some x in xs
 d) some k, v in xs

(a) and (b) are handled in the parser, and end up in the AST as
calls to `internal.member_2` and `internal.member_3`:

 a) internal.member_2(x, xs)
 b) internal.member_4(k, v, xs)

The backing builtin functions iterate over their last arguments,
trying to find a match. If they do, they will return `true`.
In all other cases -- no match, or a type in the last argument that
can't be iterated over (not an array, object or set), it will
return `false`.

As such, they can be used with `not` without any restrictions.

(c) and (d) are rewritten in the compiler, where x', v', and k' are
fresh local vars:

 c) x' = xs[_]
 d) v' = xs[k']

Since `in` is a new keyword, it's enabled gradually: for now, a new
mechanism of future keyword imports is added. There are new option
arguments in the parser methods, and there's a hook in the parser
code updating its set of enabled future keywords whenever it
encounters an import statement like

    import future.keywords.in # enables only "in"
    import future.keywords    # enables all future keywords

Functionally, these are identical right now: there is only one
future keyword, "in".

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-10-14 19:21:52 +02:00