test bison
This commit is contained in:
parent
e7b8c97dce
commit
e5b1dd03b5
|
|
@ -1,41 +1,14 @@
|
|||
%{
|
||||
#define YYDEBUG 1
|
||||
#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;
|
||||
void yyerror(const char*);
|
||||
|
||||
|
||||
/*
|
||||
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;
|
||||
int yylex();
|
||||
%}
|
||||
|
||||
%debug
|
||||
%define parse.error detailed
|
||||
|
||||
|
||||
%token TOKEN_EOF
|
||||
%token TOKEN_KEYWORD_IDENTIFICATION
|
||||
%token TOKEN_KEYWORD_DIVISION
|
||||
|
|
@ -102,6 +75,7 @@ statement : section
|
|||
| data_space
|
||||
| data_declaration
|
||||
;
|
||||
|
||||
section : type TOKEN_KEYWORD_DIVISION TOKEN_DOT
|
||||
| type TOKEN_RUN TOKEN_DOT
|
||||
;
|
||||
|
|
|
|||
Loading…
Reference in New Issue