test bison
This commit is contained in:
parent
e7b8c97dce
commit
e5b1dd03b5
|
|
@ -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
|
||||||
;
|
;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue