Commit b2014af1 authored by supriti's avatar supriti

Minor modifications to cGrammar.py to preserve. Major changes coming next

parent 5368aadc
...@@ -202,14 +202,23 @@ def parseStatement(line): ...@@ -202,14 +202,23 @@ def parseStatement(line):
logging.debug(" Writing to variable %s" % var_name) logging.debug(" Writing to variable %s" % var_name)
annotation = (var_name, "simDCache((%s_addr), \"w\");" % (var_name)) annotation = (var_name, "simDCache((%s_addr), \"w\");" % (var_name))
print r.value
# Parse the Value Expression
try:
r_value = expression.parseString(r.value[0])
except ParseException, e:
logging.error(e.msg, e.line)
logging.error(" Parsing Destination (LHS): %s" % e.msg)
print r_value.add.add_op.deref.deref_exp
logging.debug(" Annotation = %s" % annotation[1]) logging.debug(" Annotation = %s" % annotation[1])
return annotation return annotation
if __name__ == "__main__": def test():
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
lines = [ lines = [ "pcmdata[start - start_40] = *(short int*)((uintptr_t)ivtmp_28);"
"pcmdata[start - start_40] = *(short int*)((uintptr_t)ivtmp_28);"
, "a = b + c;" , "a = b + c;"
, "diff = (int) *(short int *)((uintptr_t)indata + (uintptr_t)ivtmp_28) - valpred;" , "diff = (int) *(short int *)((uintptr_t)indata + (uintptr_t)ivtmp_28) - valpred;"
, "D_2252 = (unsigned int) j_76 + D_2263;" , "D_2252 = (unsigned int) j_76 + D_2263;"
...@@ -217,12 +226,11 @@ if __name__ == "__main__": ...@@ -217,12 +226,11 @@ if __name__ == "__main__":
, "*(outp + i) = (signed char) (signed char) outputbuffer;" , "*(outp + i) = (signed char) (signed char) outputbuffer;"
] ]
annotations = [ annotations = [ "simDCache((pcmdata_addr + (start-start_40)), \"w\");"
"simDCache((pcmdata_addr + (start-start_40)), \"w\");"
, "simDCache((a_addr), \"w\");" , "simDCache((a_addr), \"w\");"
, "simDCache((diff_addr), \"w\");" , "simDCache((diff_addr), \"w\");"
, "simDCache((D_2252_addr), \"w\");" , "simDCache((D_2252_addr), \"w\");"
, "simDCache((outp_addr, \"w\");" , "simDCache((outp_addr), \"w\");"
, "simDCache((outp_addr + (+i)), \"w\");" , "simDCache((outp_addr + (+i)), \"w\");"
] ]
...@@ -231,8 +239,14 @@ if __name__ == "__main__": ...@@ -231,8 +239,14 @@ if __name__ == "__main__":
annotation = parseStatement(lines[i]) annotation = parseStatement(lines[i])
if annotation[1] != annotations[i]: if annotation[1] != annotations[i]:
logging.error(" Line %d does not give expected results!" % i) logging.error(" Line %d does not give expected results!" % i)
exit quit
print "\n\n All Tests Passed!" print "\n\n All Tests Passed!"
if __name__ == "__main__":
\ No newline at end of file logging.basicConfig(level=logging.DEBUG)
line = "pcmdata[start - start_40] = *(short int*)((uintptr_t)ivtmp_28);"
parseStatement(line)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment