%{
#include <stdio.h>
#include <dfa.h>
%}
%start productions
%token GOESTO
%token STR
%union {
	Dfa d ;
}
%type <d> expr2 expr1 expr STR
%%

productions :
	|
	production
	productions
	;

production :
	expr GOESTO
	;

expr :
	expr '|' expr1
	{
		$$ = dfa_union(0,$1,$3) ;
	}
	|
	expr1
	{
		$$ = $1 ;
	}
	;

expr1 :
	expr1 expr2
	{
		$$ = dfa_concat(0,$1,$2) ;
	}
	|
	expr2
	{
		$$ = $1 ;
	}
	;

expr2 :
	'(' expr ')'
	{
		$$ = $2 ;
	}
	|
	STR
	{
		$$ = $1 ;
	}
	;
%%
yyerror(s)
	char *s ;
{
	fprintf(stderr,"%s.\n",s) ;
}
