Fixed BNF concept evaluations

This commit is contained in:
2020-01-03 19:19:57 +01:00
parent adcbc6bb2e
commit ffd98d7407
20 changed files with 682 additions and 237 deletions
+5 -2
View File
@@ -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