Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/openqasm_pygments/qasm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _defcalgrammar_callback(self, match):
tokens = {
"root": [
(r"^[ \t]*#?pragma", token.Comment.Preproc, "pragma"),
(r"^[ \t]*@\w+", token.Name.Decorator, "annotation"),
(r"^[ \t]*@\w+(\.\w+)*", token.Name.Decorator, "annotation"),
(r"[ \r\n\t]+", token.Whitespace),
(r"\bOPENQASM\b", token.Comment.Preproc, "version"),
(r"//.*$", token.Comment.Single),
Expand Down
17 changes: 17 additions & 0 deletions tests/test_qasm3_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ def test_for_loop_variable_not_callable(lexer_qasm3):
]


def test_annotation_namespace(lexer_qasm3):
text = """\
@annotation
@namespace.annotation
@namespace1.namespace2.annotation
qubit q;
"""
assert _remove_whitespace(lexer_qasm3.get_tokens(text)) == [
(token.Name.Decorator, "@annotation"),
(token.Name.Decorator, "@namespace.annotation"),
(token.Name.Decorator, "@namespace1.namespace2.annotation"),
(token.Keyword.Type, "qubit"),
(token.Name, "q"),
(token.Punctuation, ";")
]


class TestPulseLexerDelegation:
def test_inferred_known_alias(self, lexer_qasm3):
# This uses a very (!) non-standard pulse-grammar lexer to test delegation
Expand Down
Loading