/[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.7 - (hide annotations)
Mon Jun 13 19:57:10 2005 UTC (12 years, 6 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_5_2
Changes since 1.6: +1 -0 lines
- Work around CVSNT problem with wrong keyword ordering
- Fix complaining about a new CVSNT keyword properties
1 bertho 1.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 bertho 1.4 %x xAUTHOR
28 bertho 1.1
29     %{
30     #include <stdio.h>
31     #include <stdlib.h>
32     #include <string.h>
33     #include <ctype.h>
34    
35     #include "utils.h"
36     #include "readconf.h"
37     #include "rcs.h"
38     #include "rcs.tab.h"
39    
40     #define SKIP_DELTATEXT 1
41    
42     static void reset_str(void);
43     static void add_str(const char *s, int l);
44     static char *get_str(void);
45    
46     static int skip_string = 0;
47    
48     #define YY_NO_UNPUT 1
49    
50     %}
51    
52     ws [\b\t\v\f\r ]
53     num [0-9.]+
54     digit [0-9]
55     idchar [!-#%-+\-/<-?A-~\240-\377]
56     special [$,.:;@]
57    
58     %%
59     /* RCS keywords */
60     head return tHEAD;
61     branch return tBRANCH;
62     access return tACCESS;
63     symbols return tSYMBOLS;
64     locks return tLOCKS;
65     strict return tSTRICT;
66     comment return tCOMMENT;
67     expand return tEXPAND;
68     date return tDATE;
69     author return tAUTHOR;
70     state return tSTATE;
71     branches return tBRANCHES;
72     next return tNEXT;
73     desc return tDESC;
74     log return tLOG;
75     text return tTEXT;
76     /* CVS extensions */
77     owner return tOWNER;
78     group return tGROUP;
79     permissions return tPERMISSIONS;
80     special return tSPECIAL;
81     symlnk return tSYMLINK;
82     hardlinks return tHARDLINKS;
83     /* Other known extensions */
84     namespace return tNAMESPACE;
85     dead return tDEAD;
86 bertho 1.6 /* CVSNT extensions */
87 bertho 1.5 mergepoint1 return tMERGEPOINT;
88 bertho 1.6 deltatype return tDELTATYPE;
89     commitid return tCOMMITID;
90     kopt return tKOPT;
91     filename return tFILENAME;
92 bertho 1.7 properties return tPROPERTIES;
93 bertho 1.1
94     /* Here come any other 'newphrase' constructs */
95     {num}?{idchar}({idchar}|{num})* {
96     rcslval.str = xstrdup(rcstext);
97     return tNEWPHRASE;
98     }
99    
100     /* Special rules for skipping everything after a 'newphrase' part */
101     <xSKIP>[^;@\n]+ ;
102     <xSKIP>\n line_number++;
103     <xSKIP>@ BEGIN(xSKIPSTR);
104     <xSKIP>; BEGIN(INITIAL); return *rcstext;
105    
106     <xSKIPSTR>[^\n@]+ ;
107     <xSKIPSTR>\n line_number++;
108     <xSKIPSTR>@@ ;
109     <xSKIPSTR>@ BEGIN(xSKIP);
110    
111     {num} rcslval.str = xstrdup(rcstext); return tREV;
112     [:;$] return *rcstext;
113    
114     <xID>{ws}+ ;
115     <xID>\n line_number++;
116     <xID>{special} BEGIN(INITIAL); return *rcstext;
117     <xID>{num}?{idchar}({idchar}|{num})* {
118     rcslval.str = xstrdup(rcstext);
119     BEGIN(INITIAL);
120     return tID;
121     }
122 bertho 1.3 <xID>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
123 bertho 1.1
124     <xSYM>{ws}+ ;
125     <xSYM>\n line_number++;
126     <xSYM>{special} BEGIN(INITIAL); return *rcstext;
127     <xSYM>{digit}*{idchar}({idchar}|{digit})* {
128     rcslval.str = xstrdup(rcstext);
129     BEGIN(INITIAL);
130     return tSYM;
131     }
132 bertho 1.3 <xSYM>{digit}*. rcserror("Invalid character in SYMBOL '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
133 bertho 1.1
134     @ reset_str(); BEGIN(xSTR);
135     <xSTR>[^@\n]+ add_str(rcstext, rcsleng);
136     <xSTR>\n line_number++; add_str(rcstext, rcsleng);
137     <xSTR>@@ add_str(rcstext, 1);
138     <xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
139    
140 bertho 1.4 <xAUTHOR>@ reset_str(); BEGIN(xSTR);
141     <xAUTHOR>{ws}+ ;
142     <xAUTHOR>\n line_number++;
143     <xAUTHOR>{special} BEGIN(INITIAL); return *rcstext;
144     <xAUTHOR>{num}?{idchar}({idchar}|{num})* {
145     rcslval.str = xstrdup(rcstext);
146     BEGIN(INITIAL);
147     return tID;
148     }
149     <xAUTHOR>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
150 bertho 1.1
151     {ws}+ ; /* Ignore whitespace */
152     \n line_number++;
153    
154     . rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
155    
156     %%
157    
158     int rcswrap(void)
159     {
160     return 1;
161     }
162    
163     void set_id(void)
164     {
165     BEGIN(xID);
166 bertho 1.4 }
167    
168     void set_author(void)
169     {
170     BEGIN(xAUTHOR);
171 bertho 1.1 }
172    
173     void set_sym(void)
174     {
175     BEGIN(xSYM);
176     }
177    
178     void set_skip(void)
179     {
180     BEGIN(xSKIP);
181     }
182    
183     void set_skipstr(void)
184     {
185     skip_string = 1;
186     }
187    
188     #define STRALLOCSIZE 256
189     static char *str;
190     static int nstr;
191     static int nastr;
192    
193     static void reset_str(void)
194     {
195     nstr = 0;
196     }
197    
198     static void add_str(const char *s, int l)
199     {
200     #ifdef SKIP_DELTATEXT
201     if(skip_string)
202     return;
203     #endif
204     if(nstr + l + 1 > nastr)
205     {
206     str = xrealloc(str, nastr+STRALLOCSIZE);
207     nastr += STRALLOCSIZE;
208     }
209     memcpy(str+nstr, s, l);
210     nstr += l;
211     }
212    
213     static char *get_str(void)
214     {
215     #ifdef SKIP_DELTATEXT
216     if(skip_string)
217     return xstrdup("");
218     #endif
219 bertho 1.2 if(str)
220     {
221     str[nstr] = '\0';
222     return xstrdup(str);
223     }
224     else
225     return xstrdup("");
226 bertho 1.1 }
227    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0