/[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.1.1.1 - (show annotations) (vendor branch)
Tue Feb 20 12:07:03 2001 UTC (16 years, 9 months ago) by bertho
Branch: CvsGraph
CVS Tags: REL_1_0_0
Changes since 1.1: +0 -0 lines
Initial import
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 "y.tab.h"
32
33 static void reset_str(void);
34 static void add_str(const char *s, int l);
35 static char *get_str(void);
36
37 int line_number;
38
39 #define YY_NO_UNPUT 1
40
41 %}
42
43 %%
44 branch_bgcolor return tBRANCH_BGCOLOR;
45 branch_bspace return tBRANCH_BSPACE;
46 branch_color return tBRANCH_COLOR;
47 branch_font return tBRANCH_FONT;
48 branch_lspace return tBRANCH_LSPACE;
49 branch_rspace return tBRANCH_RSPACE;
50 branch_tspace return tBRANCH_TSPACE;
51 branch_separator return tBRANCH_SEPARATOR;
52 cmd_rlog return tCMD_RLOG;
53 color_bg return tCOLOR_BG;
54 cvsmodule return tCVSMODULE;
55 cvsroot return tCVSROOT;
56 rev_color return tREV_COLOR;
57 rev_font return tREV_FONT;
58 rev_separator return tREV_SEPARATOR;
59 rev_minline return tREV_MINLINE;
60 rev_maxline return tREV_MAXLINE;
61 rev_lspace return tREV_LSPACE;
62 rev_rspace return tREV_RSPACE;
63 rev_tspace return tREV_TSPACE;
64 rev_bspace return tREV_BSPACE;
65 tag_color return tTAG_COLOR;
66 tag_font return tTAG_FONT;
67 title return tTITLE;
68 title_x return tTITLE_X;
69 title_y return tTITLE_Y;
70 title_font return tTITLE_FONT;
71 title_align return tTITLE_ALIGN;
72 title_color return tTITLE_COLOR;
73 margin_top return tMARGIN_TOP;
74 margin_bottom return tMARGIN_BOTTOM;
75 margin_left return tMARGIN_LEFT;
76 margin_right return tMARGIN_RIGHT;
77
78 true yylval.num = 1; return tNUMBER;
79 false yylval.num = 0; return tNUMBER;
80
81 [a-zA-Z_][a-zA-Z0-9_]* yyerror("Unknown keyword '%s'", yytext);
82
83 [+-]?0[0-7]* yylval.num = strtol(yytext, NULL, 8); return tNUMBER;
84 [+-]?[1-9][0-9]* yylval.num = strtol(yytext, NULL, 10); return tNUMBER;
85 [+-]?0[xX][0-9a-fA-F]+ yylval.num = strtol(yytext, NULL, 16); return tNUMBER;
86 [+-]?0[xX] yyerror("Invalid hex number");
87
88 = return *yytext;
89 ; return *yytext;
90
91 \" reset_str(); BEGIN(STR);
92 <STR>[^\\\"\n]* add_str(yytext, yyleng);
93 <STR>\\[abfnrtv] {
94 char ch;
95 switch(yytext[1])
96 {
97 case 'a': ch = '\a'; break;
98 case 'b': ch = '\b'; break;
99 case 'f': ch = '\f'; break;
100 case 'n': ch = '\n'; break;
101 case 'r': ch = '\r'; break;
102 case 't': ch = '\t'; break;
103 case 'v': ch = '\v'; break;
104 }
105 add_str(&ch, 1);
106 }
107 <STR>\\[012][0-7]{0,2} { char ch = strtol(yytext+1, NULL, 8); add_str(&ch, 1); }
108 <STR>\\[xX][a-fA-F0-9]{2} { char ch = strtol(yytext+1, NULL, 8); add_str(&ch, 1); }
109 <STR>\\[xX][a-fA-F0-9] yyerror("Invalid hex escape");
110 <STR>\\. add_str(yytext, yyleng);
111 <STR>\n yyerror("Newline in string");
112 <STR>\" yylval.str = get_str(); BEGIN(INITIAL); return tSTRING;
113
114 [ \t\f\v]+ ; /* Ignore whitespace */
115 #[^\n]* ; /* Ignore comments */
116
117 \n line_number++;
118 . yyerror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*yytext) ? *yytext : ' ', *yytext);
119
120 %%
121
122 int yywrap(void)
123 {
124 return 1;
125 }
126
127 #define STRALLOCSIZE 128
128 static char *str;
129 static int nstr;
130 static int nastr;
131
132 static void reset_str(void)
133 {
134 nstr = 0;
135 }
136
137 static void add_str(const char *s, int l)
138 {
139 if(nstr + l + 1 > nastr)
140 {
141 str = xrealloc(str, nastr+STRALLOCSIZE);
142 nastr += STRALLOCSIZE;
143 }
144 memcpy(str+nstr, s, l);
145 nstr += l;
146 }
147
148 static char *get_str(void)
149 {
150 str[nstr] = '\0';
151 return xstrdup(str);
152 }
153

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0