From e92221723c89d4123108f4d65b97bf1ced7868ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20T=C3=B3th?= Date: Thu, 18 Jul 2024 11:33:41 +0000 Subject: [PATCH 1/2] Add test cases --- pyk/src/tests/unit/kast/test_outer_parser.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pyk/src/tests/unit/kast/test_outer_parser.py b/pyk/src/tests/unit/kast/test_outer_parser.py index 882482fb11b..577ef709568 100644 --- a/pyk/src/tests/unit/kast/test_outer_parser.py +++ b/pyk/src/tests/unit/kast/test_outer_parser.py @@ -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')),)),)),)), From cd9eda9dacdda163b79d27cb25e82fc64a3e5934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20T=C3=B3th?= Date: Thu, 18 Jul 2024 11:45:44 +0000 Subject: [PATCH 2/2] Fix `_maybe_att` --- pyk/src/pyk/kast/outer_parser.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyk/src/pyk/kast/outer_parser.py b/pyk/src/pyk/kast/outer_parser.py index 5fd7334db74..86b48fa39bc 100644 --- a/pyk/src/pyk/kast/outer_parser.py +++ b/pyk/src/pyk/kast/outer_parser.py @@ -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 = ''