module liquid.ir.ir

Code Map

module liquid.ir.ir;

public import watt.text.sink;


//! Control the flow of the visitor.
enum Status
{
	Stop,
	Continue,
	ContinueParent,
}

//! Base class for all nodes.
class Node
{
public:
	this() { }
	fn accept(v: Visitor, sink: scope (Sink)) Status;
}

//! Top level container node.
class File : Node
{
public:
	nodes: Node[];


public:
	this() { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! A string of text to be printed out directly.
class Text : Node
{
public:
	text: string;


public:
	this(text: string) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! A expression to be evaluated and printed.
class Print : Node
{
public:
	exp: Exp;


public:
	this(exp: Exp) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Base class for all expressions.
class Exp : Node
{
public:
	this() { }
}

//! A single identifier to be looked up in the global scope.
class Ident : Exp
{
public:
	ident: string;


public:
	this(ident: string) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! A string literal.
class StringLiteral : Exp
{
public:
	val: string;


public:
	this(val: string) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! A bool literal.
class BoolLiteral : Exp
{
public:
	val: bool;


public:
	this(val: bool) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! A literal for a number.
class NumberLiteral : Exp
{
public:
	val: f64;
	integer: bool;


public:
	this(val: f64, integer: bool) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

class BinOp : Exp
{
public:
	enum Type
	{
		Equal,
		NotEqual,
		GreaterThan,
		LessThan,
		GreaterThanOrEqual,
		LessThanOrEqual,
		Or,
		And,
		Contains,
	}


public:
	type: Type;
	l: Exp;
	r: Exp;


public:
	this(type: Type, l: Exp, r: Exp) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Lookup symbol into child expression.
class Access : Exp
{
public:
	child: Exp;
	ident: string;


public:
	this(child: Exp, ident: string) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Array lookup.
class Index : Exp
{
public:
	child: Exp;
	index: Exp;


public:
	this(child: Exp, index: Exp) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Filter expression.
class Filter : Exp
{
public:
	child: Exp;
	ident: string;
	args: Exp[];


public:
	this(child: Exp, ident: string, args: Exp[]) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! If control statement.
class If : Node
{
public:
	thenNodes: Node[];
	elseNodes: Node[];
	exp: Exp;
	invert: bool;
	elsif: bool;


public:
	this(invert: bool, exp: Exp, thenNodes: Node[], elseNodes: Node[]) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! For loop control statement.
class For : Node
{
public:
	var: string;
	nodes: Node[];
	exp: Exp;


public:
	this(var: string, exp: Exp, nodes: Node[]) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

class Assign : Node
{
public:
	ident: string;
	exp: Exp;


public:
	this(ident: string, exp: Exp) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

class Include : Node
{
public:
	filename: string;
	assigns: Assign[];


public:
	this(filename: string, assigns: Assign[]) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Not actually output by the parser. Used for things like %endif%, which
//! mark the end of a list of nodes.
class ClosingTagNode : Node
{
public:
	name: string;


public:
	this(name: string) { }
	fn accept(v: Visitor, sink: scope (Sink)) Status { }
}

//! Base visitor class.
class Visitor
{
public:
	alias Status = Status;
	alias Stop = Status.Stop;
	alias Continue = Status.Continue;
	alias ContinueParent = Status.ContinueParent;


public:
	this() { }
	fn enter(File, scope (Sink)) Status;
	fn leave(File, scope (Sink)) Status;
	fn visit(Text, scope (Sink)) Status;
	fn enter(Print, scope (Sink)) Status;
	fn leave(Print, scope (Sink)) Status;
	fn enter(If, scope (Sink)) Status;
	fn leave(If, scope (Sink)) Status;
	fn enter(For, scope (Sink)) Status;
	fn leave(For, scope (Sink)) Status;
	fn enter(Assign, scope (Sink)) Status;
	fn leave(Assign, scope (Sink)) Status;
	fn visit(Include, scope (Sink)) Status;
	fn enter(Access, scope (Sink)) Status;
	fn leave(Access, scope (Sink)) Status;
	fn enter(Filter, scope (Sink)) Status;
	fn leave(Filter, scope (Sink)) Status;
	fn enter(BinOp, scope (Sink)) Status;
	fn leave(BinOp, scope (Sink)) Status;
	fn enter(Index, scope (Sink)) Status;
	fn leave(Index, scope (Sink)) Status;
	fn visit(Ident, scope (Sink)) Status;
	fn visit(StringLiteral, scope (Sink)) Status;
	fn visit(BoolLiteral, scope (Sink)) Status;
	fn visit(NumberLiteral, scope (Sink)) Status;
}

//! Filter out continue parent and turn that into a continue.
fn filterParent(s: Status) Status { }
class Node

Base class for all nodes.

class File : Node

Top level container node.

class Text : Node

A string of text to be printed out directly.

class Print : Node

A expression to be evaluated and printed.

class Exp : Node

Base class for all expressions.

class Ident : Exp

A single identifier to be looked up in the global scope.

class StringLiteral : Exp

A string literal.

class BoolLiteral : Exp

A bool literal.

class NumberLiteral : Exp

A literal for a number.

class Access : Exp

Lookup symbol into child expression.

class Index : Exp

Array lookup.

class Filter : Exp

Filter expression.

class If : Node

If control statement.

class For : Node

For loop control statement.

class ClosingTagNode : Node

Not actually output by the parser. Used for things like %endif%, which mark the end of a list of nodes.

enum Status

Control the flow of the visitor.

class Visitor

Base visitor class.

fn filterParent(s: Status) Status

Filter out continue parent and turn that into a continue.