try accomidate more versions of bison

This commit is contained in:
Dana Jansens 2003-04-03 15:36:43 +00:00
parent ff113a7eea
commit 2d81fb038b

View file

@ -1,10 +1,26 @@
%{ %{
#include "parse.h" #include <glib.h>
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
# include <stdio.h> # include <stdio.h>
#endif #endif
%}
%union ParseToken {
float real;
int integer;
char *string;
char *identifier;
gboolean bool;
char character;
}
%{
#include "parse.h"
extern int yylex(); extern int yylex();
/*extern int yyparse();*/
/*void yyerror(char *err);*/
extern int yylineno; extern int yylineno;
extern FILE *yyin; extern FILE *yyin;
@ -17,15 +33,6 @@ void parse_token(ParseTokenType type, union ParseToken token);
void parse_set_section(char *section); void parse_set_section(char *section);
%} %}
%union ParseToken {
float real;
int integer;
char *string;
char *identifier;
gboolean bool;
char character;
}
%token <real> REAL %token <real> REAL
%token <integer> INTEGER %token <integer> INTEGER
%token <string> STRING %token <string> STRING
@ -47,7 +54,7 @@ sections:
; ;
lines: lines:
| lines tokens '\n' { t.character = $3; parse_token(TOKEN_NEWLINE, t); } | lines tokens '\n' { t.character = $3; parse_token($3, t); }
; ;
tokens: tokens:
@ -56,17 +63,17 @@ tokens:
; ;
token: token:
REAL { t.real = $1; parse_token(TOKEN_REAL, t); } REAL { t.real = $1; parse_token(REAL, t); }
| INTEGER { t.integer = $1; parse_token(TOKEN_INTEGER, t); } | INTEGER { t.integer = $1; parse_token(INTEGER, t); }
| STRING { t.string = $1; parse_token(TOKEN_STRING, t); } | STRING { t.string = $1; parse_token(STRING, t); }
| IDENTIFIER { t.identifier = $1; parse_token(TOKEN_IDENTIFIER, t); } | IDENTIFIER { t.identifier = $1; parse_token(IDENTIFIER, t); }
| BOOL { t.bool = $1; parse_token(TOKEN_BOOL, t); } | BOOL { t.bool = $1; parse_token(BOOL, t); }
| '(' { t.character = $1; parse_token(TOKEN_LBRACKET, t); } | '(' { t.character = $1; parse_token($1, t); }
| ')' { t.character = $1; parse_token(TOKEN_RBRACKET, t); } | ')' { t.character = $1; parse_token($1, t); }
| '{' { t.character = $1; parse_token(TOKEN_LBRACE, t); } | '{' { t.character = $1; parse_token($1, t); }
| '}' { t.character = $1; parse_token(TOKEN_RBRACE, t); } | '}' { t.character = $1; parse_token($1, t); }
| '=' { t.character = $1; parse_token(TOKEN_EQUALS, t); } | '=' { t.character = $1; parse_token($1, t); }
| ',' { t.character = $1; parse_token(TOKEN_COMMA, t); } | ',' { t.character = $1; parse_token($1, t); }
; ;
%% %%