def pretty(source, start='Statement', output=None): if isinstance(source, java_parser.Node): ast = source else: ast = java_parser.parse(source, start) if output is None: JavaPretty().visit(ast) else: JavaPretty(output).visit(ast)
def pretty(source,start='Statement',output=None): if isinstance(source,java_parser.Node): ast = source else: ast = java_parser.parse(source,start) if output is None: JavaPretty().visit(ast) else: JavaPretty(output).visit(ast)
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
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
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 #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