module liquid.parser.parser

Code Map

module liquid.parser.parser;


enum Status
{
	Ok,
	Error,
}

class Parser
{
public:
	enum State
	{
		Text,
		Print,
		Statement,
		End,
	}


public:
	state: State;
	src: Source;
	sink: StringSink;
	//! A description of an error for the user's consumption.
	errorMessage: string;
	raw: bool;


public:
	this(src: Source) { }
	//! Given a state in which we expect a two char string, skip it.
	fn eatSequence(s: string) Status { }
	//! Parse an identifier name into sink.
	fn eatIdent() { }
	//! If the parser is at the given word, return true. No characters are
	//! consumed.
	fn atWord(s: string) bool { }
	//! Parse a include name into sink.
	fn eatIncludeName() { }
	//! Get the contents of the sink, and then reset it.
	fn getSink() string { }
}

fn parse(src: Source, e: Engine) ir.File { }
//! Parse a liquid file.
fn parseFile(p: Parser, file: ir.File) Status { }
//! Parse nodes until we hit a {%  %}. If name is 'elsif', the If node will
//! be placed at the end of nodes.
fn parseNodesUntilTag(p: Parser, nodes: ir.Node[], nameThatEnded: string, names: string[]) Status { }
//! Parse the individual elements of the file until we run out of file.
fn parseNode(p: Parser, node: ir.Node) Status { }
fn atEndRaw(p: Parser) bool { }
//! Parse regular text until we find a tag, or run out of text.
fn parseText(p: Parser, text: ir.Node) Status { }
//! Parse {{ ... }}.
fn parsePrint(p: Parser, print: ir.Node) Status { }
//! Parse an entire Exp expression.
fn parseExp(p: Parser, exp: ir.Exp, justOneExpression: bool) Status { }
fn parseNumberLiteral(p: Parser, exp: ir.Exp) Status { }
fn parseStringLiteral(p: Parser, exp: ir.Exp) Status { }
//! Parse an Access expression.
fn parseAccess(p: Parser, child: ir.Exp, exp: ir.Exp) Status { }
//! Parse a Filter expression.
fn parseFilter(p: Parser, child: ir.Exp, exp: ir.Exp) Status { }
//! Parse Filter arguments (if any).
fn parseFilterArgs(p: Parser, args: ir.Exp[]) Status { }
//! Parse a statement.
fn parseStatement(p: Parser, node: ir.Node) Status { }
fn parseAssign(p: Parser, node: ir.Node) Status { }
fn parseInclude(p: Parser, node: ir.Node) Status { }
fn parseElsIf(p: Parser, node: ir.Node) Status { }
fn parseIf(p: Parser, invert: bool, node: ir.Node) Status { }
fn parseRaw(p: Parser, node: ir.Node) Status { }
fn parseFor(p: Parser, node: ir.Node) Status { }
fn parseComment(p: Parser) Status { }
//! This function parses a ident.
fn parseIdent(p: Parser, name: string) Status { }
//! This function parser a include name.
fn parseIncludeName(p: Parser, name: string) Status { }
//! Parses close statements '%}', handles hyphens.
fn parseCloseStatement(p: Parser) Status { }
//! Parses close statements '%}', handles hyphens.
fn parseClosePrint(p: Parser) Status { }
//! Matches and skips a single char from the source, sets error msg.
fn matchAndSkip(p: Parser, c: dchar) Status { }
//! Returns either a ir.Ident or ir.BoolLiteral.
fn makeIdentOrBool(word: string) ir.Exp { }
//! Returns true if current character is c and skip it.
fn ifAndSkip(p: Parser, c: dchar) bool { }
//! Is the given char a valid character for a include name.
fn isIncludeName(c: dchar) bool { }
//! Is the given char a valid character for a variable name.
fn isIdentName(c: dchar) bool { }
fn parseFile(p: Parser, file: ir.File) Status

Parse a liquid file.

fn parseNodesUntilTag(p: Parser, nodes: ir.Node[], nameThatEnded: string, names: string[]) Status

Parse nodes until we hit a {% %}. If name is 'elsif', the If node will be placed at the end of nodes.

fn parseNode(p: Parser, node: ir.Node) Status

Parse the individual elements of the file until we run out of file.

fn parseText(p: Parser, text: ir.Node) Status

Parse regular text until we find a tag, or run out of text.

fn parsePrint(p: Parser, print: ir.Node) Status

Parse {{ ... }}.

fn parseExp(p: Parser, exp: ir.Exp, justOneExpression: bool) Status

Parse an entire Exp expression.

fn parseAccess(p: Parser, child: ir.Exp, exp: ir.Exp) Status

Parse an Access expression.

fn parseFilter(p: Parser, child: ir.Exp, exp: ir.Exp) Status

Parse a Filter expression.

fn parseFilterArgs(p: Parser, args: ir.Exp[]) Status

Parse Filter arguments (if any).

fn parseStatement(p: Parser, node: ir.Node) Status

Parse a statement.

fn parseIdent(p: Parser, name: string) Status

This function parses a ident.

Include name must start with a alpha or '' and may contain alpha, '', or -.

fn parseIncludeName(p: Parser, name: string) Status

This function parser a include name.

Include name must start with a ident or number, may contain alpha numerical, '.' and '/'.

fn parseCloseStatement(p: Parser) Status

Parses close statements '%}', handles hyphens.

fn parseClosePrint(p: Parser) Status

Parses close statements '%}', handles hyphens.

fn matchAndSkip(p: Parser, c: dchar) Status

Matches and skips a single char from the source, sets error msg.

fn makeIdentOrBool(word: string) ir.Exp

Returns either a ir.Ident or ir.BoolLiteral.

fn ifAndSkip(p: Parser, c: dchar) bool

Returns true if current character is c and skip it.

fn isIncludeName(c: dchar) bool

Is the given char a valid character for a include name.

fn isIdentName(c: dchar) bool

Is the given char a valid character for a variable name.