add declaring and assignment with parser LHS support
This commit is contained in:
12
src/parser/assignable/identifier/identifier.c
Normal file
12
src/parser/assignable/identifier/identifier.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "identifier.h"
|
||||
#include "../../../lexer/token.h"
|
||||
#include "../../parser.h"
|
||||
#include <string.h>
|
||||
#include "../../../memory.h"
|
||||
|
||||
ParsedValue *parse_identifier(Token *token) {
|
||||
ParsedValue *parsedValue = checked_malloc(sizeof(ParsedValue));
|
||||
parsedValue->type = AST_IDENTIFIER;
|
||||
parsedValue->data = strcpy(checked_malloc(sizeof(token->value)), token->value);
|
||||
return parsedValue;
|
||||
}
|
||||
11
src/parser/assignable/identifier/identifier.h
Normal file
11
src/parser/assignable/identifier/identifier.h
Normal file
@@ -0,0 +1,11 @@
|
||||
// parser.h
|
||||
|
||||
#ifndef IDENTIFIER_H
|
||||
#define IDENTIFIER_H
|
||||
#include "../../parser.h"
|
||||
#include "../../../lexer/token.h" // for Token
|
||||
|
||||
// Function declaration for parsing an identifier
|
||||
ParsedValue * parse_identifier(Token * token);
|
||||
|
||||
#endif // IDENTIFIER_H
|
||||
Reference in New Issue
Block a user