[
(
'yy_group{0:d}'.format(len(group_actions_text) + j),
- 'yy_group_end'
+ (
+ 'yy_group_end_element'
+ if isinstance(i.groups0[j], regex.RegexGroupElement) else
+ 'yy_group_end'
+ )
)
for j in range(len(i.groups0))
] +
[
(
'yy_group{0:d}'.format(len(group_actions_text) + j),
- 'yy_group_end'
+ (
+ 'yy_group_end_element'
+ if isinstance(i.groups1[j], regex.RegexGroupElement) else
+ 'yy_group_end'
+ )
)
for j in range(len(i.groups1))
]
(
groups[j][0]
if isinstance(groups[j], regex.RegexGroupAction) else
+ regex.Text(
+ text = '''_element = yy_group_element(
+ yy_group_stack[-1],
+ yy_group_stack[-2],
+ yy_element_stack.pop(),
+ {0:s}
+)
+yy_element_stack[-1].append(
+ (yy_group_stack[-1], yy_group_stack[-2], _element)
+)
+del yy_group_stack[-2:]
+'''.format(
+ groups[j][0].get_text()
+ )
+ )
+ if isinstance(groups[j], regex.RegexGroupElement) else
regex.Text(
text = '''if yy_groups[{0:d}] is None:
yy_groups[{1:d}] = yy_group_text[yy_group_stack[-1]:yy_group_stack[-2]]
self.repr_serialize(params)
return 'regex.RegexGroupAction({0:s})'.format(', '.join(params))
# GENERATE END
+
+class RegexGroupElement(RegexGroup):
+ class Text(Text):
+ # GENERATE ELEMENT() BEGIN
+ def __init__(
+ self,
+ tag = 'RegexGroupElement_Text',
+ attrib = {},
+ text = '',
+ children = []
+ ):
+ Text.__init__(
+ self,
+ tag,
+ attrib,
+ text,
+ children
+ )
+ def copy(self, factory = None):
+ result = Text.copy(
+ self,
+ Text if factory is None else factory
+ )
+ return result
+ def __repr__(self):
+ params = []
+ self.repr_serialize(params)
+ return 'regex.RegexGroupElement.Text({0:s})'.format(', '.join(params))
+ # GENERATE END
+
+ # GENERATE ELEMENT() BEGIN
+ def __init__(
+ self,
+ tag = 'RegexGroupElement',
+ attrib = {},
+ text = '',
+ children = [],
+ n_groups = -1
+ ):
+ RegexGroup.__init__(
+ self,
+ tag,
+ attrib,
+ text,
+ children,
+ n_groups
+ )
+ def copy(self, factory = None):
+ result = RegexGroup.copy(
+ self,
+ RegexGroupElement if factory is None else factory
+ )
+ return result
+ def __repr__(self):
+ params = []
+ self.repr_serialize(params)
+ return 'regex.RegexGroupElement({0:s})'.format(', '.join(params))
+ # GENERATE END
# GENERATE FACTORY(element.Element) BEGIN
tag_to_class = {
'RegexGroupName': RegexGroupName,
'RegexGroupName_Text': RegexGroupName.Text,
'RegexGroupAction': RegexGroupAction,
- 'RegexGroupAction_Text': RegexGroupAction.Text
+ 'RegexGroupAction_Text': RegexGroupAction.Text,
+ 'RegexGroupElement': RegexGroupElement,
+ 'RegexGroupElement_Text': RegexGroupElement.Text
}
def factory(tag, attrib = {}, *args, **kwargs):
return tag_to_class.get(tag, element.Element)(tag, attrib, *args, **kwargs)
yylval = None
%}
+DIGIT (?E{ast.AST.Num.Mantissa}[0-9]+)\.?|(?E{ast.AST.Num.Mantissa}[0-9]*)\.(?E{ast.AST.Num.Fraction}[0-9]+)
+
%option noecs nometa-ecs noyywrap reject yymore
%%
[ ]
-(?{
- _element = yy_group_element(
- yy_group_stack[-1],
- yy_group_stack[-2],
- yy_element_stack.pop(),
- ast.AST.Num
- )
- yy_element_stack[-1].append(
- (yy_group_stack[-1], yy_group_stack[-2], _element)
- )
- del yy_group_stack[-2:]
-}(?{
- _element = yy_group_element(
- yy_group_stack[-1],
- yy_group_stack[-2],
- yy_element_stack.pop(),
- ast.AST.Num.Mantissa
- )
- yy_element_stack[-1].append(
- (yy_group_stack[-1], yy_group_stack[-2], _element)
- )
- del yy_group_stack[-2:]
-}[0-9]+)(?{
- yy_element_stack.append([])
- del yy_group_stack[-2:]
-}"")\.?|(?{
- _element = yy_group_element(
- yy_group_stack[-1],
- yy_group_stack[-2],
- yy_element_stack.pop(),
- ast.AST.Num.Mantissa
- )
- yy_element_stack[-1].append(
- (yy_group_stack[-1], yy_group_stack[-2], _element)
- )
- del yy_group_stack[-2:]
-}[0-9]*)(?{
- yy_element_stack.append([])
- del yy_group_stack[-2:]
-}"")\.(?{
- _element = yy_group_element(
- yy_group_stack[-1],
- yy_group_stack[-2],
- yy_element_stack.pop(),
- ast.AST.Num.Fraction
- )
- yy_element_stack[-1].append(
- (yy_group_stack[-1], yy_group_stack[-2], _element)
- )
- del yy_group_stack[-2:]
-}[0-9]+)(?{
- yy_element_stack.append([])
- del yy_group_stack[-2:]
-}""))(?{
- yy_element_stack.append([])
- del yy_group_stack[-2:]
-}"") {
+(?E{ast.AST.Num}{DIGIT}) {
global yylval
yylval = float(yytext)
return NUM