Skip to content

Latest commit

 

History

History
117 lines (104 loc) · 1.6 KB

AST-json-structure.md

File metadata and controls

117 lines (104 loc) · 1.6 KB

Module

{
    "type": "Module",
    "statements": [] // These need to be functions or declaration statements (for globals)
}

CodeBlock

{
    "type": "CodeBlock",
    "statements": [] // These can be any node specified below
}

Function

{
    "type": "Function",
    "parameters": ["DataType", "DataType", ...],
    "ret-type": "DataType",
    "code-block": {"type": "CodeBlock", ...}
}

IfBlock

{
    "type": "IfBlock",
    "statements": [
        {
            "condition": "...",
            "code-block": {"type": "CodeBlock", ...},
        }
    ],
    "default": {"type": "CodeBlock", ...} 
}

Loop

{
    "type": "Loop",
    "condition": "...",
    "code-block": {"type": "CodeBlock", ...} 
}

DeclarationStatement

{
    "type": "DeclarationStatement",
    "dst": "some variable",
    "src": "...",
    "dtype": "DataType"
}

AssignmentStatement

{
    "type": "AssignmentStatement",
    "dst": "some variable",
    "src": "..."
}

ReturnStatement

{
    "type": "ReturnStatement",
    "value": "...",
    "dtype": "DataType"
}

Literal

{
    "type": "Literal",
    "value": "...",
    "dtype": "DataType"
}

Variable

{
    "type": "Variable",
    "name": "...",
    "dtype": "DataType"
}

Expression

{
    "type": "Expression",
    "left-operand": "...",
    "operator": "...",
    "right-operand": "...",
    "dtype": "DataType"
}

FunctionCall

{
    "type": "FunctionCall",
    "function-name": "...",
    "parameters": ["..."],
    "dtype": "DataType"
}