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

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0