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

Fix attribute parsing #4530

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pyk/src/pyk/kast/outer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,13 @@ def _maybe_att(self) -> Att:
value: str
if self._la.type == TokenType.LPAREN:
self._consume()
if self._la.type is TokenType.ATTR_CONTENT:
value = self._consume()
else:
value = _dequote_string(self._match(TokenType.STRING))
match self._la.type:
case TokenType.ATTR_CONTENT:
value = self._consume()
case TokenType.STRING:
value = _dequote_string(self._consume())
case _:
value = ''
self._match(TokenType.RPAREN)
else:
value = ''
Expand Down
20 changes: 20 additions & 0 deletions pyk/src/tests/unit/kast/test_outer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@
'syntax Foo ::= "foo"',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),)),)),)),
),
(
'syntax Foo ::= "foo" [symbol]',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),), att=Att((('symbol', ''),))),)),)),
),
(
'syntax Foo ::= "foo" [symbol()]',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),), att=Att((('symbol', ''),))),)),)),
),
(
'syntax Foo ::= "foo" [symbol("")]',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),), att=Att((('symbol', ''),))),)),)),
),
(
'syntax Foo ::= "foo" [symbol(foo)]',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),), att=Att((('symbol', 'foo'),))),)),)),
),
(
'syntax Foo ::= "foo" [symbol("foo")]',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((Terminal('foo'),), att=Att((('symbol', 'foo'),))),)),)),
),
(
'syntax Foo ::= Bar',
SyntaxDefn(SortDecl('Foo'), (PriorityBlock((Production((NonTerminal(Sort('Bar')),)),)),)),
Expand Down
Loading