"""Grammar statement."""
import re
from ...datatypes import Varname
from ...processor import PAction
from ...processor.context import Context
from .statement import Statement
[docs]
class Grammar(Statement):
"""Class for `grammar` statement."""
match_re = re.compile(r"(grammar) +([^)]*)\)?\:$")
value_delim_re = re.compile(r"\(")
value_types = (Varname, Varname)
[docs]
def execute(self, context: Context) -> PAction:
"""Execute this token.
:param context: Current context object.
:raises SyntaxError: Can not be executed.
"""
raise SyntaxError(f"Grammar not defined at top level in line {self.lineno}")