1 |
/*
|
2 |
* CvsGraph graphical representation generator of brances and revisions
|
3 |
* of a file in cvs/rcs.
|
4 |
*
|
5 |
* Copyright (C) 2001 B. Stultiens
|
6 |
*
|
7 |
* This program is free software; you can redistribute it and/or modify
|
8 |
* it under the terms of the GNU General Public License as published by
|
9 |
* the Free Software Foundation; either version 2 of the License, or
|
10 |
* (at your option) any later version.
|
11 |
*
|
12 |
* This program is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU General Public License
|
18 |
* along with this program; if not, write to the Free Software
|
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 |
*/
|
21 |
|
22 |
%x xSTR
|
23 |
%x xID
|
24 |
%x xSYM
|
25 |
%x xSKIP
|
26 |
%x xSKIPSTR
|
27 |
|
28 |
%{
|
29 |
#include <stdio.h>
|
30 |
#include <stdlib.h>
|
31 |
#include <string.h>
|
32 |
#include <ctype.h>
|
33 |
|
34 |
#include "utils.h"
|
35 |
#include "readconf.h"
|
36 |
#include "rcs.h"
|
37 |
#include "rcs.tab.h"
|
38 |
|
39 |
#define SKIP_DELTATEXT 1
|
40 |
|
41 |
static void reset_str(void);
|
42 |
static void add_str(const char *s, int l);
|
43 |
static char *get_str(void);
|
44 |
|
45 |
static int skip_string = 0;
|
46 |
|
47 |
#define YY_NO_UNPUT 1
|
48 |
|
49 |
%}
|
50 |
|
51 |
ws [\b\t\v\f\r ]
|
52 |
num [0-9.]+
|
53 |
digit [0-9]
|
54 |
idchar [!-#%-+\-/<-?A-~\240-\377]
|
55 |
special [$,.:;@]
|
56 |
|
57 |
%%
|
58 |
/* RCS keywords */
|
59 |
head return tHEAD;
|
60 |
branch return tBRANCH;
|
61 |
access return tACCESS;
|
62 |
symbols return tSYMBOLS;
|
63 |
locks return tLOCKS;
|
64 |
strict return tSTRICT;
|
65 |
comment return tCOMMENT;
|
66 |
expand return tEXPAND;
|
67 |
date return tDATE;
|
68 |
author return tAUTHOR;
|
69 |
state return tSTATE;
|
70 |
branches return tBRANCHES;
|
71 |
next return tNEXT;
|
72 |
desc return tDESC;
|
73 |
log return tLOG;
|
74 |
text return tTEXT;
|
75 |
/* CVS extensions */
|
76 |
owner return tOWNER;
|
77 |
group return tGROUP;
|
78 |
permissions return tPERMISSIONS;
|
79 |
special return tSPECIAL;
|
80 |
symlnk return tSYMLINK;
|
81 |
hardlinks return tHARDLINKS;
|
82 |
/* Other known extensions */
|
83 |
namespace return tNAMESPACE;
|
84 |
dead return tDEAD;
|
85 |
|
86 |
/* Here come any other 'newphrase' constructs */
|
87 |
{num}?{idchar}({idchar}|{num})* {
|
88 |
rcslval.str = xstrdup(rcstext);
|
89 |
return tNEWPHRASE;
|
90 |
}
|
91 |
|
92 |
/* Special rules for skipping everything after a 'newphrase' part */
|
93 |
<xSKIP>[^;@\n]+ ;
|
94 |
<xSKIP>\n line_number++;
|
95 |
<xSKIP>@ BEGIN(xSKIPSTR);
|
96 |
<xSKIP>; BEGIN(INITIAL); return *rcstext;
|
97 |
|
98 |
<xSKIPSTR>[^\n@]+ ;
|
99 |
<xSKIPSTR>\n line_number++;
|
100 |
<xSKIPSTR>@@ ;
|
101 |
<xSKIPSTR>@ BEGIN(xSKIP);
|
102 |
|
103 |
{num} rcslval.str = xstrdup(rcstext); return tREV;
|
104 |
[:;$] return *rcstext;
|
105 |
|
106 |
<xID>{ws}+ ;
|
107 |
<xID>\n line_number++;
|
108 |
<xID>{special} BEGIN(INITIAL); return *rcstext;
|
109 |
<xID>{num}?{idchar}({idchar}|{num})* {
|
110 |
rcslval.str = xstrdup(rcstext);
|
111 |
BEGIN(INITIAL);
|
112 |
return tID;
|
113 |
}
|
114 |
|
115 |
<xSYM>{ws}+ ;
|
116 |
<xSYM>\n line_number++;
|
117 |
<xSYM>{special} BEGIN(INITIAL); return *rcstext;
|
118 |
<xSYM>{digit}*{idchar}({idchar}|{digit})* {
|
119 |
rcslval.str = xstrdup(rcstext);
|
120 |
BEGIN(INITIAL);
|
121 |
return tSYM;
|
122 |
}
|
123 |
|
124 |
@ reset_str(); BEGIN(xSTR);
|
125 |
<xSTR>[^@\n]+ add_str(rcstext, rcsleng);
|
126 |
<xSTR>\n line_number++; add_str(rcstext, rcsleng);
|
127 |
<xSTR>@@ add_str(rcstext, 1);
|
128 |
<xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
|
129 |
|
130 |
|
131 |
{ws}+ ; /* Ignore whitespace */
|
132 |
\n line_number++;
|
133 |
|
134 |
. rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
|
135 |
|
136 |
%%
|
137 |
|
138 |
int rcswrap(void)
|
139 |
{
|
140 |
return 1;
|
141 |
}
|
142 |
|
143 |
void set_id(void)
|
144 |
{
|
145 |
BEGIN(xID);
|
146 |
}
|
147 |
|
148 |
void set_sym(void)
|
149 |
{
|
150 |
BEGIN(xSYM);
|
151 |
}
|
152 |
|
153 |
void set_skip(void)
|
154 |
{
|
155 |
BEGIN(xSKIP);
|
156 |
}
|
157 |
|
158 |
void set_skipstr(void)
|
159 |
{
|
160 |
skip_string = 1;
|
161 |
}
|
162 |
|
163 |
#define STRALLOCSIZE 256
|
164 |
static char *str;
|
165 |
static int nstr;
|
166 |
static int nastr;
|
167 |
|
168 |
static void reset_str(void)
|
169 |
{
|
170 |
nstr = 0;
|
171 |
}
|
172 |
|
173 |
static void add_str(const char *s, int l)
|
174 |
{
|
175 |
#ifdef SKIP_DELTATEXT
|
176 |
if(skip_string)
|
177 |
return;
|
178 |
#endif
|
179 |
if(nstr + l + 1 > nastr)
|
180 |
{
|
181 |
str = xrealloc(str, nastr+STRALLOCSIZE);
|
182 |
nastr += STRALLOCSIZE;
|
183 |
}
|
184 |
memcpy(str+nstr, s, l);
|
185 |
nstr += l;
|
186 |
}
|
187 |
|
188 |
static char *get_str(void)
|
189 |
{
|
190 |
#ifdef SKIP_DELTATEXT
|
191 |
if(skip_string)
|
192 |
return xstrdup("");
|
193 |
#endif
|
194 |
str[nstr] = '\0';
|
195 |
return xstrdup(str);
|
196 |
}
|
197 |
|