Fixed first token recognition when creating bnf concepts
This commit is contained in:
@@ -391,10 +391,11 @@ class StrMatch(Match):
|
||||
Matches a literal
|
||||
"""
|
||||
|
||||
def __init__(self, to_match, rule_name="", ignore_case=True):
|
||||
def __init__(self, to_match, rule_name="", ignore_case=True, skip_whitespace=True):
|
||||
super(Match, self).__init__(rule_name=rule_name)
|
||||
self.to_match = to_match
|
||||
self.ignore_case = ignore_case
|
||||
self.skip_white_space = skip_whitespace
|
||||
|
||||
def __repr__(self):
|
||||
return self.add_rule_name_if_needed(f"'{self.to_match}'")
|
||||
@@ -415,7 +416,7 @@ class StrMatch(Match):
|
||||
|
||||
if m:
|
||||
node = TerminalNode(self, parser_helper.pos, parser_helper.pos, token.str_value)
|
||||
parser_helper.next_token()
|
||||
parser_helper.next_token(self.skip_white_space)
|
||||
return node
|
||||
|
||||
return None
|
||||
@@ -469,6 +470,8 @@ class BnfNodeFirstTokenVisitor(ParsingExpressionVisitor):
|
||||
return self.STOP
|
||||
|
||||
def visit_StrMatch(self, pe):
|
||||
if not pe.to_match:
|
||||
return
|
||||
self.add_first_token(pe.to_match)
|
||||
return self.STOP
|
||||
|
||||
@@ -947,6 +950,9 @@ class BnfNodeParser(BaseNodeParser):
|
||||
:return:
|
||||
"""
|
||||
|
||||
if not isinstance(parser_input, ParserInput):
|
||||
return None
|
||||
|
||||
context.log(f"Parsing '{parser_input}' with BnfNode", self.name)
|
||||
sheerka = context.sheerka
|
||||
|
||||
|
||||
Reference in New Issue
Block a user