2002-03-31 21:09:17 +00:00
|
|
|
%{
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
2002-04-01 04:36:56 +00:00
|
|
|
#define YYDEBUG 1
|
|
|
|
#define YYERROR_VERBOSE 1
|
2002-03-31 21:09:17 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
double d;
|
|
|
|
gboolean b;
|
|
|
|
gint i;
|
|
|
|
gchar *s;
|
|
|
|
}
|
|
|
|
|
|
|
|
%token <s> IDENTIFIER STRING
|
|
|
|
%token <d> FLOAT
|
|
|
|
%token <i> INTEGER
|
|
|
|
%token <b> BOOLEAN
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
%left '{' '}' '(' ')'
|
|
|
|
%left '!' '='
|
|
|
|
%left '+'
|
|
|
|
%left '.'
|
|
|
|
|
|
|
|
%start graph
|
2002-03-31 21:09:17 +00:00
|
|
|
%%
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
id: IDENTIFIER {}
|
|
|
|
;
|
|
|
|
|
|
|
|
qid: id
|
|
|
|
| id '.' id
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
value: STRING {}
|
|
|
|
| FLOAT {}
|
|
|
|
| INTEGER {}
|
|
|
|
| BOOLEAN {}
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
property_value: qid '=' value
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
element: id
|
|
|
|
| bin
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
graph: /* empty */
|
|
|
|
| graph element
|
|
|
|
| graph connection
|
|
|
|
| graph property_value
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
bin: '{' graph '}'
|
|
|
|
| id '.' '(' graph ')'
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
connection: lconnection
|
|
|
|
| rconnection
|
|
|
|
| bconnection
|
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
lconnection: qid '+' '!'
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
rconnection: '!' '+' qid
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
bconnection: '!'
|
|
|
|
| qid '+' bconnection '+' qid
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
extern FILE *yyin;
|
|
|
|
|
|
|
|
int
|
|
|
|
yyerror (const char *s)
|
|
|
|
{
|
|
|
|
printf ("error: %s\n", s);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
++argv, --argc; /* skip over program name */
|
|
|
|
if ( argc > 0 )
|
|
|
|
yyin = fopen (argv[0], "r");
|
|
|
|
else
|
|
|
|
yyin = stdin;
|
|
|
|
|
|
|
|
return yyparse();
|
|
|
|
}
|