Skip to content

Commit

Permalink
Fix axiom parser grammar
Browse files Browse the repository at this point in the history
Having SEP as a start of token leads to misleading item start pointer
when issuing diagnostic. Cleanup when separaterors are, and make sure
item starts with non-whitespace.

Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
  • Loading branch information
rovarga committed Aug 12, 2020
1 parent 7d78583 commit e030487
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -25,8 +25,9 @@ itemName: infraName | dataName;
dataName: prefixedName;
infraName: '@' prefixedName;
item: SEP* itemName SEP* itemValue;
itemValue: (argument)? SEP* (SEMICOLON | LEFT_BRACE SEP* (item)* SEP* RIGHT_BRACE SEP*) SEP*;
file: SEP* item SEP* EOF;
item: itemName itemValue;
itemValue: (SEP+ argument)? SEP* (SEMICOLON | LEFT_BRACE SEP* (item SEP*)* RIGHT_BRACE);
prefixedName : (prefix COLON)? localName;
Expand Down
Expand Up @@ -36,7 +36,7 @@ public static ItemContext contextFrom(String sourceName, CharStream stream) {
parser.removeErrorListeners();
AxiomErrorListener errorListener = new AxiomErrorListener(sourceName);
parser.addErrorListener(errorListener);
ItemContext statement = parser.item();
ItemContext statement = parser.file().item();
errorListener.validate();
return statement;
}
Expand Down

0 comments on commit e030487

Please sign in to comment.