test bison

This commit is contained in:
vel 2024-11-12 15:41:25 -08:00
parent e7b8c97dce
commit e5b1dd03b5
Signed by: velvox
GPG Key ID: 59D9762F674151DF
1 changed files with 2 additions and 28 deletions

View File

@ -1,41 +1,14 @@
%{ %{
#define YYDEBUG 1 #define YYDEBUG 1
#include <stdio.h> #include <stdio.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "expr.h"
/*
YYSTYPE is the lexical value returned by each rule in a bison grammar.
By default, it is an integer. In this example, we are returning a pointer to an expression.
*/
#define YYSTYPE struct expr *
/*
Clunky: Manually declare the interface to the scanner generated by flex.
*/
extern char *yytext;
extern int yylex();
extern int yylineno; extern int yylineno;
void yyerror(const char*); void yyerror(const char*);
int yylex();
/*
Clunky: Keep the final result of the parse in a global variable,
so that it can be retrieved by main().
*/
struct expr * parser_result = 0;
%} %}
%debug %debug
%define parse.error detailed %define parse.error detailed
%token TOKEN_EOF %token TOKEN_EOF
%token TOKEN_KEYWORD_IDENTIFICATION %token TOKEN_KEYWORD_IDENTIFICATION
%token TOKEN_KEYWORD_DIVISION %token TOKEN_KEYWORD_DIVISION
@ -102,6 +75,7 @@ statement : section
| data_space | data_space
| data_declaration | data_declaration
; ;
section : type TOKEN_KEYWORD_DIVISION TOKEN_DOT section : type TOKEN_KEYWORD_DIVISION TOKEN_DOT
| type TOKEN_RUN TOKEN_DOT | type TOKEN_RUN TOKEN_DOT
; ;