gram.y revision 9aa2a2b5
1/*
2** grammar for xgc syntax
3*/
4
5%{
6#define YYDEBUG 1
7
8#include <stdio.h>
9#include <X11/X.h>
10#include <X11/Intrinsic.h>
11#include "xgc.h"
12
13extern int yylineno;
14
15%}
16
17%union
18{
19  int num;
20  char *ptr;
21};
22
23%token <ptr> STRING
24%token <num> NUMBER
25%token <num> RUN
26%token <num> FUNCTION FUNCTIONTYPE
27%token <num> TEST TESTTYPE
28%token <num> LINESTYLE LINESTYLETYPE
29%token <num> CAPSTYLE CAPSTYLETYPE
30%token <num> JOINSTYLE JOINSTYLETYPE
31%token <num> ROUND SOLID
32%token <num> FILLSTYLE FILLSTYLETYPE
33%token <num> FILLRULE FILLRULETYPE
34%token <num> ARCMODE ARCMODETYPE
35%token <num> FOREGROUND BACKGROUND LINEWIDTH PLANEMASK DASHLIST PERCENT
36%token <num> FONT
37
38%%
39
40all		: stmts
41		;
42
43stmts		: /* empty */
44		| stmts '\n'
45		| stmts stmt '\n'
46		;
47
48stmt		: error
49		| RUN
50	{ run_test(); }
51		| TEST TESTTYPE
52	{ change_test ($2, TRUE); }
53		| FUNCTION FUNCTIONTYPE
54	{ GC_change_function ($2, TRUE); }
55		| LINESTYLE LINESTYLETYPE
56	{ GC_change_linestyle ($2, TRUE); }
57		| LINESTYLE SOLID
58	{ GC_change_linestyle (LineSolid, TRUE); }
59		| CAPSTYLE CAPSTYLETYPE
60	{ GC_change_capstyle ($2, TRUE); }
61		| CAPSTYLE ROUND
62	{ GC_change_capstyle (CapRound, TRUE); }
63		| JOINSTYLE JOINSTYLETYPE
64	{ GC_change_joinstyle ($2, TRUE); }
65		| JOINSTYLE ROUND
66	{ GC_change_joinstyle (JoinRound, TRUE); }
67		| FILLSTYLE FILLSTYLETYPE
68	{ GC_change_fillstyle ($2, TRUE); }
69		| FILLSTYLE SOLID
70	{ GC_change_fillstyle (FillSolid, TRUE); }
71		| FILLRULE FILLRULETYPE
72	{ GC_change_fillrule ($2, TRUE); }
73		| ARCMODE ARCMODETYPE
74	{ GC_change_arcmode ($2, TRUE); }
75		| FOREGROUND NUMBER
76	{ GC_change_foreground ($2, TRUE); }
77		| BACKGROUND NUMBER
78	{ GC_change_background ($2, TRUE); }
79		| LINEWIDTH NUMBER
80	{ GC_change_linewidth ($2, TRUE); }
81		| PLANEMASK NUMBER
82	{ GC_change_planemask ($2, TRUE); }
83		| DASHLIST NUMBER
84	{ GC_change_dashlist ($2, TRUE); }
85		| FONT STRING
86	{ GC_change_font ($2, TRUE); }
87		| PERCENT NUMBER
88	{ change_percent ($2, TRUE); }
89		;
90
91%%
92void
93yyerror(const char *s)
94{
95  fprintf(stderr, "xgc: syntax error, line %d\n", yylineno);
96}
97