summaryrefslogtreecommitdiff
path: root/other/gramble/input.y
blob: 17ae7188d6e5ca52cd6fdb2a26a1cea32f65fef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* gramble - grammar ramble
 *
 * team teso
 *
 * grammar parser
 */

%{
#include <stdio.h>
#include <stdlib.h>
#include "input.h"

extern void *	in_grammar;

%}


%union {
	unsigned int	uint;	/* unsigned number (length) */
	unsigned char *	str;	/* generic ASCIIZ string pointer */
	void *		ugly;
}


%token	<str>	STR NSSTR NTERM TERM FILTER NEGFILTER SIZE
%token	<uint>	NUM

/* use % type here */
%type	<ugly>	prod prodr prodrelem poptl popt

%start	prodlist

%%

prodlist:
	prodlist prod
{
	in_grammar = NULL;
}
	| prod
{
	in_grammar = NULL;
}
	;

prod:	NTERM ':' prodr
{
	$$ = NULL;
}
	;

/* prodr, right side of a production */
prodr:	prodr prodrelem
{
	$$ = NULL;
}
	| prodrelem
{
	$$ = NULL;
}
	;

/* prodr, right side of a production */
prodrelem:	'[' prodr ']' poptl
{
	$$ = NULL;
}
	| NTERM
{
	$$ = NULL;
}
	| TERM
{
	$$ = NULL;
}
	;

/* production option list */
poptl:	poptl '(' popt ')'
{
	$$ = NULL;
}
	|
{
	$$ = NULL;
}
	;

popt:	FILTER ':' '/' NSSTR '/'
{
	fprintf (stderr, "FILTER: %s with /%s/\n", $1, $4);
	$$ = NULL;
}
	| NEGFILTER ':' '/' NSSTR '/'
{
	$$ = NULL;
}
	| SIZE ':' NUM '-' NUM
{
	$$ = NULL;
}
	;


%%

/* TODO: includes in parser come here
 */