create token nodes in lexer
This commit is contained in:
parent
89889b778f
commit
57dcf9e62d
@ -1,6 +1,10 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
#define YYSTYPE Node *
|
||||
|
||||
void parse(const char * filename);
|
||||
|
||||
#endif
|
||||
|
@ -7,13 +7,22 @@
|
||||
#include "parser.tab.h"
|
||||
#include "String.h"
|
||||
#include <stdlib.h>
|
||||
#include "Node.h"
|
||||
|
||||
#define YY_USER_ACTION yylloc->first_column += yyleng;
|
||||
#define YY_USER_ACTION \
|
||||
do { \
|
||||
yylloc->first_column += yyleng; \
|
||||
*yylval = Node_new(NODE_TYPE_TOKEN); \
|
||||
(*yylval)->token.fname = current_file; \
|
||||
(*yylval)->token.line = current_line; \
|
||||
(*yylval)->token.text = String_new(yytext); \
|
||||
} while(0);
|
||||
|
||||
static String * build_string = NULL;
|
||||
static size_t current_line = 1u;
|
||||
static String * current_file = NULL;
|
||||
void handle_loc(const char * input);
|
||||
void user_action(void);
|
||||
|
||||
%}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user