@syntaxs/compiler
Version:
Compiler used to compile Syntax Script projects.
238 lines • 11.4 kB
TypeScript
import { BraceExpression, GlobalStatement, ImportsStatement, Node, NodeType, OperatorStatement, ParenExpression, ProgramStatement, SquareExpression, Token, VariableExpression } from './types.js';
import { Range } from 'lsp-types';
export declare namespace syxparser {
/**
* Parses an import statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseImportStatement(put: boolean, token: Token): Node;
/**
* Parses an import statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseRuleStatement(token: Token, put: boolean): Node;
/**
* Parses a keyword statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseKeywordStatement(put: boolean, token: Token): Node;
/**
* Parses an export statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseExportStatement(token: Token, put: boolean): Node;
/**
* Parses a function statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseFunctionStatement(token: Token, put: boolean): Node;
/**
* Parses an imports statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseImportsStatement(token: Token, put: boolean): ImportsStatement;
/**
* Parses a compile statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseCompileStatement(token: Token, put: boolean): Node;
/**
* Parses an operator statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseOperatorStatement(token: Token, put: boolean): OperatorStatement;
/**
* Parses an operator statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseGlobalStatement(token: Token, put: boolean): GlobalStatement;
/**
* Parses a single quote string expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseSingleQuotedString(put: boolean): {
type: NodeType.String;
value: string;
range: Range;
modifiers: any[];
};
/**
* Parses a double quote string expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseDoubleQuotedString(put: boolean): {
type: NodeType.String;
value: string;
range: Range;
modifiers: any[];
};
/**
* Parses a primitive type expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parsePrimitiveType(primitiveTypes: RegExp, put: boolean): Node;
/**
* Parses a whitespace identifier expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseWhitespaceIdentifier(put: boolean): Node;
/**
* Parses a brace expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseBraceExpression(put: boolean, dr: Range): BraceExpression;
/**
* Parses a square expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseSquareExpression(put: boolean, dr: Range): SquareExpression;
/**
* Parses a paren expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseParenExpression(put: boolean, dr: Range): ParenExpression;
/**
* Parses a primitive variable expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parsePrimitiveVariable(put: boolean): VariableExpression;
let tokens: Token[];
let program: ProgramStatement;
let filePath: string;
/**
* Parses the token list given into statements and expressions.
* @param {Token[]} t Token list to parse.
* @param {string} _filePath Path of the file that is being parsed.
* @returns Main {@link ProgramStatement} containing all other statements.
* @author efekos
* @version 1.0.4
* @since 0.0.2-alpha
*/
function parseTokens(t: Token[], _filePath: string): ProgramStatement;
/**
* Returns the token at given index. Alias for `tokens[i]`.
* @param {number} i Token index. Defaults to 0.
* @returns The token at given index.
* @author efekos
* @version 1.0.0
* @since 0.0.1-alpha
*/
function at(i?: number): Token;
/**
* Combines the start of first range with the end of second range to create a range.
* @param starterRange Start range.
* @param enderRange End range.
* @author efekos
* @since 0.0.1-alpha
* @version 1.0.1
*/
function combineTwo(starter: Token | Range, ender: Token | Range): Range;
/**
* Parses a statement from the most recent token. Will call {@link parseExpression} if no statement is present.
* @param {boolean} put Whether the result should be added to the program statement.
* @returns A node that is either a statement or an expression if a statement wasn't present.
* @author efekos
* @version 1.1.0
* @since 0.0.2-alpha
*/
function parseStatement(put?: boolean): Node;
/**
* An alias function to handle different cases of calling {@link parseStatement} and {@link parseExpression}.
* @param {T} node The node.
* @param {boolean} put Whether the node should be added to current program.
* @returns The node.
* @author efekos
* @version 1.0.0
* @since 0.0.1-alpha
*/
function node<T extends Node>(node: T, put: boolean): T;
/**
* Parses the most recent expression at the token list. Goes to {@link parseStatement} if a keyword is found.
* @param {boolean} put Whether the result should be put into current program.
* @param {boolean} statements Whether statements should be allowed. Function will stop if a keyword found with this value set to `true`.
* @param {boolean} expectIdentifier Whether identifiers should be allowed. Unknown identifiers will stop the function with this value set to `false`, returning the identifier as a {@link StringExpression} otherwise.
* @returns The parsed node.
* @author efekos
* @version 1.1.0
* @since 0.0.2-alpha
*/
function parseExpression(put?: boolean, statements?: boolean, expectIdentifier?: boolean): Node;
}
export declare namespace sysparser {
/**
* Parses an import statement. Parameters are related to the environment of {@link syxparser.parseStatement} or {@link sysparser.parseStatement}.
* @returns Parsed node.
*/
function parseImportStatement(put: boolean, token: Token): Node;
/**
* Parses a single quote string expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseSingleQuotedString(put: boolean): Node;
/**
* Parses a double quote string expression. Parameters are related to the environment of {@link syxparser.parseExpression} or {@link sysparser.parseExpression}.
* @returns Parsed node.
*/
function parseDoubleQuotedString(put: boolean): Node;
let tokens: Token[];
let program: ProgramStatement;
let filePath: string;
/**
* Combines the start of first range with the end of second range to create a range.
* @param starterRange Start range.
* @param enderRange End range.
* @author efekos
* @since 0.0.1-alpha
* @version 1.0.1
*/
function combineTwo(starter: Token | Range, ender: Token | Range): Range;
/**
* Parses the token list given into statements and expressions.
* @param {Token[]} t Token list to parse.
* @returns Main {@link ProgramStatement} containing all other statements.
* @author efekos
* @version 1.0.3
* @since 0.0.2-alpha
*/
function parseTokens(t: Token[], _filePath: string): ProgramStatement;
/**
* Returns the token at given index. Alias for `tokens[i]`.
* @param {number} i Token index. Defaults to 0.
* @returns The token at given index.
* @author efekos
* @version 1.0.0
* @since 0.0.1-alpha
*/
function at(i?: number): Token;
/**
* Parses a statement from the most recent token. Will call {@link parseExpression} if no statement is present.
* @param {boolean} put Whether the result should be added to the program statement.
* @returns A node that is either a statement or an expression if a statement wasn't present.
* @author efekos
* @version 1.0.6
* @since 0.0.1-alpha
*/
function parseStatement(put?: boolean): Node;
/**
* An alias function to handle different cases of calling {@link parseStatement} and {@link parseExpression}.
* @param {Node} node The node.
* @param {boolean} put Whether the node should be added to current program.
* @returns The node.
* @author efekos
* @version 1.0.0
* @since 0.0.1-alpha
*/
function node(node: Node, put: boolean): Node;
/**
* Parses the most recent expression at the token list. Goes to {@link parseStatement} if a keyword is found.
* @param {boolean} put Whether the result should be put into current program.
* @param {boolean} statements Whether statements should be allowed. Function will stop if a keyword found with this value set to `true`.
* @param {boolean} expectIdentifier Whether identifiers should be allowed. Unknown identifiers will stop the function with this value set to `false`, returning the identifier as a {@link StringExpression} otherwise.
* @returns The parsed node.
* @author efekos
* @version 1.0.6
* @since 0.0.1-alpha
*/
function parseExpression(put?: boolean, statements?: boolean): Node;
}
//# sourceMappingURL=ast.d.ts.map