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

Annotate of /cvsgraph/confl.l

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


Revision 1.3 - (show annotations)
Mon Feb 26 00:09:20 2001 UTC (16 years, 9 months ago) by bertho
Branch: MAIN
Changes since 1.2: +3 -0 lines
- Fixed the recursion problem so that branches of branches are properly placed.
- Fixed a lonely '+' in an expression.
- Started to make an imagemap functionality (not very functional yet)
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 STR
23
24 %{
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <ctype.h>
29
30 #include "utils.h"
31 #include "readconf.h"
32 #include "y.tab.h"
33
34 static void reset_str(void);
35 static void add_str(const char *s, int l);
36 static char *get_str(void);
37
38 int line_number;
39
40 #define YY_NO_UNPUT 1
41
42 %}
43
44 %%
45 branch_bgcolor return tBRANCH_BGCOLOR;
46 branch_bspace return tBRANCH_BSPACE;
47 branch_color return tBRANCH_COLOR;
48 branch_font return tBRANCH_FONT;
49 branch_lspace return tBRANCH_LSPACE;
50 branch_rspace return tBRANCH_RSPACE;
51 branch_tspace return tBRANCH_TSPACE;
52 branch_separator return tBRANCH_SEPARATOR;
53 cmd_rlog return tCMD_RLOG;
54 color_bg return tCOLOR_BG;
55 cvsmodule return tCVSMODULE;
56 cvsroot return tCVSROOT;
57 rev_color return tREV_COLOR;
58 rev_font return tREV_FONT;
59 rev_separator return tREV_SEPARATOR;
60 rev_minline return tREV_MINLINE;
61 rev_maxline return tREV_MAXLINE;
62 rev_lspace return tREV_LSPACE;
63 rev_rspace return tREV_RSPACE;
64 rev_tspace return tREV_TSPACE;
65 rev_bspace return tREV_BSPACE;
66 tag_color return tTAG_COLOR;
67 tag_font return tTAG_FONT;
68 title return tTITLE;
69 title_x return tTITLE_X;
70 title_y return tTITLE_Y;
71 title_font return tTITLE_FONT;
72 title_align return tTITLE_ALIGN;
73 title_color return tTITLE_COLOR;
74 margin_top return tMARGIN_TOP;
75 margin_bottom return tMARGIN_BOTTOM;
76 margin_left return tMARGIN_LEFT;
77 margin_right return tMARGIN_RIGHT;
78 image_type return tIMAGE_TYPE;
79 image_quality return tIMAGE_QUALITY;
80 map_name return tMAP_NAME;
81 map_branch return tMAP_BRANCH;
82 map_rev return tMAP_REV;
83
84 jpeg yylval.num = IMAGE_JPEG; return tNUMBER;
85 png yylval.num = IMAGE_PNG; return tNUMBER;
86 gif yylval.num = IMAGE_GIF; return tNUMBER;
87
88 true yylval.num = 1; return tNUMBER;
89 false yylval.num = 0; return tNUMBER;
90
91 [a-zA-Z_][a-zA-Z0-9_]* yyerror("Unknown keyword '%s'", yytext);
92
93 [+-]?0[0-7]* yylval.num = strtol(yytext, NULL, 8); return tNUMBER;
94 [+-]?[1-9][0-9]* yylval.num = strtol(yytext, NULL, 10); return tNUMBER;
95 [+-]?0[xX][0-9a-fA-F]+ yylval.num = strtol(yytext, NULL, 16); return tNUMBER;
96 [+-]?0[xX] yyerror("Invalid hex number");
97
98 = return *yytext;
99 ; return *yytext;
100
101 \" reset_str(); BEGIN(STR);
102 <STR>[^\\\"\n]* add_str(yytext, yyleng);
103 <STR>\\[abfnrtv] {
104 char ch;
105 switch(yytext[1])
106 {
107 case 'a': ch = '\a'; break;
108 case 'b': ch = '\b'; break;
109 case 'f': ch = '\f'; break;
110 case 'n': ch = '\n'; break;
111 case 'r': ch = '\r'; break;
112 case 't': ch = '\t'; break;
113 case 'v': ch = '\v'; break;
114 }
115 add_str(&ch, 1);
116 }
117 <STR>\\[012][0-7]{0,2} { char ch = strtol(yytext+1, NULL, 8); add_str(&ch, 1); }
118 <STR>\\[xX][a-fA-F0-9]{2} { char ch = strtol(yytext+1, NULL, 8); add_str(&ch, 1); }
119 <STR>\\[xX][a-fA-F0-9] yyerror("Invalid hex escape");
120 <STR>\\. add_str(yytext, yyleng);
121 <STR>\n yyerror("Newline in string");
122 <STR>\" yylval.str = get_str(); BEGIN(INITIAL); return tSTRING;
123
124 [ \t\f\v]+ ; /* Ignore whitespace */
125 #[^\n]* ; /* Ignore comments */
126
127 \n line_number++;
128 . yyerror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*yytext) ? *yytext : ' ', *yytext);
129
130 %%
131
132 int yywrap(void)
133 {
134 return 1;
135 }
136
137 #define STRALLOCSIZE 128
138 static char *str;
139 static int nstr;
140 static int nastr;
141
142 static void reset_str(void)
143 {
144 nstr = 0;
145 }
146
147 static void add_str(const char *s, int l)
148 {
149 if(nstr + l + 1 > nastr)
150 {
151 str = xrealloc(str, nastr+STRALLOCSIZE);
152 nastr += STRALLOCSIZE;
153 }
154 memcpy(str+nstr, s, l);
155 nstr += l;
156 }
157
158 static char *get_str(void)
159 {
160 str[nstr] = '\0';
161 return xstrdup(str);
162 }
163

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0