Last active
July 8, 2017 15:52
-
-
Save gigaherz/9fb7469dbb2b35ab90699d634781dd2b to your computer and use it in GitHub Desktop.
A concept for a JSON-encoded Java AST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"PROGRAM": "Name here", | |
"VERSION": "1.0", | |
"Program": { | |
"TYPE": "class", | |
"SUPER": "Application", | |
"ATTRIBUTES": [ "public", "static"], | |
"FORMAT": 1, | |
"MEMBERS": { | |
"main": { | |
"TYPE": "method", | |
"ATTRIBUTES": [ "public", "static"], | |
"ARGUMENTS": { "args": "String[]" }, | |
"RETURNS": "int", | |
"LOCALS": { | |
"ret": "int" | |
}, | |
"BODY": [ | |
{ | |
"TYPE": "assignation", | |
"TARGET": { "TYPE": "var_ref", "SYMBOL": "ret" }, | |
"VALUE": { | |
"TYPE": "static_call", | |
"TARGET": "java.lang.Integer.parseInt", | |
"ARGUMENTS": [ | |
{ | |
"TYPE": "array_subscript", | |
"TARGET": { "TYPE": "var_ref", "SYMBOL": "args"}, | |
"INDEX": { "TYPE": "literal", "VALUE": 0 } | |
} | |
] | |
} | |
}, | |
{ | |
"TYPE": "static_call", | |
"TARGET": "java.lang.System.out.print", | |
"ARGUMENTS": [ | |
{ "TYPE": "literal", "VALUE": "The number is: " } | |
] | |
}, | |
{ | |
"TYPE": "static_call", | |
"TARGET": "java.lang.System.out.println", | |
"ARGUMENTS": [ | |
{ "TYPE": "var_ref", "SYMBOL": "ret" } | |
] | |
}, | |
{ | |
"TYPE": "return", | |
"VALUE": { "TYPE": "var_ref", "SYMBOL": "ret" } | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment