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.
23 parse_data (int strip);
25 #define YY_INPUT(buf,result,max_size) { \
26 int c = getc (yyin); \
27 result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
31 %s CONTENT SKIP COMMIT
33 <INITIAL>head BEGIN(CONTENT); return HEAD;
34 <INITIAL>branch BEGIN(CONTENT); return BRANCH;
35 <INITIAL>access BEGIN(CONTENT); return ACCESS;
36 <INITIAL>symbols BEGIN(CONTENT); return SYMBOLS;
37 <INITIAL>locks BEGIN(CONTENT); return LOCKS;
38 <INITIAL>comment BEGIN(CONTENT); return COMMENT;
39 <INITIAL>expand BEGIN(CONTENT); return EXPAND;
40 <INITIAL>date BEGIN(CONTENT); return DATE;
41 <INITIAL>branches BEGIN(CONTENT); return BRANCHES;
42 <INITIAL>next BEGIN(CONTENT); return NEXT;
43 <INITIAL>commitid BEGIN(COMMIT); return COMMITID;
44 <INITIAL>strict BEGIN(CONTENT); return STRICT;
45 <INITIAL>author BEGIN(CONTENT); return AUTHOR;
46 <INITIAL>state BEGIN(CONTENT); return STATE;
47 <INITIAL>desc return DESC;
48 <INITIAL>log return LOG;
49 <INITIAL>text BEGIN(SKIP); return TEXT;
51 yylval.s = parse_data (0);
55 <CONTENT>[-a-zA-Z_+%][-a-zA-Z_0-9+/%.]* {
56 yylval.s = atom (yytext);
59 <COMMIT>[0-9a-zA-Z]+ {
60 yylval.s = atom (yytext);
64 yylval.number = lex_number (yytext);
67 ; BEGIN(INITIAL); return SEMI;
70 yylval.s = parse_data (1);
76 1 return BRAINDAMAGED_NUMBER;
78 fprintf (stderr, "%s: (%d) ignoring %c\n",
83 int yywrap (void) { return 1; }
90 static inline void addbuf(struct varbuf *buf, char c)
92 if (buf->cur == buf->len)
93 buf->string = realloc(buf->string, buf->len *= 2);
94 buf->string[buf->cur++] = c;
98 parse_data (int strip)
106 buf.string = malloc(buf.len);
124 ret = atom (buf.string);
140 n.n[n.c] = (int) strtol(s, &next, 10);
152 lex_date (cvs_number *n)
157 tm.tm_year = n->n[0];
158 if (tm.tm_year > 1900)
160 tm.tm_mon = n->n[1] - 1;
161 tm.tm_mday = n->n[2];
162 tm.tm_hour = n->n[3];
170 fprintf (stderr, "%s: (%d) unparsable date: ", yyfilename,
172 for (i = 0; i < n->c; i++) {
173 if (i) fprintf (stderr, ".");
174 fprintf (stderr, "%d", n->n[i]);
176 fprintf (stderr, "\n");