Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
pattern = self._compiled.pattern.replace('`', '` + "`" + `')
if self._compiled.flags & re.IGNORECASE:
pattern = '(?i)' + pattern
return 'goleri.NewRegex({}, regexp.MustCompile(`{}`))'.format(
gid,
pattern)
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
new_indent = indent + 1
value = ',\n'.join(['{indent}{elem}'.format(
indent=go_indent * new_indent,
elem=elem._export_go(
go_indent,
new_indent,
enums)) for elem in self._elements])
return 'goleri.NewChoice(\n{gid},\n{mg},\n{val},\n{indent})'.format(
gid='{indent}{gid}'.format(
indent=go_indent * (indent + 1),
gid=gid),
mg='{indent}{mg}'.format(
indent=go_indent * (indent + 1),
mg=('false', 'true')[
self._get_node_result == self._most_greedy_result]),
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewToken({}, "{}")'.format(
gid,
self._token)
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewList({}, {}, {}, {}, {}, {})'.format(
gid,
self._element._export_go(go_indent, indent, enums),
self._delimiter._export_go(go_indent, indent, enums),
self._min,
self._max or '0',
'true' if self._opt else 'false')
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewTokens({}, "{}")'.format(
gid,
' '.join(self._tokens))
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewRepeat({}, {}, {}, {})'.format(
gid,
self._element._export_go(go_indent, indent, enums),
self._min,
self._max or '0')
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewOptional({}, {})'.format(
gid,
self._element._export_go(go_indent, indent, enums))
@go_export
def _run_export_go(self, go_indent, indent, enums, gid):
return 'goleri.NewKeyword({}, "{}", {})'.format(
gid,
self._keyword,
'true' if self._ign_case else 'false')