25 "Expected an identifier here. Example: inst mov[16](arg1: register[32], arg2: immediate[8]) { ... }"
32 unsigned int ntokens =
44 "Expected a list of arguments for the instruction inside parentheses. Example: inst mov[16](arg1: register[32], "
45 "arg2: immediate[8]) { ... }"
51 ntokens += _parse_inst_args(
module, node_statement, tkopen_parens);
60 "Expected an open braces at start of the body of the instruction. Example: inst mov[16](arg1: register[32], "
61 "arg2: immediate[8]) { ... }"
76 unsigned int ntokens = 1;
80 current = &
token[ntokens];
82 switch (current->
type) {
84 ntokens += _parse_arg_spec(
module, node_statement, current);
90 token[ntokens].column,
91 token[ntokens].lexeme.length,
92 "Expected a comma after the argument specification. Example: inst mov[16](arg1: register[32], arg2: "
93 "immediate[8]) { ... }"
110 "Unexpected token here. It should follow the syntax like in example: inst mov[16](arg1: register[32], arg2: "
111 "immediate[8]) { ... }"
136 "Expected an argument identifier here. Example: inst mov[16](arg1: register[32], arg2: immediate[8]) { ... }"
148 "Expected an colon after argument identifier. Example: inst mov[16](arg1: register[32], arg2: immediate[8]) { "
161 "Expected an argument type keyword here. Example: inst mov[16](arg1: register[32], arg2: immediate[8]) { ... }"
174 "inst mov[16](arg1: register[32], arg2: immediate[8]) { ... }"
ast_node_t * ast_add_children(ast_node_t *parent, node_type_t type, token_t *token)
Add a new children for the given AST node.
#define ARR_TT(...)
Same as ARR_ARG() macro, but with the specific type token_type_t.
void module_add_error(module_t *module, unsigned int line, unsigned int column, unsigned int length, const char *message)
Add error for the given module.
unsigned int parse_statement_inst(module_t *module, ast_node_t *parent, token_t *token)
Parse a inst statement adding it as a children on parent AST node.
unsigned int parse_advance(token_t *token, token_type_t *types, size_t ntypes)
Finds the next token TK_EOF or any of the specified types and then returns the number of tokens trave...
unsigned int parse_size_spec(module_t *module, ast_node_t *parent, token_t *token, const char *example)
Parse a size specification in the format [ EXPRESSION ] adding it as a children on parent AST node.
unsigned int parse_fieldlist_spec(module_t *module, ast_node_t *parent, token_t *token)
Parse a field list specification in the format field = EXPRESSION, ... adding it as a children on par...
unsigned int length
The length of the string.
Struct that represents a Mya module.
long long int value
Integer value of the token.
token_type_t type
Token type.
dstring_t lexeme
Lexeme of the token.
unsigned int line
Token line inside the module.
unsigned int column
Column of the token position on the line.
struct ast_node ast_node_t
struct module module_t
Struct that represents a Mya module.
struct token token_t
Struct for a Mya token.