Diffstat (limited to 'libical/src/libical/icallexer.l') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icallexer.l | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/libical/src/libical/icallexer.l b/libical/src/libical/icallexer.l new file mode 100644 index 0000000..53b396a --- a/dev/null +++ b/libical/src/libical/icallexer.l | |||
@@ -0,0 +1,170 @@ | |||
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 | #include <stdlib.h> | ||
39 | #include <math.h> | ||
40 | |||
41 | int icalparser_flex_input(char* buf, int max_size); | ||
42 | void icalparser_clear_flex_input(void); | ||
43 | |||
44 | |||
45 | #define ICAL_MAX_STR_CONST 1024 | ||
46 | |||
47 | #undef YY_INPUT | ||
48 | #define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) | ||
49 | #undef yywrap | ||
50 | |||
51 | #undef YY_FATAL_ERROR | ||
52 | #define YY_FATAL_ERROR(msg) ical_yyerror(msg) | ||
53 | |||
54 | icalvalue_kind value_kind=ICAL_NO_VALUE; | ||
55 | void set_parser_value_state(icalvalue_kind kind); | ||
56 | extern int yydebug; | ||
57 | |||
58 | void ical_yyerror(char *s); | ||
59 | |||
60 | void init_str_buf(void); | ||
61 | |||
62 | int last_state; | ||
63 | |||
64 | char *str_buf; | ||
65 | char *str_buf_p; | ||
66 | size_t buf_sz; /* = ICAL_MAX_STR_CONST;*/ | ||
67 | |||
68 | /* Define routines that were not propertly defined because of the | ||
69 | renaming hack applied in icalyacc.y */ | ||
70 | YY_BUFFER_STATE ical_yy_scan_buffer ( char *base, yy_size_t size ); | ||
71 | YY_BUFFER_STATE ical_yy_scan_string ( yyconst char *yy_str ); | ||
72 | YY_BUFFER_STATE ical_yy_scan_bytes ( yyconst char *bytes, int len ); | ||
73 | |||
74 | %} | ||
75 | |||
76 | crlf \x0D?\x0A | ||
77 | space [ ] | ||
78 | qsafechar[^\x00-\x1F\"] | ||
79 | safechar[^\x00-\x1F\"\:\;\,] | ||
80 | tsafechar[\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E] | ||
81 | valuechar[^\x00-\x08\x10-\x1F] | ||
82 | xname X-[a-zA-Z0-9\-]+ | ||
83 | xname2 [a-zA-Z0-9\-\ ] | ||
84 | paramtext{safechar}+ | ||
85 | value {valuechar}+ | ||
86 | quotedstring\"{qsafechar}+\" | ||
87 | digit [0-9] | ||
88 | |||
89 | %array /* Make yytext an array. Slow, but handy. HACK */ | ||
90 | |||
91 | %option caseless | ||
92 | |||
93 | %s quoted_string | ||
94 | %s binary_value boolean_value uri_value time_value duration_value number_value period_value recur_value text_value utcoffset_value | ||
95 | %s enum_param_value string_param_value stringlist_param_value keyword line_start component seperator parameter end_of_value paramtext | ||
96 | |||
97 | |||
98 | |||
99 | %% | ||
100 | |||
101 | %{ | ||
102 | %} | ||
103 | |||
104 | |||
105 | |||
106 | <time_value>{ | ||
107 | {digit}+ { ical_yylval.v_string =icalmemory_tmp_copy(yytext) ; | ||
108 | return DIGITS; } | ||
109 | T { return TIME_CHAR; } | ||
110 | Z { return UTC_CHAR; } | ||
111 | [\/\+\-PWHMSD] { return yytext[0]; } | ||
112 | {crlf} { return EOL;} | ||
113 | |||
114 | } | ||
115 | |||
116 | <utcoffset_value>{ | ||
117 | {crlf} { return EOL;} | ||
118 | \-|\+ { return yytext[0]; } | ||
119 | {digit}{digit} { ical_yylval.v_int=atoi(yytext); return INTNUMBER; } | ||
120 | |||
121 | } | ||
122 | |||
123 | <enum_param_value>{ | ||
124 | . { return CHARACTER; } | ||
125 | {crlf} { return EOL;} | ||
126 | |||
127 | } | ||
128 | |||
129 | <seperator>{ | ||
130 | , { BEGIN(last_state); return COMMA; } | ||
131 | } | ||
132 | |||
133 | |||
134 | %% | ||
135 | |||
136 | int yywrap() | ||
137 | { | ||
138 | return 1; | ||
139 | } | ||
140 | |||
141 | |||
142 | void set_parser_value_state(icalvalue_kind kind) | ||
143 | { | ||
144 | |||
145 | switch (kind){ | ||
146 | |||
147 | case ICAL_UTCOFFSET_VALUE: | ||
148 | {BEGIN(utcoffset_value);break;} | ||
149 | |||
150 | case ICAL_DATETIMEPERIOD_VALUE: | ||
151 | case ICAL_DURATION_VALUE: | ||
152 | case ICAL_PERIOD_VALUE: | ||
153 | {BEGIN(time_value);break;} | ||
154 | |||
155 | default: | ||
156 | { | ||
157 | assert(1==0); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
162 | void init_str_buf(void) | ||
163 | { | ||
164 | str_buf = icalmemory_tmp_buffer(ICAL_MAX_STR_CONST); | ||
165 | str_buf_p = str_buf; | ||
166 | buf_sz = ICAL_MAX_STR_CONST; | ||
167 | |||
168 | |||
169 | } | ||
170 | |||