Literal,
NamedTuple,
NoReturn,
+ Protocol,
TypeGuard,
overload,
)
ClassDict = dict[str, "Class"]
DestinationDict = dict[str, Destination]
ModuleDict = dict[str, "Module"]
-ParserDict = dict[str, "DSLParser"]
+
+
+class Parser(Protocol):
+ def __init__(self, clinic: Clinic) -> None: ...
+ def parse(self, block: Block) -> None: ...
+
clinic = None
class Clinic:
) -> None:
# maps strings to Parser objects.
# (instantiated from the "parsers" global.)
- self.parsers: ParserDict = {}
+ self.parsers: dict[str, Parser] = {}
self.language: CLanguage = language
if printer:
fail("Custom printers are broken right now")
d = self.get_destination(name)
return d.buffers[item]
- def parse(self, input):
+ def parse(self, input: str) -> str:
printer = self.printer
self.block_parser = BlockParser(input, self.language, verify=self.verify)
for block in self.block_parser:
# "clinic", handles the Clinic DSL
# "python", handles running Python code
#
-parsers = {'clinic' : DSLParser, 'python': PythonParser}
+parsers: dict[str, Callable[[Clinic], Parser]] = {
+ 'clinic': DSLParser,
+ 'python': PythonParser,
+}
clinic = None