fix bug 3734, 'undefined symbol error with flex-2.6.2'
[claws.git] / src / plugins / vcalendar / libical / libical / icallexer.l
1 %{
2 /* -*- Mode: C -*-
3   ======================================================================
4   FILE: icallexer.l
5   CREATOR: eric 10 June 1999
6   
7   DESCRIPTION:
8   
9   $Id$
10   $Locker$
11
12   (C) COPYRIGHT 1999 Eric Busboom 
13   http://www.softwarestudio.org
14
15   The contents of this file are subject to the Mozilla Public License
16   Version 1.0 (the "License"); you may not use this file except in
17   compliance with the License. You may obtain a copy of the License at
18   http://www.mozilla.org/MPL/
19  
20   Software distributed under the License is distributed on an "AS IS"
21   basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
22   the License for the specific language governing rights and
23   limitations under the License.
24
25   The original author is Eric Busboom
26   The original code is icalitip.y
27
28
29
30   ======================================================================*/
31 #include "icalparser.h"
32 #include "icalenums.h"
33 #include "icalmemory.h"
34 #include "assert.h"
35 #include "icalyacc.h"
36
37 #include <string.h> /* For strdup() */
38
39 int icalparser_flex_input(char* buf, int max_size);
40 void icalparser_clear_flex_input(void);
41
42
43 #define ICAL_MAX_STR_CONST 1024
44
45 #undef YY_INPUT
46 #define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
47
48 #undef YY_FATAL_ERROR
49 #define YY_FATAL_ERROR(msg) ical_yyerror(msg)
50
51 icalvalue_kind value_kind=ICAL_NO_VALUE;
52 void set_parser_value_state(icalvalue_kind kind);
53 extern int yydebug; 
54
55 void ical_yyerror(char *s);
56
57 void init_str_buf(void);
58
59 int last_state;
60
61 char *str_buf;
62 char *str_buf_p;
63 size_t buf_sz; /* = ICAL_MAX_STR_CONST;*/
64
65 %}
66
67 crlf            \x0D?\x0A
68 space           [ ]
69 qsafechar       [^\x00-\x1F\"]
70 safechar        [^\x00-\x1F\"\:\;\,]
71 tsafechar       [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E]
72 valuechar       [^\x00-\x08\x10-\x1F]
73 xname           X-[a-zA-Z0-9\-]+
74 xname2          [a-zA-Z0-9\-\ ]
75 paramtext       {safechar}+
76 value           {valuechar}+
77 quotedstring    \"{qsafechar}+\"
78 digit           [0-9]
79
80 %array /* Make yytext an array. Slow, but handy. HACK */
81
82 %option caseless
83
84 %s quoted_string
85 %s binary_value boolean_value uri_value time_value duration_value number_value period_value recur_value text_value utcoffset_value
86 %s enum_param_value string_param_value stringlist_param_value keyword line_start component seperator parameter end_of_value paramtext
87
88
89
90 %%
91
92 %{
93 %}
94
95
96
97 <time_value>{
98 {digit}+                 { ical_yylval.v_string =icalmemory_tmp_copy(yytext) ;
99                            return DIGITS; }
100 T                        { return TIME_CHAR; }
101 Z                        { return UTC_CHAR; }
102 [\/\+\-PWHMSD]           { return yytext[0]; }
103 {crlf}                   { return EOL;}
104
105 }
106
107 <utcoffset_value>{
108 {crlf}                   { return EOL;}
109 \-|\+                    { return yytext[0]; }
110 {digit}{digit}           { ical_yylval.v_int=atoi(yytext); return INTNUMBER; }
111
112 }
113
114 <enum_param_value>{
115 .                        { return CHARACTER; }
116 {crlf}                   { return EOL;}
117
118 }
119
120 <seperator>{
121 ,       { BEGIN(last_state); return COMMA; } 
122 }
123
124
125 %% 
126
127 int yywrap()
128 {
129      return 1;
130 }
131
132
133 void set_parser_value_state(icalvalue_kind kind)
134 {
135
136     switch (kind){
137
138         case ICAL_UTCOFFSET_VALUE:
139             {BEGIN(utcoffset_value);break;}
140
141         case ICAL_DATETIMEPERIOD_VALUE:
142         case ICAL_DURATION_VALUE:
143         case ICAL_PERIOD_VALUE:
144             {BEGIN(time_value);break;}
145
146         default:
147         {
148            assert(1==0);
149         }
150     }
151 }
152
153 void init_str_buf(void)
154 {
155    str_buf = icalmemory_tmp_buffer(ICAL_MAX_STR_CONST);
156    str_buf_p = str_buf;
157    buf_sz = ICAL_MAX_STR_CONST;
158
159
160 }
161