Fixed #49 : working
This commit is contained in:
@@ -4,7 +4,7 @@ from typing import List, Tuple, Union
|
||||
from core.builtin_concepts_ids import BuiltinConcepts
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from core.tokenizer import Token, TokenKind, Tokenizer, LexerError
|
||||
from core.utils import tokens_are_matching
|
||||
from core.utils import tokens_are_matching, get_text_from_tokens
|
||||
from parsers.BaseNodeParser import UnrecognizedTokensNode
|
||||
from parsers.BaseParser import Node, ParsingError, BaseParser, ErrorSink, UnexpectedTokenParsingError
|
||||
|
||||
@@ -33,7 +33,7 @@ class ParenthesisMismatchError(ParsingError):
|
||||
token: Token
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(init=False)
|
||||
class ExprNode(Node):
|
||||
"""
|
||||
Base ExprNode
|
||||
@@ -43,6 +43,12 @@ class ExprNode(Node):
|
||||
end: int # index of the last token
|
||||
tokens: List[Token]
|
||||
|
||||
def __init__(self, start: int, end: int, tokens: List[Token]):
|
||||
self.start = start
|
||||
self.end = end
|
||||
self.tokens = tokens
|
||||
self.source = None
|
||||
|
||||
def eval(self, obj):
|
||||
return True
|
||||
|
||||
@@ -61,6 +67,12 @@ class ExprNode(Node):
|
||||
def __hash__(self):
|
||||
return hash((self.start, self.end))
|
||||
|
||||
def get_source(self):
|
||||
if self.source is None:
|
||||
self.source = get_text_from_tokens(self.tokens)
|
||||
|
||||
return self.source
|
||||
|
||||
|
||||
class NameExprNode(ExprNode):
|
||||
def __init__(self, start, end, tokens):
|
||||
|
||||
Reference in New Issue
Block a user