def main(): from lfort.cindex import Index from pprint import pprint from optparse import OptionParser, OptionGroup global opts parser = OptionParser("usage: %prog [options] {filename} [lfort-args*]") parser.add_option("", "--show-ids", dest="showIDs", help="Don't compute cursor IDs (very slow)", default=False) parser.add_option("", "--max-depth", dest="maxDepth", help="Limit cursor expansion to depth N", metavar="N", type=int, default=None) parser.disable_interspersed_args() (opts, args) = parser.parse_args() if len(args) == 0: parser.error('invalid number arguments') index = Index.create() tu = index.parse(None, args) if not tu: parser.error("unable to load input") pprint(('diags', map(get_diag_info, tu.diagnostics))) pprint(('nodes', get_info(tu.cursor)))
def test_file(): index = Index.create() tu = index.parse('t.c', unsaved_files = [('t.c', "")]) file = File.from_name(tu, "t.c") assert str(file) == "t.c" assert file.name == "t.c" assert repr(file) == "<File: t.c>"
def test_file(): index = Index.create() tu = index.parse('t.c', unsaved_files=[('t.c', "")]) file = File.from_name(tu, "t.c") assert str(file) == "t.c" assert file.name == "t.c" assert repr(file) == "<File: t.c>"
def main(): import sys from lfort.cindex import Index from optparse import OptionParser, OptionGroup parser = OptionParser("usage: %prog [options] {filename} [lfort-args*]") parser.disable_interspersed_args() (opts, args) = parser.parse_args() if len(args) == 0: parser.error('invalid number arguments') # FIXME: Add an output file option out = sys.stdout index = Index.create() tu = index.parse(None, args) if not tu: parser.error("unable to load input") # A helper function for generating the node name. def name(f): if f: return "\"" + f.name + "\"" # Generate the include graph out.write("digraph G {\n") for i in tu.get_includes(): line = " " if i.is_input_file: # Always write the input file as a node just in case it doesn't # actually include anything. This would generate a 1 node graph. line += name(i.include) else: line += '%s->%s' % (name(i.source), name(i.include)) line += "\n" out.write(line) out.write("}\n")
def main(): import sys from lfort.cindex import Index from optparse import OptionParser, OptionGroup parser = OptionParser("usage: %prog [options] {filename} [lfort-args*]") parser.disable_interspersed_args() (opts, args) = parser.parse_args() if len(args) == 0: parser.error('invalid number arguments') # FIXME: Add an output file option out = sys.stdout index = Index.create() tu = index.parse(None, args) if not tu: parser.error("unable to load input") # A helper function for generating the node name. def name(f): if f: return "\"" + f.name + "\"" # Generate the include graph out.write("digraph G {\n") for i in tu.get_includes(): line = " "; if i.is_input_file: # Always write the input file as a node just in case it doesn't # actually include anything. This would generate a 1 node graph. line += name(i.include) else: line += '%s->%s' % (name(i.source), name(i.include)) line += "\n"; out.write(line) out.write("}\n")
def test_index_parse(): path = os.path.join(kInputsDir, 'hello.cpp') index = Index.create() tu = index.parse(path) assert isinstance(tu, Program)