/[CvsGraph]/cvsgraph/rcsl.l
ViewVC logotype

Annotate of /cvsgraph/rcsl.l

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations)
Mon Mar 10 22:57:21 2003 UTC (14 years, 8 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_4_0
Changes since 1.2: +2 -0 lines
*** empty log message ***
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 <xID>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
115
116 <xSYM>{ws}+ ;
117 <xSYM>\n line_number++;
118 <xSYM>{special} BEGIN(INITIAL); return *rcstext;
119 <xSYM>{digit}*{idchar}({idchar}|{digit})* {
120 rcslval.str = xstrdup(rcstext);
121 BEGIN(INITIAL);
122 return tSYM;
123 }
124 <xSYM>{digit}*. rcserror("Invalid character in SYMBOL '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
125
126 @ reset_str(); BEGIN(xSTR);
127 <xSTR>[^@\n]+ add_str(rcstext, rcsleng);
128 <xSTR>\n line_number++; add_str(rcstext, rcsleng);
129 <xSTR>@@ add_str(rcstext, 1);
130 <xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
131
132
133 {ws}+ ; /* Ignore whitespace */
134 \n line_number++;
135
136 . rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
137
138 %%
139
140 int rcswrap(void)
141 {
142 return 1;
143 }
144
145 void set_id(void)
146 {
147 BEGIN(xID);
148 }
149
150 void set_sym(void)
151 {
152 BEGIN(xSYM);
153 }
154
155 void set_skip(void)
156 {
157 BEGIN(xSKIP);
158 }
159
160 void set_skipstr(void)
161 {
162 skip_string = 1;
163 }
164
165 #define STRALLOCSIZE 256
166 static char *str;
167 static int nstr;
168 static int nastr;
169
170 static void reset_str(void)
171 {
172 nstr = 0;
173 }
174
175 static void add_str(const char *s, int l)
176 {
177 #ifdef SKIP_DELTATEXT
178 if(skip_string)
179 return;
180 #endif
181 if(nstr + l + 1 > nastr)
182 {
183 str = xrealloc(str, nastr+STRALLOCSIZE);
184 nastr += STRALLOCSIZE;
185 }
186 memcpy(str+nstr, s, l);
187 nstr += l;
188 }
189
190 static char *get_str(void)
191 {
192 #ifdef SKIP_DELTATEXT
193 if(skip_string)
194 return xstrdup("");
195 #endif
196 if(str)
197 {
198 str[nstr] = '\0';
199 return xstrdup(str);
200 }
201 else
202 return xstrdup("");
203 }
204

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0