Struct passerine::compiler::parse::Parser [−][src]
pub struct Parser { /* fields omitted */ }
Expand description
Constructs an AST
from a token stream.
Note that this struct should not be controlled manually,
use the parse
function instead.
Implementations
Returns the next non-sep tokens, without advancing the parser.
Returns the current token then advances the parser.
Throws an error if the next token is unexpected. I get one funny error message and this is it. The error message returned by this function will be changed frequently
Consumes a specific token then advances the parser. Can be used to consume Sep tokens, which are normally skipped.
Looks at the current token and parses an infix expression
Looks at the current token and parses the right side of any infix expressions.
Looks at the current operator token and determines the precedence
Uses some pratt parser magic to parse an expression. It’s essentially a fold-left over tokens based on the precedence and content. Cool stuff.
Parses a keyword. Note that this is wrapped in a CSTPattern node.
Constructs the AST for a literal, such as a number or string.
Constructs the ast for a group, i.e. an expression between parenthesis.
Parses the body of a block. A block is one or more expressions, separated by separators. This is more of a helper function, as it serves as both the parser entrypoint while still being recursively nestable.
Parse a block as an expression,
Building the appropriate AST
.
Just a body between curlies.
Parse a macro definition.
syntax
, followed by a pattern, followed by a block
Parse an extern
statement.
used for compiler magic and other glue.
takes the form:
magic "FFI String Name" data_to_pass_out
and evaluates to the value returned by the ffi function.
Parse a label.
A label takes the form of <Label> <expression>
Parses an argument pattern,
Which converts an AST
into an ArgPattern
.
Parses an assignment, associates right.
Parses a lambda definition, associates right.
Parses a pair operator, i.e. the comma used to build tuples: a, b, c
.
Parses a function composition, i.e. a . b
Parses an addition, calls out to FFI.
Parses a subraction, calls out to FFI.
Parses a multiplication, calls out to FFI.
Parses a division, calls out to FFI.
Parses an equality, calls out to FFI.
Parses an remainder, calls out to FFI.
Parses an power, calls out to FFI.
Parses a function call. Function calls are a bit magical, because they’re just a series of expressions. There’s a bit of magic involved - we interpret anything that isn’t an operator as a function call operator. Then pull a fast one and not parse it like an operator at all.