Intermediate JSON code: Link:
Intermediate format{
"types": {
"int": [ "basic",2] ,
"void": [ "basic",0] ,
"char": [ "basic",1] ,
"float": [ "basic",4] ,
"bool": [ "basic",1] ,
"array-of-chars": [ "array",0,"char"] ,
"-none-": [ "basic",2] ,
"_tt": [ "pt",2,"char"] ,
"_tt1": [ "pt",2,"char"] ,
"_tt2": [ "pt",2,"char"] ,
"_tt3": [ "pt",2,"int"] ,
"_tt": [ "pt",2,"int"] ,
"_tt": [ "pt",2,"char"] ,
"_tt4": [ "array",480,"int"] ,
"_tt5": [ "array",0,"char"] } ,
"globals": { "flags": "_tt4","hello": "_tt5",
"_G1": "array-of-chars"} ,
"functions": [{"function": "putchar","par": { "c": "int"} ,
"return": "void","mod": [ ],"body":
[ { "var": { "count": "int","timer": "int"} } ,
[ "",[ "char","*",61440] ,"=","c"] ,
[ "","c","=",[ "int","c","<<",2] ] ,
[ "","c","=",[ "int","c","|",63491] ] ,
{ "for": [ [ "","count","=",0] ,[ "bool","count","<",16] ,[ "int",
"count","=",[ "int","count","+",1] ] ] ,
"do_": [ { "asm": " movp 0x0020,A2"} ,
{ "asm": " mov D0,(A2+24)"} ,
{ "if": [ "bool","c","&",32768] ,
"then": [ { "asm": " mov D0,(A2+26)"} ] } ,
[ "","c","=",[ "int","c","<<",1] ] ,
{ "for": [ [ "","timer","=",0] ,[ "bool","timer","<",750] ,[ "int",
"timer","=",[ "int","timer","+",1] ] ] ,
"do_": [ ] } ,
{ "asm": " movp 0x0020,A2"} ,
{ "asm": " mov D0,(A2+18)"} ,
{ "for": [ [ "","timer","=",0] ,[ "bool","timer","<",750] ,[ "int",
"timer","=",[ "int","timer","+",1] ] ] ,
"do_": [ ] } ,
{ "asm": " movp 0x0020,A2"} ,
{ "asm": " mov D0,(A2+16)"} ] } ,
{ "asm": " movp 1,A2"} ]
}
,
{"function": "putdigit","par": { "n": "int","div": "int"} ,
"return": "int","mod": [ ],"body":
[ { "var": { "ch": "int"} } ,
[ "","ch","=",48] ,
{ "while": [ "bool","n",">=","div"] ,
"do_": [ [ "int","ch","=",[ "int","ch","+",1] ] ,
[ "int","n","=",[ "int","n","-","div"] ] ] } ,
[ "void","putchar",[ "ch"] ] ,
{ "return": "n"} ]
}
,
{"function": "puthexdigit","par": { "n": "int","level": "int"} ,
"return": "void","mod": [ ],"body":
[ { "var": { "c": "char"} } ,
[ "","c","=",[ "char",[ "char","n","&",15] ,"+",48] ] ,
{ "if": [ "bool","level","!=",1] ,
"then": [ [ "void","puthexdigit",[ [ "int","n",">>",4] ,[ "int",
"level","-",1] ] ] ] } ,
{ "if": [ "bool","c",">",57] ,
"then": [ [ "","c","=",[ "char","c","+",7] ] ] } ,
[ "void","putchar",[ "c"] ] ]
}
,
{"function": "putnumber","par": { "n": "int"} ,
"return": "void","mod": [ ],"body":
[ { "var": { } } ,
[ "","n","=",[ "int","putdigit",[ "n",10000] ] ] ,
[ "","n","=",[ "int","putdigit",[ "n",1000] ] ] ,
[ "","n","=",[ "int","putdigit",[ "n",100] ] ] ,
[ "","n","=",[ "int","putdigit",[ "n",10] ] ] ,
[ "","n","=",[ "int","putdigit",[ "n",1] ] ] ]
}
,
{"function": "putstring","par": { "s": "_tt1"} ,
"return": "void","mod": [ ],"body":
[ { "var": { } } ,
{ "while": [ "bool",[ "char","*","s"] ,"!=",0] ,
"do_": [ [ "void","putchar",[ [ "char","*","s"] ] ] ,
[ "_tt1","s","=",[ "_tt1","s","+",1] ] ] } ]
}
,
{"function": "printf","par": { "str": "_tt2","...": "int"} ,
"return": "void","mod": [ ],"body":
[ { "var": { "arp": "_tt3","c": "char","arg": "int"} } ,
[ "","arp","=",[ "_tt","&","str"] ] ,
{ "while": 1,
"do_": [ [ "","c","=",[ "char","*",[ "_tt2","str","++"] ] ] ,
{ "if": [ "bool","c","!=",37] ,
"then": [ { "if": [ "bool","c","==",0] ,
"then": [ { "break": "0"} ] } ,
[ "void","putchar",[ "c"] ] ,
{ "continue": "0"} ] ,
"else": [ [ "_tt3","arp","=",[ "_tt3","arp","+",
1] ] ,
[ "","arg","=",[ "int","*","arp"] ] ,
{ "switch": [ "char","*",[ "_tt2","str","++"] ] ,
"block": [ { "case": 0} ,
[ "_tt2","str","=",[ "_tt2","str","-",1] ] ,
{ "break": "0"} ,
{ "case": 99} ,
[ "void","putchar",[ "arg"] ] ,
{ "break": "0"} ,
{ "case": 105} ,
[ "void","putnumber",[ "arg"] ] ,
{ "break": "0"} ,
{ "case": 115} ,
[ "void","putstring",[ "arg"] ] ,
{ "break": "0"} ,
{ "case": 120} ,
[ "void","puthexdigit",[ "arg",4] ] ,
{ "break": "0"} ,
{ "default": "0"} ,
[ "_tt3","arp","=",[ "_tt3","arp","-",1] ] ,
[ "void","putchar",[ "c"] ] ,
{ "break": "0"} ] } ] } ] } ]
}
,
{"function": "primes","par": { } ,
"return": "void","mod": [ ],"body":
[ { "var": { "i": "int","prime": "int","k": "int","count": "int",
"iter": "int","size": "int"} } ,
[ "","size","=",120] ,
{ "for": [ [ "","iter","=",1] ,[ "bool","iter","<=",10] ,[ "int",
"iter","=",[ "int","iter","+",1] ] ] ,
"do_": [ [ "","count","=",0] ,
{ "for": [ [ "","i","=",0] ,[ "bool","i","<=","size"] ,[ "int",
"i","=",[ "int","i","+",1] ] ] ,
"do_": [ [ "",[ "int","flags",":","i"] ,"=",1] ] } ,
{ "for": [ [ "","i","=",0] ,[ "bool","i","<=","size"] ,[ "int",
"i","=",[ "int","i","+",1] ] ] ,
"do_": [ { "if": [ "int","flags",":","i"] ,
"then": [ [ "","prime","=",[ "int",[ "int","i","+",
"i"] ,"+",3] ] ,
[ "void","putnumber",[ "prime"] ] ,
[ "void","putchar",[ 32] ] ,
[ "","k","=",[ "int","i","+","prime"] ] ,
{ "while": [ "bool","k","<=","size"] ,
"do_": [ [ "",[ "int","flags",":","k"] ,"=",0] ,
[ "int","k","=",[ "int","k","+","prime"] ] ] } ,
[ "","count","=",[ "int","count","+",1] ] ] } ] } ] } ]
}
,
{"function": "main","par": { } ,
"return": "int","mod": [ ],"body":
[ { "var": { } } ,
[ "void","putstring",[ "hello"] ] ,
[ "void","putchar",[ 10] ] ,
[ "void","printf",[ "_G1","hello",43,4853] ] ]
}
] ,
"initlist": { "hello": "Hello World ! ",
"_G1": "Test printf %s, char %c, hex %x "}
}
End of JSON code.Types, globals and functions in the old internal format:Link:
(old)AST manuallist of types in the old way: