Added a description for my extensions (README-my-extensions.html).
[parsecvs/imz-RCS2git-use-cases.git] / gram.y
blob796871743fd4e110b3083468306f2d2207f9c430
1 %{
2 /*
3 * Copyright © 2006 Keith Packard <keithp@keithp.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #include "cvs.h"
22 void yyerror (char *msg);
26 %union {
27 int i;
28 time_t date;
29 char *s;
30 cvs_number number;
31 cvs_symbol *symbol;
32 cvs_version *version;
33 cvs_version **vlist;
34 cvs_patch *patch;
35 cvs_patch **patches;
36 cvs_branch *branch;
37 cvs_file *file;
40 %token HEAD BRANCH ACCESS SYMBOLS LOCKS COMMENT DATE
41 %token BRANCHES NEXT COMMITID EXPAND
42 %token DESC LOG TEXT STRICT AUTHOR STATE
43 %token SEMI COLON
44 %token BRAINDAMAGED_NUMBER
45 %token <s> HEX NAME DATA TEXT_DATA
46 %token <number> NUMBER
48 %type <s> text log
49 %type <symbol> symbollist symbol symbols
50 %type <version> revision
51 %type <vlist> revisions
52 %type <date> date
53 %type <branch> branches numbers
54 %type <s> opt_commitid commitid
55 %type <s> desc name
56 %type <s> author state
57 %type <number> next opt_number
58 %type <patch> patch
59 %type <patches> patches
63 file : headers revisions desc patches
67 headers : header headers
70 header : HEAD opt_number SEMI
71 { this_file->head = $2; }
72 | BRANCH NUMBER SEMI
73 { this_file->branch = $2; }
74 | ACCESS SEMI
75 | symbollist
76 { this_file->symbols = $1; }
77 | LOCKS locks SEMI lock_type
78 | COMMENT DATA SEMI
79 | EXPAND DATA SEMI
80 { this_file->expand = $2; }
82 locks : locks lock
85 lock : NAME COLON NUMBER
87 lock_type : STRICT SEMI
90 symbollist : SYMBOLS symbols SEMI
91 { $$ = $2; }
93 symbols : symbols symbol
94 { $2->next = $1; $$ = $2; }
95 | symbols fscked_symbol
96 { $$ = $1; }
98 { $$ = NULL; }
100 symbol : name COLON NUMBER
102 $$ = calloc (1, sizeof (cvs_symbol));
103 $$->name = $1;
104 $$->number = $3;
107 fscked_symbol : name COLON BRAINDAMAGED_NUMBER
109 fprintf(stderr, "ignoring symbol %s (FreeBSD RELENG_2_1_0 braindamage?)\n", $1);
112 name : NAME
113 | NUMBER
115 char name[CVS_MAX_REV_LEN];
116 cvs_number_string (&$1, name);
117 $$ = atom (name);
120 revisions : revisions revision
121 { *$1 = $2; $$ = &$2->next; }
123 { $$ = &this_file->versions; }
125 revision : NUMBER date author state branches next opt_commitid
127 $$ = calloc (1, sizeof (cvs_version));
128 $$->number = $1;
129 $$->date = $2;
130 $$->author = $3;
131 $$->state = $4;
132 $$->dead = !strcmp ($4, "dead");
133 $$->branches = $5;
134 $$->parent = $6;
135 $$->commitid = $7;
136 hash_version($$);
137 ++this_file->nversions;
140 date : DATE NUMBER SEMI
142 $$ = lex_date (&$2);
145 author : AUTHOR NAME SEMI
146 { $$ = $2; }
148 state : STATE NAME SEMI
149 { $$ = $2; }
151 branches : BRANCHES numbers SEMI
152 { $$ = $2; }
154 numbers : NUMBER numbers
156 $$ = calloc (1, sizeof (cvs_branch));
157 $$->next = $2;
158 $$->number = $1;
159 hash_branch($$);
162 { $$ = NULL; }
164 next : NEXT opt_number SEMI
165 { $$ = $2; }
167 opt_number : NUMBER
168 { $$ = $1; }
170 { $$.c = 0; }
172 opt_commitid : commitid
173 { $$ = $1; }
175 { $$ = NULL; }
177 commitid : COMMITID NAME SEMI
178 { $$ = $2; }
180 desc : DESC DATA
181 { $$ = $2; }
183 patches : patches patch
184 { *$1 = $2; $$ = &$2->next; }
186 { $$ = &this_file->patches; }
188 patch : NUMBER log text
189 { $$ = calloc (1, sizeof (cvs_patch));
190 $$->number = $1;
191 $$->log = $2;
192 $$->text = $3;
193 hash_patch($$);
196 log : LOG DATA
197 { $$ = $2; }
199 text : TEXT TEXT_DATA
200 { $$ = $2; }
204 void yyerror (char *msg)
206 fprintf (stderr, "parse error %s at %s\n", msg, lex_text ());