예제 #1
0
def switchgroup(vals,suite):
    vals = [ jast_make(jast.Primary,Literal=make_literal(str(v))) for v in vals ]
    groups = []
    for prim in vals[:-1]:
        lbl = jast_make(jast.SwitchLabel,Expression=prim)
        stmts = jast_make(jast.BlockStatements)
        groups.append(jast_make(jast.SwitchBlockStatementGroup,lbl,stmts))
    groups.append(jast_make(jast.SwitchBlockStatementGroup,
                            jast_make(jast.SwitchLabel,Expression=vals[-1])
                            ,suite))
    return JavaTemplate(jast_make(jast.SwitchBlockStatementGroups,groups))
예제 #2
0
def switchgroup(vals,suite):
    vals = [ jast_make(jast.Primary,Literal=make_literal(str(v))) for v in vals ]
    groups = []
    for prim in vals[:-1]:
        lbl = jast_make(jast.SwitchLabel,Expression=prim)
        stmts = jast_make(jast.BlockStatements)
        groups.append(jast_make(jast.SwitchBlockStatementGroup,lbl,stmts))
    groups.append(jast_make(jast.SwitchBlockStatementGroup,
                            jast_make(jast.SwitchLabel,Expression=vals[-1])
                            ,suite))
    return JavaTemplate(jast_make(jast.SwitchBlockStatementGroups,groups))
예제 #3
0
class JavaTemplate:

    def __init__(self,frag,parms='',bindings=None,start='Fragment'):
        if isinstance(frag,java_parser.Node):
            fragment = frag
        else:
            #print "parsing... <<"
            #print frag
            try:
                fragment = java_parser.parse(frag,start=start)
            except java_parser.JavaSyntaxError,e:
                print frag
                raise
            #print ">>"            
        if (not isinstance(fragment,jast.Fragment) and
            not isinstance(fragment,jast.PlaceholderFragment)):
            child_name = fragment.__class__.__name__
            if child_name == 'FormalParameterList': # !!!
                child_name = 'FormalParameterListOpt'
            try:
                fragment = jast_make(jast.Fragment,**{child_name: fragment})
            except UnknownScheme:
                fragment = jast.Fragment((child_name,),[fragment])

        self.fragment = fragment
            
        if not parms:
            self.parms = []
        else:
            if isinstance(parms,str):
	        self.parms = parms.split(':')
            else:
                self.parms = parms
        
        if bindings is None:
            self.bindings = {}
        else:
            self.bindings = bindings
예제 #4
0
    def __init__(self,frag,parms='',bindings=None,start='Fragment'):
        if isinstance(frag,java_parser.Node):
            fragment = frag
        else:
            #print("parsing... <<")
            #print(frag)
            try:
                fragment = java_parser.parse(frag,start=start)
            except java_parser.JavaSyntaxError as e:
                print(frag)
                raise e
            #print(">>")
        if (not isinstance(fragment,jast.Fragment) and
            not isinstance(fragment,jast.PlaceholderFragment)):
            child_name = fragment.__class__.__name__
            if child_name == 'FormalParameterList': # !!!
                child_name = 'FormalParameterListOpt'
            try:
                fragment = jast_make(jast.Fragment,**{child_name: fragment})
            except UnknownScheme:
                fragment = jast.Fragment((child_name,),[fragment])

        self.fragment = fragment
            
        if not parms:
            self.parms = []
        else:
            if isinstance(parms,str):
                self.parms = parms.split(':')
            else:
                self.parms = parms
        
        if bindings is None:
            self.bindings = {}
        else:
            self.bindings = bindings
예제 #5
0
def recast_Placeholder_Selectors__BlockStatements(frag,paren):
    if not frag.Selectors: # !!!
        return jast_make(jast.BlockStatements,
                         jast_make(jast.BlockStatementPlaceholder,frag.Placeholder))
예제 #6
0
def recast_QualifiedIdentifier__ExpressionInSeq(frag,paren):
    if len(frag.QualifiedIdentifier) == 1:
        return jast_make(jast.Primary,Identifier=frag.QualifiedIdentifier[0],ArgumentsOpt=None)
예제 #7
0
def recast_QualifiedIdentifier__ExpressionInSeq(frag, paren):
    if len(frag.QualifiedIdentifier) == 1:
        return jast_make(jast.Primary,
                         Identifier=frag.QualifiedIdentifier[0],
                         ArgumentsOpt=None)
예제 #8
0
def recast_Placeholder_Selectors__ExpressionInSeq(frag,paren):
    if not frag.Selectors: # !!!
        return jast_make(jast.ExpressionInSeqPlaceholder,frag.Placeholder)
예제 #9
0
def recast_Placeholder_Selectors__FormalParameterInSeq(frag,paren):
    if not frag.Selectors: # !!!
        return jast_make(jast.FormalParameterInSeqPlaceholder,frag.Placeholder)
예제 #10
0
def recast_Placeholder_Selectors__ExpressionInSeq(frag, paren):
    if not frag.Selectors:  # !!!
        return jast_make(jast.ExpressionInSeqPlaceholder, frag.Placeholder)
예제 #11
0
def recast_Expression__Primary(frag,paren):
    return jast_make(jast.Primary,Expression=frag.Expression)
예제 #12
0
def recast_Expression__Primary(frag, paren):
    return jast_make(jast.Primary, Expression=frag.Expression)
예제 #13
0
def recast___ExpressionInSeq(frag, paren):
    return jast_make(jast.Expressions)
예제 #14
0
def recast___BlockStatements(frag, paren):
    return jast_make(jast.BlockStatements)
예제 #15
0
def recast_Placeholder_Selectors__Identifier(frag, paren):
    if not frag.Selectors:  # !!!
        return jast_make(jast.IdentifierPlaceholder, frag.Placeholder)
예제 #16
0
def recast_Placeholder_Selectors__BlockStatements(frag, paren):
    if not frag.Selectors:  # !!!
        return jast_make(
            jast.BlockStatements,
            jast_make(jast.BlockStatementPlaceholder, frag.Placeholder))
예제 #17
0
def recast_Placeholder_Selectors__Identifier(frag,paren):
    if not frag.Selectors: # !!!
        return jast_make(jast.IdentifierPlaceholder,frag.Placeholder)
예제 #18
0
def recast___ClassBodyDeclarations(frag, paren):
    return jast_make(jast.ClassBodyDeclarations)
예제 #19
0
def recast___BlockStatements(frag,paren):
    return jast_make(jast.BlockStatements)
예제 #20
0
def recast_Placeholder_Selectors__FormalParameterInSeq(frag, paren):
    if not frag.Selectors:  # !!!
        return jast_make(jast.FormalParameterInSeqPlaceholder,
                         frag.Placeholder)
예제 #21
0
def recast___ExpressionInSeq(frag,paren):
    return jast_make(jast.Expressions)
예제 #22
0
def recast___SwitchBlockStatementGroupInSeq(frag, paren):
    return jast_make(jast.SwitchBlockStatementGroups)
예제 #23
0
def recast___ClassBodyDeclarations(frag,paren):
    return jast_make(jast.ClassBodyDeclarations)
예제 #24
0
def recast_Literal__Primary(frag, paren):
    return jast_make(jast.Primary, Literal=frag)
예제 #25
0
def recast___SwitchBlockStatementGroupInSeq(frag,paren):
    return jast_make(jast.SwitchBlockStatementGroups)
예제 #26
0
def recast_QualifiedIdentifier__TypeOrVOID(frag,paren):
    return jast_make(jast.Type,
                     QualifiedIdentifier = frag,
                     BracketsOpt = jast_make(jast.Brackets))
예제 #27
0
def recast_Literal__Primary(frag,paren):
    return jast_make(jast.Primary,Literal=frag)
예제 #28
0
def recast_QualifiedIdentifier__TypeOrVOID(frag, paren):
    return jast_make(jast.Type,
                     QualifiedIdentifier=frag,
                     BracketsOpt=jast_make(jast.Brackets))