Parser compiles from .y and .lex files
This commit is contained in:
10
grammar.y
10
grammar.y
@ -5,8 +5,10 @@
|
|||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "symbol_table.c"
|
#include "symbol_table.c"
|
||||||
|
extern int yylex(void);
|
||||||
|
void yyerror(const char *err);
|
||||||
%}
|
%}
|
||||||
|
/*
|
||||||
%token ID 101
|
%token ID 101
|
||||||
%token T_INTEGER 201
|
%token T_INTEGER 201
|
||||||
%token T_ADDRESS 202
|
%token T_ADDRESS 202
|
||||||
@ -52,7 +54,7 @@
|
|||||||
%token DOT 612
|
%token DOT 612
|
||||||
%token RESERVE 613
|
%token RESERVE 613
|
||||||
%token RELEASE 614
|
%token RELEASE 614
|
||||||
%token COMMENT 700
|
%token COMMENT 700 */
|
||||||
%%
|
%%
|
||||||
|
|
||||||
start: /*empty for now*/
|
start: /*empty for now*/
|
||||||
@ -67,7 +69,9 @@ start: /*empty for now*/
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
void yyerror(const char *err) {
|
||||||
|
fprintf(stderr, "Error: %s\n", err);
|
||||||
|
}
|
||||||
int main() {
|
int main() {
|
||||||
return yyparse();
|
return yyparse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
%{
|
%{
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
#include "grammar.tab.h"
|
||||||
int line_number = 1, column_number = 1;
|
int line_number = 1, column_number = 1;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
Reference in New Issue
Block a user