forked from HoloTech/customcmd-plugin
19da69b3e8
Working base grammar, visitor, client, context. Good test coverage for grammar constructs.
25 lines
693 B
Python
25 lines
693 B
Python
from typing import TYPE_CHECKING, Any
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
from .terms import ExecutorTerm
|
|
|
|
class ExecContext:
|
|
"""
|
|
Base context class that carries the instantiation state.
|
|
|
|
This is passed to all CommandTerms upon execution.
|
|
"""
|
|
|
|
def __init__(self, *, alias: str, args: list[str], content: str, **kwargs):
|
|
self.alias = alias
|
|
self.args = args
|
|
self.content = content
|
|
|
|
# Dictionary of local variables for the command context.
|
|
# Useful if the Terms need to share state
|
|
self.scope: dict[str, Any] = {}
|
|
|
|
# Stack of terms that are *currently* executing with this context.
|
|
self.termstack: list['ExecutorTerm'] = []
|