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
|
/*
** grammar for xgc syntax
*/
%{
#define YYDEBUG 1
#include <stdio.h>
#include <X11/X.h>
#include <X11/Intrinsic.h>
#include "xgc.h"
extern int yylineno;
%}
%union
{
int num;
char *ptr;
};
%token <ptr> STRING
%token <num> NUMBER
%token <num> RUN
%token <num> FUNCTION FUNCTIONTYPE
%token <num> TEST TESTTYPE
%token <num> LINESTYLE LINESTYLETYPE
%token <num> CAPSTYLE CAPSTYLETYPE
%token <num> JOINSTYLE JOINSTYLETYPE
%token <num> ROUND SOLID
%token <num> FILLSTYLE FILLSTYLETYPE
%token <num> FILLRULE FILLRULETYPE
%token <num> ARCMODE ARCMODETYPE
%token <num> FOREGROUND BACKGROUND LINEWIDTH PLANEMASK DASHLIST PERCENT
%token <num> FONT
%%
all : stmts
;
stmts : /* empty */
| stmts '\n'
| stmts stmt '\n'
;
stmt : error
| RUN
{ run_test(); }
| TEST TESTTYPE
{ change_test ($2, TRUE); }
| FUNCTION FUNCTIONTYPE
{ GC_change_function ($2, TRUE); }
| LINESTYLE LINESTYLETYPE
{ GC_change_linestyle ($2, TRUE); }
| LINESTYLE SOLID
{ GC_change_linestyle (LineSolid, TRUE); }
| CAPSTYLE CAPSTYLETYPE
{ GC_change_capstyle ($2, TRUE); }
| CAPSTYLE ROUND
{ GC_change_capstyle (CapRound, TRUE); }
| JOINSTYLE JOINSTYLETYPE
{ GC_change_joinstyle ($2, TRUE); }
| JOINSTYLE ROUND
{ GC_change_joinstyle (JoinRound, TRUE); }
| FILLSTYLE FILLSTYLETYPE
{ GC_change_fillstyle ($2, TRUE); }
| FILLSTYLE SOLID
{ GC_change_fillstyle (FillSolid, TRUE); }
| FILLRULE FILLRULETYPE
{ GC_change_fillrule ($2, TRUE); }
| ARCMODE ARCMODETYPE
{ GC_change_arcmode ($2, TRUE); }
| FOREGROUND NUMBER
{ GC_change_foreground ($2, TRUE); }
| BACKGROUND NUMBER
{ GC_change_background ($2, TRUE); }
| LINEWIDTH NUMBER
{ GC_change_linewidth ($2, TRUE); }
| PLANEMASK NUMBER
{ GC_change_planemask ($2, TRUE); }
| DASHLIST NUMBER
{ GC_change_dashlist ($2, TRUE); }
| FONT STRING
{ GC_change_font ($2, TRUE); }
| PERCENT NUMBER
{ change_percent ($2, TRUE); }
;
%%
void
yyerror(const char *s)
{
fprintf(stderr, "xgc: syntax error, line %d\n", yylineno);
}
|