Subversion Repositories Vertical

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
 
2
%{
3
#include <stdio.h>
4
%}
5
 
6
// Symbols.
7
%union
8
{
9
	char	*sval;
10
};
11
%token <sval> IDENTIFIER
12
%token PROCEDURE
13
%token BLOCK
14
%token ENDBLOCK
15
 
16
%start Procedure
17
%%
18
 
19
Procedure:
20
	PROCEDURE IDENTIFIER BLOCK { printf("Procedure : %s\n", $2); }
21
	Parts
22
	ENDBLOCK
23
	;
24
 
25
Parts:
26
	/* empty */
27
	| Parts Part
28
	;
29
 
30
Part:
31
	IDENTIFIER BLOCK { printf("\tPart : %s\n", $1); }
32
		Keywords
33
	ENDBLOCK
34
	;
35
 
36
Keywords:
37
	/* empty */
38
	| Keywords Keyword
39
	;
40
 
41
Keyword:
42
	IDENTIFIER { printf("\t\tKeyword : %s\n", $1); }
43
	;
44
%%
45
 
46
int yyerror(char *s) {
47
  printf("yyerror : %s\n",s);
48
}
49
 
50
int main(void) {
51
  yyparse();
52
}
53