nodes: add PseudoNode to store fake nodes used to improve diagnostics

This commit is contained in:
Antoine Viallon 2023-05-12 01:30:02 +02:00
parent 4929efa7b0
commit 4ef1e63ee4
Signed by: aviallon
GPG key ID: D126B13AB555E16F

View file

@ -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] = []