Fixed BNF concept evaluations
This commit is contained in:
@@ -78,7 +78,7 @@ class BaseParser:
|
||||
context.log(self.log, f" Recognized '{value}'", self.name)
|
||||
|
||||
@staticmethod
|
||||
def get_text_from_tokens(tokens):
|
||||
def get_text_from_tokens(tokens, custom_switcher=None):
|
||||
if tokens is None:
|
||||
return ""
|
||||
res = ""
|
||||
@@ -88,9 +88,12 @@ class BaseParser:
|
||||
|
||||
switcher = {
|
||||
TokenKind.KEYWORD: lambda t: Keywords(t.value).value,
|
||||
TokenKind.CONCEPT: lambda t: f"__C__{t.value}__C__"
|
||||
TokenKind.CONCEPT: lambda t: "c:" + t.value + ":",
|
||||
}
|
||||
|
||||
if custom_switcher:
|
||||
switcher.update(custom_switcher)
|
||||
|
||||
for token in tokens:
|
||||
value = switcher.get(token.type, lambda t: t.value)(token)
|
||||
res += value
|
||||
|
||||
Reference in New Issue
Block a user