added preprocessor, requirements.txt
This commit is contained in:
parent
97f6b7989e
commit
83350bd6c9
22
analyze.py
22
analyze.py
@ -1,7 +1,8 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import os,sys,io
|
||||||
from pycparser import parse_file, c_ast, CParser
|
from pycparser import parse_file, c_ast, CParser
|
||||||
|
from pcpp import Preprocessor
|
||||||
import graphviz as gv
|
import graphviz as gv
|
||||||
|
|
||||||
from modelbuilder import *
|
from modelbuilder import *
|
||||||
@ -26,15 +27,27 @@ if __name__ == "__main__":
|
|||||||
#read whole file to a string
|
#read whole file to a string
|
||||||
source = f.read()
|
source = f.read()
|
||||||
|
|
||||||
|
p = Preprocessor()
|
||||||
|
p.add_path('/usr/lib/gcc/x86_64-linux-gnu/12/include/')
|
||||||
|
|
||||||
|
p.parse(source)
|
||||||
|
oh = io.StringIO()
|
||||||
|
p.write(oh)
|
||||||
|
prep_source = oh.getvalue()
|
||||||
|
|
||||||
|
#print(prep_source)
|
||||||
|
#exit()
|
||||||
|
|
||||||
parser = CParser()
|
parser = CParser()
|
||||||
ast = parser.parse(comment_remover(source))
|
ast = parser.parse(prep_source)
|
||||||
#ast = parse_file(args.filename, use_cpp=False)
|
#ast = parse_file(args.filename, use_cpp=False)
|
||||||
|
|
||||||
assign_table = []
|
assign_table = []
|
||||||
state_enums = []
|
state_enums = []
|
||||||
func_table = {}
|
func_table = {}
|
||||||
enum_table = {}
|
enum_table = {}
|
||||||
|
state_asmts = []
|
||||||
|
|
||||||
fdv = FuncDefVisitor()
|
fdv = FuncDefVisitor()
|
||||||
fdv.visit(ast)
|
fdv.visit(ast)
|
||||||
func_table = fdv.func_table
|
func_table = fdv.func_table
|
||||||
@ -43,7 +56,8 @@ if __name__ == "__main__":
|
|||||||
etv.visit(ast)
|
etv.visit(ast)
|
||||||
enum_table = etv.enums
|
enum_table = etv.enums
|
||||||
|
|
||||||
state_asmts = []
|
if not(args.func in func_table):
|
||||||
|
raise Exception(f"Function name '{args.func}' not found!")
|
||||||
|
|
||||||
if args.enum in enum_table:
|
if args.enum in enum_table:
|
||||||
ev = EnumVisitor()
|
ev = EnumVisitor()
|
||||||
|
|||||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pycparser
|
||||||
|
graphviz
|
||||||
|
pcpp>=1.30
|
||||||
Loading…
x
Reference in New Issue
Block a user