module volta.parser.base

Code Map

module volta.parser.base;

public import volta.ir.token;


enum ParseStatus
{
	Succeeded,
	Failed,
}

alias Succeeded = ParseStatus.Succeeded;
alias Failed = ParseStatus.Failed;
//! Just for convenience.
alias NodeSinkDg = void delegate(ir.Node);

//! Used as a sink for functions that return multiple nodes.
class NodeSink
{
public:
	this() { }
	fn push(n: ir.Node) { }
	fn pushNodes(nodes: ir.Node[]) { }
	fn array() ir.Node[] { }
}

class ParserStream : TokenStream
{
public:
	parserErrors: ParserError[];
	neverIgnoreError: bool;
	lastDocComment: Token;
	//! For backwards doc comments (like this one).
	retroComment: ir.Node;
	multiDepth: i32;
	settings: Settings;
	globalDocComments: string[];
	magicFlagD: bool;
	setExpLocationVisitor: SetExpLocationVisitor;


public:
	this(tokens: Token[], settings: Settings, errSink: ErrorSink) { }
	fn eof() bool { }
	fn eofIndex(i: size_t) bool { }
	//! Get the current token and advances the stream to the next token.
	fn get() Token { }
	fn saveTokens() size_t { }
	fn doneSavingTokens(startIndex: size_t) Token[] { }
	fn resetErrors() { }
	fn pushCommentLevel() { }
	fn popCommentLevel() { }
	//! Add a comment to the current comment level.
	fn addComment(comment: Token) { }
	//! Retrieve and clear the current comment.
	fn comment() string { }
	//! True if we found @ { on its own, so apply the last doccomment multiple
	//! times, until we see a matching number of @ }s.
	fn inMultiCommentBlock() bool { }
}

fn parsePanic(ps: ParserStream, loc: const(Location), nodeType: ir.NodeType, message: string, file: string, line: const(i32)) ParseStatus { }
fn unexpectedToken(ps: ParserStream, ntype: ir.NodeType, file: string, line: const(i32)) ParseStatus { }
fn unexpectedToken(ps: ParserStream, n: ir.Node, file: string, line: const(i32)) ParseStatus { }
fn wrongToken(ps: ParserStream, ntype: ir.NodeType, found: Token, expected: TokenType, file: string, line: const(i32)) ParseStatus { }
fn parseFailed(ps: ParserStream, ntype: ir.NodeType, file: string, line: const(i32)) ParseStatus { }
fn parseFailed(ps: ParserStream, n: ir.Node, file: string, line: const(i32)) ParseStatus { }
fn parseFailed(ps: ParserStream, ntype: ir.NodeType, ntype2: ir.NodeType, file: string, line: const(i32)) ParseStatus { }
fn unsupportedFeature(ps: ParserStream, n: ir.Node, s: string, file: string, l: const(i32)) ParseStatus { }
fn invalidIntegerLiteral(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
fn parseExpected(ps: ParserStream, loc: const(Location), nodeType: ir.NodeType, message: string, file: string, line: const(i32)) ParseStatus { }
fn parseExpected(ps: ParserStream, loc: const(Location), n: ir.Node, message: string, file: string, line: const(i32)) ParseStatus { }
fn allArgumentsMustBeLabelled(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
fn docCommentMultiple(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
fn strayDocComment(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
fn badComposable(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
fn badMultiBind(ps: ParserStream, loc: const(Location), file: string, line: const(i32)) ParseStatus { }
//! Match the current token on the parserstream @ps against @type. Does not
//! advance the parserstream.
fn checkToken(ps: ParserStream, ntype: ir.NodeType, type: TokenType, file: string, line: const(i32)) ParseStatus { }
//! Match the current token on the parserstream @ps against @type. Does not
//! advance the parserstream.
fn checkTokens(ps: ParserStream, ntype: ir.NodeType, types: scope (const(scope (TokenType)[]), file: string, line: const(i32)) ParseStatus { }
//! Match the current Token on the ParserStream @ps against @type.
fn match(ps: ParserStream, ntype: ir.NodeType, type: TokenType, file: string, line: const(i32)) ParseStatus { }
//! Match the current token on the parserstream @ps against @type.
fn match(ps: ParserStream, node: ir.Node, type: TokenType, file: string, line: const(i32)) ParseStatus { }
//! Match the current tokens on the parserstream @ps against @types.
fn match(ps: ParserStream, ntype: ir.NodeType, types: scope (const(scope (TokenType)[]), file: string, line: const(i32)) ParseStatus { }
//! Match the current token on the parserstream @ps against @type.
fn match(ps: ParserStream, n: ir.Node, type: TokenType, tok: Token, file: string, line: const(i32)) ParseStatus { }
//! Match the current token on the parserstream @ps against @type.
fn match(ps: ParserStream, nodeType: ir.NodeType, type: TokenType, tok: Token, file: string, line: const(i32)) ParseStatus { }
//! Matches the current token on the parserstream @ps against @type and if
//! they matches gets it from the stream.
fn matchIf(ps: ParserStream, type: TokenType) bool { }
//! Add all doccomment tokens to the current comment level.
fn eatComments(ps: ParserStream) ParseStatus { }
//! Parse a QualifiedName, leadingDot optinal.
fn parseQualifiedName(ps: ParserStream, name: ir.QualifiedName, allowLeadingDot: bool) ParseStatus { }
//! Parse a single Identifier.
fn parseIdentifier(ps: ParserStream, i: ir.Identifier) ParseStatus { }
//! Returns true if the ParserStream is in a state where there is a colon
//! (along with optional identifiers and commas) before a semicolon.
//! Basically, returns true if we're at a new-style (a : i32) variable
//! declaration.
fn isColonDeclaration(ps: ParserStream) bool { }
alias NodeSinkDg

Just for convenience.

class NodeSink

Used as a sink for functions that return multiple nodes.

fn checkToken(ps: ParserStream, ntype: ir.NodeType, type: TokenType, file: string, line: const(i32)) ParseStatus

Match the current token on the parserstream @ps against @type. Does not advance the parserstream.

Side-effects: If token is not type raises a unexpected token error.

fn checkTokens(ps: ParserStream, ntype: ir.NodeType, types: scope (const(scope (TokenType)[]), file: string, line: const(i32)) ParseStatus

Match the current token on the parserstream @ps against @type. Does not advance the parserstream.

Side-effects: If token is not type raises a unexpected token error.

fn match(ps: ParserStream, ntype: ir.NodeType, type: TokenType, file: string, line: const(i32)) ParseStatus

Match the current Token on the ParserStream @ps against @type.

Side-effects: Advances the ParserStream if the current Token is of @type. If the Token is not @type an unexpected token error is raised.

fn match(ps: ParserStream, node: ir.Node, type: TokenType, file: string, line: const(i32)) ParseStatus

Match the current token on the parserstream @ps against @type.

Side-effects: Advances the tokenstream if current token is of @type. If token is not type raises a unexpected token error.

fn match(ps: ParserStream, ntype: ir.NodeType, types: scope (const(scope (TokenType)[]), file: string, line: const(i32)) ParseStatus

Match the current tokens on the parserstream @ps against @types.

Side-effects: Advances the tokenstream if all the tokens matches @types. If token is not type raises a unexpected token error.

fn match(ps: ParserStream, n: ir.Node, type: TokenType, tok: Token, file: string, line: const(i32)) ParseStatus

Match the current token on the parserstream @ps against @type.

Side-effects: Advances the tokenstream if current token is of @type. If token is not type raises a unexpected token error.

fn matchIf(ps: ParserStream, type: TokenType) bool

Matches the current token on the parserstream @ps against @type and if they matches gets it from the stream.

Side-effects: None

fn eatComments(ps: ParserStream) ParseStatus

Add all doccomment tokens to the current comment level.

fn parseQualifiedName(ps: ParserStream, name: ir.QualifiedName, allowLeadingDot: bool) ParseStatus

Parse a QualifiedName, leadingDot optinal.

fn parseIdentifier(ps: ParserStream, i: ir.Identifier) ParseStatus

Parse a single Identifier.

fn isColonDeclaration(ps: ParserStream) bool

Returns true if the ParserStream is in a state where there is a colon (along with optional identifiers and commas) before a semicolon. Basically, returns true if we're at a new-style (a : i32) variable declaration.