Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def regex(self, ast, *args):
pattern = ast
try:
re.compile(pattern)
except (TypeError, re.error) as e:
raise FailedSemantics('regexp error: ' + str(e))
return pattern
ctx = context or ModelContext(
self.rules,
trace=trace,
keywords=self.keywords,
**kwargs)
semantics = notnone(semantics, self.semantics)
left_recursion = notnone(left_recursion, self.left_recursion)
parseinfo = notnone(parseinfo, self._use_parseinfo)
comments_re = notnone(comments_re, self.comments_re)
eol_comments_re = notnone(eol_comments_re, self.eol_comments_re)
nameguard = notnone(nameguard, self.nameguard)
namechars = notnone(namechars, self.namechars)
whitespace = notnone(whitespace, self.whitespace)
if whitespace:
whitespace = re.compile(whitespace)
return ctx.parse(
text,
rule_name=start,
filename=filename,
semantics=semantics,
trace=trace,
whitespace=whitespace,
comments_re=comments_re,
eol_comments_re=eol_comments_re,
left_recursion=left_recursion,
parseinfo=parseinfo,
nameguard=nameguard,
namechars=namechars,
**kwargs
)
def __init__(
self,
text,
whitespace=re.compile(" "),
nameguard=None,
comments_re=None,
eol_comments_re=None,
ignorecase=None,
namechars="",
**kwargs,
):
super(UnknownBuffer, self).__init__(
text,
whitespace=whitespace,
nameguard=nameguard,
comments_re=comments_re,
eol_comments_re=eol_comments_re,
ignorecase=ignorecase,
namechars=namechars,
**kwargs,
def __init__(
self,
whitespace=re.compile(" "),
nameguard=None,
comments_re=None,
eol_comments_re=None,
ignorecase=None,
left_recursion=True,
parseinfo=True,
keywords=None,
namechars="",
buffer_class=UnknownBuffer,
**kwargs,
):
if keywords is None:
keywords = KEYWORDS
super(UnknownParser, self).__init__(
whitespace=whitespace,
nameguard=nameguard,