/[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.6 - (hide annotations)
Thu Oct 21 21:40:35 2004 UTC (13 years ago) by bertho
Branch: MAIN
CVS Tags: REL_1_5_1
Changes since 1.5: +5 -0 lines
- Remove warning on known extended phrases
- Add known CVSNT extended phrases to be ignored
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.1
93     /* Here come any other 'newphrase' constructs */
94     {num}?{idchar}({idchar}|{num})* {
95     rcslval.str = xstrdup(rcstext);
96     return tNEWPHRASE;
97     }
98    
99     /* Special rules for skipping everything after a 'newphrase' part */
100     <xSKIP>[^;@\n]+ ;
101     <xSKIP>\n line_number++;
102     <xSKIP>@ BEGIN(xSKIPSTR);
103     <xSKIP>; BEGIN(INITIAL); return *rcstext;
104    
105     <xSKIPSTR>[^\n@]+ ;
106     <xSKIPSTR>\n line_number++;
107     <xSKIPSTR>@@ ;
108     <xSKIPSTR>@ BEGIN(xSKIP);
109    
110     {num} rcslval.str = xstrdup(rcstext); return tREV;
111     [:;$] return *rcstext;
112    
113     <xID>{ws}+ ;
114     <xID>\n line_number++;
115     <xID>{special} BEGIN(INITIAL); return *rcstext;
116     <xID>{num}?{idchar}({idchar}|{num})* {
117     rcslval.str = xstrdup(rcstext);
118     BEGIN(INITIAL);
119     return tID;
120     }
121 bertho 1.3 <xID>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
122 bertho 1.1
123     <xSYM>{ws}+ ;
124     <xSYM>\n line_number++;
125     <xSYM>{special} BEGIN(INITIAL); return *rcstext;
126     <xSYM>{digit}*{idchar}({idchar}|{digit})* {
127     rcslval.str = xstrdup(rcstext);
128     BEGIN(INITIAL);
129     return tSYM;
130     }
131 bertho 1.3 <xSYM>{digit}*. rcserror("Invalid character in SYMBOL '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
132 bertho 1.1
133     @ reset_str(); BEGIN(xSTR);
134     <xSTR>[^@\n]+ add_str(rcstext, rcsleng);
135     <xSTR>\n line_number++; add_str(rcstext, rcsleng);
136     <xSTR>@@ add_str(rcstext, 1);
137     <xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
138    
139 bertho 1.4 <xAUTHOR>@ reset_str(); BEGIN(xSTR);
140     <xAUTHOR>{ws}+ ;
141     <xAUTHOR>\n line_number++;
142     <xAUTHOR>{special} BEGIN(INITIAL); return *rcstext;
143     <xAUTHOR>{num}?{idchar}({idchar}|{num})* {
144     rcslval.str = xstrdup(rcstext);
145     BEGIN(INITIAL);
146     return tID;
147     }
148     <xAUTHOR>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
149 bertho 1.1
150     {ws}+ ; /* Ignore whitespace */
151     \n line_number++;
152    
153     . rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
154    
155     %%
156    
157     int rcswrap(void)
158     {
159     return 1;
160     }
161    
162     void set_id(void)
163     {
164     BEGIN(xID);
165 bertho 1.4 }
166    
167     void set_author(void)
168     {
169     BEGIN(xAUTHOR);
170 bertho 1.1 }
171    
172     void set_sym(void)
173     {
174     BEGIN(xSYM);
175     }
176    
177     void set_skip(void)
178     {
179     BEGIN(xSKIP);
180     }
181    
182     void set_skipstr(void)
183     {
184     skip_string = 1;
185     }
186    
187     #define STRALLOCSIZE 256
188     static char *str;
189     static int nstr;
190     static int nastr;
191    
192     static void reset_str(void)
193     {
194     nstr = 0;
195     }
196    
197     static void add_str(const char *s, int l)
198     {
199     #ifdef SKIP_DELTATEXT
200     if(skip_string)
201     return;
202     #endif
203     if(nstr + l + 1 > nastr)
204     {
205     str = xrealloc(str, nastr+STRALLOCSIZE);
206     nastr += STRALLOCSIZE;
207     }
208     memcpy(str+nstr, s, l);
209     nstr += l;
210     }
211    
212     static char *get_str(void)
213     {
214     #ifdef SKIP_DELTATEXT
215     if(skip_string)
216     return xstrdup("");
217     #endif
218 bertho 1.2 if(str)
219     {
220     str[nstr] = '\0';
221     return xstrdup(str);
222     }
223     else
224     return xstrdup("");
225 bertho 1.1 }
226    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0