def visit_re_match(self, node, children): to_match = node.extra_info.group(1) # print("**** visit_re_match, to_match == '{}'".format(to_match)) regex = RegExMatch(to_match, ignore_case=self.metamodel.ignore_case) try: regex.compile() except Exception as e: line, col = self.grammar_parser.pos_to_linecol(node[1].position) raise TextXSyntaxError(text(e), line, col) return regex
def re_match_SA(parser, node, children): to_match = children[0] regex = RegExMatch(to_match, ignore_case=parser.metamodel.ignore_case) try: regex.compile() except Exception as e: line, col = parser.pos_to_linecol(node[1].position) raise TextXSyntaxError("{} at {}".format(text(e), text((line, col))), line, col) return regex
def re_match_SA(parser, node, children): to_match = children[0] regex = RegExMatch(to_match, ignore_case=parser.metamodel.ignore_case) try: regex.compile() except Exception as e: line, col = parser.pos_to_linecol(node[1].position) raise TextXSyntaxError( "{} at {}" .format(text(e), text((line, col))), line, col) return regex
def str_match_SA(parser, node, children): to_match = children[0] # Support for autokwd metamodel param. if parser.metamodel.autokwd: match = parser.keyword_regex.match(to_match) if match and match.span() == (0, len(to_match)): regex_match = RegExMatch(r'{}\b'.format(to_match), ignore_case=parser.metamodel.ignore_case, str_repr=to_match) regex_match.compile() return regex_match return StrMatch(to_match, ignore_case=parser.metamodel.ignore_case)
def visit_re_match(self, node, children): try: to_match = children[0] except: to_match = '' regex = RegExMatch(to_match, ignore_case=self.metamodel.ignore_case) try: regex.compile() except Exception as e: line, col = self.grammar_parser.pos_to_linecol(node[1].position) raise TextXSyntaxError( "{} at {}".format(text(e), text((line, col))), line, col) return regex
def str_match_SA(parser, node, children): to_match = children[0] # Support for autokwd metamodel param. if parser.metamodel.autokwd: match = parser.keyword_regex.match(to_match) if match and match.span() == (0, len(to_match)): regex_match = RegExMatch(r'{}\b'.format(to_match), ignore_case=parser.metamodel.ignore_case, str_repr=to_match) regex_match.compile() return regex_match return StrMatch(to_match, ignore_case=parser.metamodel.ignore_case)
def visit_re_match(self, node, children): try: to_match = children[0] except IndexError: to_match = '' regex = RegExMatch(to_match, ignore_case=self.metamodel.ignore_case) try: regex.compile() except Exception as e: line, col = self.grammar_parser.pos_to_linecol(node[1].position) raise TextXSyntaxError( "{} at {}" .format(text(e), text((line, col))), line, col) return regex
def visit_str_match(self, node, children): try: to_match = children[0][1:-1] except IndexError: to_match = '' # Support for autokwd metamodel param. if self.metamodel.autokwd: match = self.keyword_regex.match(to_match) if match and match.span() == (0, len(to_match)): regex_match = RegExMatch( r'{}\b'.format(to_match), ignore_case=self.metamodel.ignore_case, str_repr=to_match) regex_match.compile() return regex_match return StrMatch(to_match, ignore_case=self.metamodel.ignore_case)
def visit_str_match(self, node, children): try: to_match = children[0][1:-1] except IndexError: to_match = '' # Support for autokwd metamodel param. if self.metamodel.autokwd: match = self.keyword_regex.match(to_match) if match and match.span() == (0, len(to_match)): regex_match = RegExMatch( r'{}\b'.format(to_match), ignore_case=self.metamodel.ignore_case, str_repr=to_match) regex_match.compile() return regex_match return StrMatch(to_match, ignore_case=self.metamodel.ignore_case)