nodes: add PseudoNode to store fake nodes used to improve diagnostics
This commit is contained in:
parent
4929efa7b0
commit
4ef1e63ee4
1 changed files with 17 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ from typing import Any, Iterable
|
|||
|
||||
from beartype import beartype
|
||||
|
||||
from . import ir, semantic
|
||||
from . import ir, semantic, tokenizer
|
||||
from .errors import SemanticAnalysisError, OverrideMandatoryError
|
||||
from .logger import Logger
|
||||
from .source import SourceLocation
|
||||
|
|
@ -111,6 +111,22 @@ class Literal(Node, ABC):
|
|||
return result
|
||||
|
||||
|
||||
class PseudoNode(Literal):
|
||||
"""
|
||||
Only used for better diagnostics
|
||||
"""
|
||||
|
||||
def __init__(self, token: tokenizer.Token):
|
||||
super().__init__(token.loc, token.value)
|
||||
self.token = token
|
||||
|
||||
def intermediate_representation(self) -> list[ir.IRItem]:
|
||||
return []
|
||||
|
||||
def semantic_analysis(self, context: semantic.Context):
|
||||
pass
|
||||
|
||||
|
||||
class Sum(Node):
|
||||
def intermediate_representation(self) -> list[ir.IRItem]:
|
||||
result: list[ir.IRAction] = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue