![]() |
Purple
0.1
Standard Language Specification
|
Function headers for parsing and operator precedence values. More...


Go to the source code of this file.
Functions | |
| ASTNode * | parse_binary_expression (void) |
| Convenience wrapper for parse_binary_expression_recursive. More... | |
| void | match_token (TokenType type) |
| Ensure current token is of a given type, and scan the next token if so. More... | |
| int | match_type (Number *out) |
| Matches a valid type in the input stream. More... | |
| TokenType | check_for_type (void) |
| Ensure current token is a type token, and scan the next token if so. More... | |
| void | variable_declaration (void) |
| Parse a variable declaration statement into an AST. More... | |
| ASTNode * | function_declaration (void) |
| Parse a function declaration statement into an AST. More... | |
| ASTNode * | function_call_expression (void) |
| Parse a function call expression into an AST. More... | |
| ASTNode * | parse_statements (void) |
| Parse a set of statements into ASTs and generate them into an AST. More... | |
Variables | |
| static TokenType | operatorPrecedence [] |
| Operator precedence values. Precedence ranges from 0-15, 15 being the first to be computed. More... | |
| static TokenType | rightAssociativeOperators [TOKENTYPE_MAX+1] |
Function headers for parsing and operator precedence values.
This table outlines Purple's operator precedence values. A higher precedence value is computed before a lower precedence value.
| Precedence | Operator | Description | Associativity |
|---|---|---|---|
| 16 | ++ -- () [] . -> (type){list} | Postfix increment/decrement Function call Array subscript Structure and Union member access Structure and union pointer member access Compound literal | Left-to-Right |
| 15 | ** ++ -- - ! ~ (type) * & bytesize | Exponent Prefix increment/decrement Unary negative Logical NOT, bitwise NOT Cast Dereference Address-of Size in bytes | Right-to-Left |
| 14 | * / % | Multiplication, division, modulus | Left-to-Right |
| 13 | + - | Addition, Subtraction | |
| 12 | << >> | Bitwise shifts | |
| 11 | < <= > >= | "Less than", "Less than or equal to" relational operators "Greater than", "Greater than or equal to" relational operators | |
| 10 | == != | "Is equal", "Is not equal" relational operators | |
| 9 | & | Bitwise AND | |
| 8 | ^ | Bitwise XOR | |
| 7 | | | Bitwise OR | |
| 6 | and nand | Logical AND Logical NOT-AND | |
| 5 | xor xnor | Logical XOR Logical NOT-XOR | |
| 4 | or nor | Logical OR Logical NOT-OR | |
| 3 | ? ... : | Ternary condition | Right-to-Left |
| 2 | = += -= *= /= %= <<= >>= &= |= ^= | Assignment Sum, Difference Assignments Product, Quotient, Modulus Assignments Bitshift Assignments Bitwise AND, OR, XOR Assignments | |
| 1 | , | Comma | Left-to-Right |
| TokenType check_for_type | ( | void | ) |
Ensure current token is a type token, and scan the next token if so.
| ASTNode * function_call_expression | ( | void | ) |
Parse a function call expression into an AST.
| ASTNode * function_declaration | ( | void | ) |
Parse a function declaration statement into an AST.
| void match_token | ( | TokenType | type | ) |
Ensure current token is of a given type, and scan the next token if so.
| type | TokenType to ensure |
| int match_type | ( | Number * | out | ) |
Matches a valid type in the input stream.
| out | Pointer to Number struct to fill with parsed data |
| ASTNode * parse_binary_expression | ( | void | ) |
Convenience wrapper for parse_binary_expression_recursive.
| ASTNode * parse_statements | ( | void | ) |
Parse a set of statements into ASTs and generate them into an AST.
| void variable_declaration | ( | void | ) |
Parse a variable declaration statement into an AST.
|
static |
Operator precedence values. Precedence ranges from 0-15, 15 being the first to be computed.
|
static |