Decaf Compiler
|
Compiler phase 2: parser. More...
#include "p2-parser.h"
Functions | |
int | get_next_token_line (TokenQueue *input) |
Look up the source line of the next token in the queue. | |
void | match_and_discard_next_token (TokenQueue *input, TokenType type, const char *text) |
Check next token for a particular type and text and discard it. | |
void | discard_next_token (TokenQueue *input) |
Remove next token from the queue. | |
bool | check_next_token_type (TokenQueue *input, TokenType type) |
Look ahead at the type of the next token. | |
bool | check_next_token (TokenQueue *input, TokenType type, const char *text) |
Look ahead at the type and text of the next token. | |
DecafType | parse_type (TokenQueue *input) |
Parse and return a Decaf type. | |
void | parse_id (TokenQueue *input, char *buffer) |
Parse and return a Decaf identifier. | |
ASTNode * | parse (TokenQueue *input) |
Convert a queue of tokens into an abstract syntax tree (AST) | |
Compiler phase 2: parser.
bool check_next_token | ( | TokenQueue * | input, |
TokenType | type, | ||
const char * | text | ||
) |
Look ahead at the type and text of the next token.
input | Token queue to examine |
type | Expected type of next token |
text | Expected text of next token |
bool check_next_token_type | ( | TokenQueue * | input, |
TokenType | type | ||
) |
Look ahead at the type of the next token.
input | Token queue to examine |
type | Expected type of next token |
void discard_next_token | ( | TokenQueue * | input | ) |
Remove next token from the queue.
Throws an error if there are no more tokens.
input | Token queue to modify |
int get_next_token_line | ( | TokenQueue * | input | ) |
Look up the source line of the next token in the queue.
input | Token queue to examine |
void match_and_discard_next_token | ( | TokenQueue * | input, |
TokenType | type, | ||
const char * | text | ||
) |
Check next token for a particular type and text and discard it.
Throws an error if there are no more tokens or if the next token in the queue does not match the given type or text.
input | Token queue to modify |
type | Expected type of next token |
text | Expected text of next token |
ASTNode * parse | ( | TokenQueue * | input | ) |
Convert a queue of tokens into an abstract syntax tree (AST)
input | Tokens to parse |
void parse_id | ( | TokenQueue * | input, |
char * | buffer | ||
) |
Parse and return a Decaf identifier.
input | Token queue to modify |
buffer | String buffer for parsed identifier (should be at least MAX_TOKEN_LEN characters long) |
DecafType parse_type | ( | TokenQueue * | input | ) |
Parse and return a Decaf type.
input | Token queue to modify |