Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error when evaluating brace-enclosed body #253

Closed
tsandall opened this issue Feb 9, 2017 · 0 comments
Closed

Parse error when evaluating brace-enclosed body #253

tsandall opened this issue Feb 9, 2017 · 0 comments

Comments

@tsandall
Copy link
Member

tsandall commented Feb 9, 2017

The new syntax allows for brace-enclosed bodies to separate expressions with newlines.

{
   p[x]
   q[x]
}

Is equivalent to p[x], q[x].

Currently, the grammar only allows brace-enclosed bodies for rules. They are not supported on their own:

> {
|   p[x]
|   q[x]
| }
|
error: 1 error occurred: 2:0: no match found, unexpected '{'

Build info:

> data
{
  "repl": {
    "version": {
      "BuildCommit": "fddedd3",
      "BuildHostname": "testing-gce-fc0690d8-894b-425b-b34e-14af86b24eef",
      "BuildTimestamp": "2017-02-09T00:39:35Z",
      "Version": "0.4.2-dev"
    }
  }
}
tsandall added a commit to tsandall/opa that referenced this issue Feb 10, 2017
This commit contains a few syntax/parsing changes:

1) Old head :- body rule syntax is no longer supported. All rules must
be declared as: head { body } now.

2) Semicolon has replaced comma as the conjunction operator. This avoids
the ambiguity between set literals and curly-brace enclosed bodies.

3) ast.ParseBody will concatenate bodies that it receives from the
parser. This way, callers can invoke ast.ParseBody without enclosing
multiple expressions in braces.

4) Trailing commas are allowed in sets, arrays, and objects. To declare
a set of size one a trailing comma must be used, e.g., {foo,} =>
set(foo) where as {foo} => body(expr(foo)).

The following commit will update all of the existing test cases to bring
them into compliance with the new syntax.

Fixes open-policy-agent#253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant