Add "primitive" parsers for all the semantic tokens in the lexer grammar
This commit is contained in:
		
							
								
								
									
										61
									
								
								src/parser_primitives.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/parser_primitives.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| #include "parser_primitives.h" | ||||
|  | ||||
| parse_result_t parse_identifier(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_IDENTIFIER, NODE_IDENTIFIER); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_decimal(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_DECIMAL, NODE_DECIMAL); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_hexadecimal(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_HEXADECIMAL, NODE_HEXADECIMAL); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_binary(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_BINARY, NODE_BINARY); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_octal(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_OCTAL, NODE_OCTAL); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_string(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_STRING, NODE_STRING); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_char(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_CHAR, NODE_CHAR); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_colon(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_COLON, NODE_COLON); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_comma(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_COMMA, NODE_COMMA); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_lbracket(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_LBRACKET, NODE_LBRACKET); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_rbracket(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_RBRACKET, NODE_RBRACKET); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_plus(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_PLUS, NODE_PLUS); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_minus(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_MINUS, NODE_MINUS); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_asterisk(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_ASTERISK, NODE_ASTERISK); | ||||
| } | ||||
|  | ||||
| parse_result_t parse_dot(tokenlist_entry_t *current) { | ||||
|     return parse_token(current, TOKEN_DOT, NODE_DOT); | ||||
| } | ||||
							
								
								
									
										22
									
								
								src/parser_primitives.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/parser_primitives.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| #ifndef INCLUDE_SRC_PARSER_PRIMITIVES_H_ | ||||
| #define INCLUDE_SRC_PARSER_PRIMITIVES_H_ | ||||
|  | ||||
| #include "parser_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); | ||||
|  | ||||
| #endif // INCLUDE_SRC_PARSER_PRIMITIVES_H_ | ||||
		Reference in New Issue
	
	Block a user