Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
Created February 14, 2015 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangentstorm/b9588b6c8ca557bbddee to your computer and use it in GitHub Desktop.
Save tangentstorm/b9588b6c8ca557bbddee to your computer and use it in GitHub Desktop.
{$mode delphi}
unit uAST; // abstract syntax tree for simple interpreter
interface uses classes, sysutils, variants;
type
TSyntax = variant;
TExpr = variant;
TBoolExpr = variant;
TStmt = variant;
TIfStmt = variant;
TWhileStmt = variant;
TWriteStmt = variant;
TAssignStmt = variant;
function NewSyntax() : TSyntax;
function NewExpr() : TExpr;
function NewBoolExpr() : TBoolExpr;
function NewStmt() : TStmt;
function NewIfStmt(condition: TBoolExpr; thenPart: TStmt; elsePart: TStmt) : TIfStmt;
function NewWhileStmt(condition: TBoolExpr; body: TStmt) : TWhileStmt;
function NewWriteStmt() : TWriteStmt;
function NewAssignStmt() : TAssignStmt;
implementation
function NewSyntax() : TSyntax;
begin result := null end;
function NewExpr() : TExpr;
begin result := null end;
function NewBoolExpr() : TBoolExpr;
begin result := null end;
function NewStmt() : TStmt;
begin result := null end;
function NewIfStmt(condition: TBoolExpr; thenPart: TStmt; elsePart: TStmt) : TIfStmt;
begin result := null end;
function NewWhileStmt(condition: TBoolExpr; body: TStmt) : TWhileStmt;
begin result := null end;
function NewWriteStmt() : TWriteStmt;
begin result := null end;
function NewAssignStmt() : TAssignStmt;
begin result := null end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment