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. More... | |
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. More... | |
void | discard_next_token (TokenQueue *input) |
Remove next token from the queue. More... | |
bool | check_next_token_type (TokenQueue *input, TokenType type) |
Look ahead at the type of the next token. More... | |
bool | check_next_token (TokenQueue *input, TokenType type, const char *text) |
Look ahead at the type and text of the next token. More... | |
DecafType | parse_type (TokenQueue *input) |
Parse and return a Decaf type. More... | |
void | parse_id (TokenQueue *input, char *buffer) |
Parse and return a Decaf identifier. More... | |
ASTNode * | parse (TokenQueue *input) |
Convert a queue of tokens into an abstract syntax tree (AST) More... | |
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 |