When two identifiers follow eachother it could be two instruction mnemonics or one instruction mnemonic and one operand. To fix this TOKEN_NEWLINE has been reintroduced as a semantic token. The grammar has been changed to allow empty statements and every instruction and directive has to end in a newline. Labels do not have to end in a newline. In addition to updating the grammar, the implementation of tokenlist, ast and parser has been updated to reflect these changes.
32 lines
1.4 KiB
C
32 lines
1.4 KiB
C
#ifndef INCLUDE_PARSER_PRIMITIVES_H_
|
|
#define INCLUDE_PARSER_PRIMITIVES_H_
|
|
|
|
#include "util.h"
|
|
|
|
parse_result_t parse_identifier(tokenlist_entry_t *current);
|
|
parse_result_t parse_decimal(tokenlist_entry_t *current);
|
|
parse_result_t parse_hexadecimal(tokenlist_entry_t *current);
|
|
parse_result_t parse_binary(tokenlist_entry_t *current);
|
|
parse_result_t parse_octal(tokenlist_entry_t *current);
|
|
parse_result_t parse_string(tokenlist_entry_t *current);
|
|
parse_result_t parse_char(tokenlist_entry_t *current);
|
|
parse_result_t parse_colon(tokenlist_entry_t *current);
|
|
parse_result_t parse_comma(tokenlist_entry_t *current);
|
|
parse_result_t parse_lbracket(tokenlist_entry_t *current);
|
|
parse_result_t parse_rbracket(tokenlist_entry_t *current);
|
|
parse_result_t parse_plus(tokenlist_entry_t *current);
|
|
parse_result_t parse_minus(tokenlist_entry_t *current);
|
|
parse_result_t parse_asterisk(tokenlist_entry_t *current);
|
|
parse_result_t parse_dot(tokenlist_entry_t *current);
|
|
parse_result_t parse_newline(tokenlist_entry_t *current);
|
|
parse_result_t parse_label_reference(tokenlist_entry_t *current);
|
|
|
|
/* These are "primitives" with a different name and some extra validation on top
|
|
* for example, register is just an identifier but it only matches a limited set
|
|
* of values
|
|
*/
|
|
parse_result_t parse_register(tokenlist_entry_t *current);
|
|
parse_result_t parse_section(tokenlist_entry_t *current);
|
|
|
|
#endif // INCLUDE_PARSER_PRIMITIVES_H_
|