libmya 0.1.0
Library to parse Mya language.
Loading...
Searching...
No Matches
parse_statement.c
Go to the documentation of this file.
1#include <string.h>
2
3#include "module.h"
4#include "parser.h"
5#include "types/keywords.h"
6
7unsigned int
9{
10 if (token->type != TK_KEYWORD) {
12 module,
13 token->line,
16 "This token is unexpected here. It's expected to be a valid statement keyword.\n"
17 );
18
19 return 1;
20 }
21
22 switch (token->value) {
23 case KEY_INCLUDE:
24 return parse_statement_include(module, parent, token);
25 case KEY_SET:
26 return parse_statement_set(module, parent, token);
27 default:
28 return 1;
29 }
30}
@ KEY_SET
Definition keywords.h:10
@ KEY_INCLUDE
Definition keywords.h:7
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.
Definition module.c:92
unsigned int parse_statement(module_t *module, ast_node_t *parent, token_t *token)
Parse a statement adding it as a children on parent AST node.
unsigned int parse_statement_include(module_t *module, ast_node_t *parent, token_t *token)
Parse a include statement adding it as a children on parent AST node.
unsigned int parse_statement_set(module_t *module, ast_node_t *parent, token_t *token)
Parse a set statement adding it as a children on parent AST node.
unsigned int length
The length of the string.
Definition dstring.h:13
Struct that represents a Mya module.
Definition module.h:34
Struct for a Mya token.
Definition token.h:32
long long int value
Integer value of the token on TK_NUMBER tokens.
Definition token.h:36
token_type_t type
Token type.
Definition token.h:33
dstring_t lexeme
Lexeme of the token.
Definition token.h:37
unsigned int line
Token line inside the module.
Definition token.h:34
unsigned int column
Column of the token position on the line.
Definition token.h:35
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.
@ TK_KEYWORD
Definition token.h:18