-
Notifications
You must be signed in to change notification settings - Fork 0
Analyzer
Hadi Moshayedi edited this page Apr 10, 2015
·
3 revisions
The analyzer processes the parse tree and creates the following:
- list of constants
- list of functions
Constants. A constant is a (type, value) tuple.
Functions. A function is a (namespace, name, argtypes, ret_type, body) tuple.
Function Body. Function body is a list of (condition: function_call, action: function_call) tuples.
Function Call. (function, args). function is a reference to an item in functions.
args. An arg is either of the following:
- A constant
- A function call
- A context variable. Index of an argument in parent function's arguments
- Get the list of constants and a {(namespace, name) -> constant} mapping.
- Get the list of functions except their body, update the {(namespace, name) -> function} mapping.
- Traverse the parse tree and generate function bodies:
- State: current namespace, {name -> function_call/context_var/constant}
- Use the last statement of a function as action.
- For now, condition is always true.