def __init__(self, is_affectation=False): from tl.bnf.value import Value self.is_affectation = is_affectation expr = SubExpr(group=(Group(['(', Expression, ')']) | Value)) expr = AttributeAccessSubExpr(expr) for i, op in enumerate(self.__class__.__operators__): expr = SubExpr( operators=self.__class__.__operators__[i], subexpr=expr ) if is_affectation: from tl.bnf.variable_value import VariableValue ops = list(BinaryInfixOperator(op) for op in self.__affect_operators__) Group.__init__(self, [ # TokenFunctor(self.prepareLeftOperand), # AttributeAccessSubExpr(Variable) # | TokenFunctor(self.cleanupLeftOperand), # TokenFunctor(self.pushLeftOperand), AttributeAccessSubExpr(VariableValue), Alternative(ops), expr ]) else: Group.__init__(self, expr)
def __init__(self, subexpr): self._subexpr = subexpr from tl.bnf.function_call import FunctionParam # from tl.bnf.variable_value import VariableValue from tl.bnf.operators import BinaryInfixOperator from tl.bnf.variable import Variable Group.__init__(self, [ subexpr, Group([ BinaryInfixOperator("."), NamedToken('attribute', Variable), Group([ '(', Group([ FunctionParam, Group([ ',', FunctionParam ], min=0, max=-1) ], min=0, max=1), ')', TokenFunctor(self.pushMethod), ]) | TokenFunctor(self.pushMember) ], min=0, max=-1) ])
def __init__(self): from tl.bnf.declaration import Declaration from tl.bnf.variable import Variable Group.__init__(self, [ "class", NamedToken('class_name', Variable), TokenFunctor(self.pushClassName), Group([ ":", NamedToken('base0', Variable), TokenFunctor(self.pushBase0), Group([ ",", NamedToken('basen', Variable), TokenFunctor(self.pushBaseN), ], min=0, max=-1) ], min=0), "{", TokenFunctor(self.startScope), Group([Declaration], min=0, max=-1), "}", ]) self._class_name = None self._bases = [] self._scope = None
def __init__(self, operators=None, subexpr=None, group=None, min=1, max=1): if operators is not None and subexpr is not None: ops = list(BinaryInfixOperator(op) for op in operators) Group.__init__(self, [ subexpr, Group([Alternative(ops), subexpr], min=0, max=-1) ], min=min, max=max) elif group is not None: Group.__init__(self, group, min, max)
def __init__(self): from tl.bnf.declaration import Declaration Group.__init__(self, [ BlockStatement | ReturnStatement | FunctionCallStatement | MethodCallStatement | Declaration | Affectation ])
def __init__(self): from tl.bnf.declaration import Declaration Group.__init__(self, [ BlockStatement | ReturnStatement | FunctionCallStatement | MethodCallStatement | Declaration | Affectation ])
def __init__(self): Group.__init__(self, [ '<', NamedToken('open', Identifier), '>', NamedToken('content', NamedToken('data', Identifier(r'[^<]+')) | Group(Balise, min=0, max=-1)), '</', NamedToken('close', Identifier), '>', TokenFunctor(self, Balise.hasSameTag), ]) self._open_tag = self.getByName('open') self._node_content = self.getByName('content') self._close_tag = self.getByName('close')
def __init__(self): Group.__init__(self, [ Group([ NamedToken('type', Type), NamedToken('name', Variable), TokenFunctor(self.pushBoth) ])| Group([ NamedToken('auto_name', Variable), TokenFunctor(self.pushName) ]) ])
def __init__(self, group=None, min=1, max=1): Group.__init__( self, [ NamedToken("function_name", Variable), TokenFunctor(self.pushName), "(", Group([FunctionParam, Group([",", FunctionParam], min=0, max=-1)], min=0, max=1), ")", ], min=min, max=max, )
def __init__(self): Group.__init__(self, [ Group([ NamedToken('type', Type), NamedToken('name', Variable), TokenFunctor(self.pushBoth) ]) | Group([ NamedToken('auto_name', Variable), TokenFunctor(self.pushName) ]), Group(Group( [TokenFunctor(self.hasBoth), Group(['(', Expression, ')'])]) | Group(['=', Expression]), min=0, max=1), EndStatement ])
def __init__(self, keywords, with_expression, min=1, max=1): self._keywords = keywords self._with_expression = with_expression group = [self._keywords] if self._with_expression == True: from tl.bnf.expression import Expression group.extend(["(", Expression, ")"]) from tl.bnf.statement import Statement group.extend([ "{", Group([Statement], min=0, max=-1), "}", TokenFunctor(self.endScope)] ) Group.__init__(self, group, min=min, max=max) self._scope = None self._expr = None
def __init__(self): Group.__init__(self, [ '<', NamedToken('open', Identifier), '>', NamedToken( 'content', NamedToken('data', Identifier(r'[^<]+')) | Group(Balise, min=0, max=-1)), '</', NamedToken('close', Identifier), '>', TokenFunctor(self, Balise.hasSameTag), ]) self._open_tag = self.getByName('open') self._node_content = self.getByName('content') self._close_tag = self.getByName('close')
def __init__(self): Group.__init__(self, [ Group([ NamedToken('type', Type), NamedToken('name', Variable), TokenFunctor(self.pushBoth) ]) | Group([ NamedToken('auto_name', Variable), TokenFunctor(self.pushName) ]), Group( Group([ TokenFunctor(self.hasBoth), Group(['(', Expression, ')']) ]) | Group(['=', Expression]), min=0, max=1 ), EndStatement ])
def __init__(self): from tl.bnf.declaration import Declaration from tl.bnf.variable import Variable Group.__init__(self, [ "class", NamedToken('class_name', Variable), TokenFunctor(self.pushClassName), Group([ ":", NamedToken('base0', Variable), TokenFunctor(self.pushBase0), Group([ ",", NamedToken('basen', Variable), TokenFunctor(self.pushBaseN), ], min=0, max=-1) ], min=0), "{", TokenFunctor(self.startScope), Group([Declaration], min=0, max=-1), "}", ]) self._class_name = None self._bases = [] self._scope = None
def __init__(self): Group.__init__(self, [ NamedToken('type', Type), NamedToken('name', Variable), "(", Group([ [ NamedToken('param', FunctionDeclarationParam), TokenFunctor(self.pushParam), ], Group([ ",", NamedToken('oparam', FunctionDeclarationParam), TokenFunctor(self.pushOtherParam), ], min=0, max=-1) ], min=0), ")", "{", TokenFunctor(self.startScope), Group([Statement], min=0, max=-1), "}", ])
def __init__(self): Group.__init__(self, [Block("while", True)])
def __init__(self): Group.__init__(self, [ Block("while", True) ])
def __init__(self): Group.__init__(self, [ Block("if", True), Block(["else", "if"], True, min=0, max=-1), Block("else", False, min=0, max=1) ])
def __init__(self): Group.__init__(self, [ Block("if", True), Block(["else", "if"], True, min=0, max=-1), Block("else", False, min=0, max=1) ])