From 1efff98dbee2a6b848716acf09a68adb9246aace Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 26 Feb 2000 13:39:37 +0000 Subject: renamed a couple files so that automake will be my friend mangled the namespace of the yacc grammer so i can link this library and libversit at the same time svn path=/trunk/; revision=1964 --- libical/src/libical/.cvsignore | 6 +- libical/src/libical/Makefile.am | 17 +- libical/src/libical/icalitip.l | 283 -------------------------- libical/src/libical/icalitip.y | 434 ---------------------------------------- libical/src/libical/icalitipl.l | 283 ++++++++++++++++++++++++++ libical/src/libical/icalitipy.y | 434 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 729 insertions(+), 728 deletions(-) delete mode 100644 libical/src/libical/icalitip.l delete mode 100644 libical/src/libical/icalitip.y create mode 100644 libical/src/libical/icalitipl.l create mode 100644 libical/src/libical/icalitipy.y (limited to 'libical') diff --git a/libical/src/libical/.cvsignore b/libical/src/libical/.cvsignore index 76c7941bb2..9dc64874d6 100644 --- a/libical/src/libical/.cvsignore +++ b/libical/src/libical/.cvsignore @@ -1,7 +1,9 @@ Makefile -.deps -icalitip.c Makefile.in +icalitipy.c +icalitipy.h +icalitipl.c *.lo *.la .libs +.deps diff --git a/libical/src/libical/Makefile.am b/libical/src/libical/Makefile.am index 0457e65247..4e74c8c207 100644 --- a/libical/src/libical/Makefile.am +++ b/libical/src/libical/Makefile.am @@ -1,9 +1,9 @@ -noinst_LTLIBRARIES = libical.la +lib_LTLIBRARIES = libical.la + +CFLAGS=-g libical_la_SOURCES = \ - filelock.c \ - filelock.h \ ical.h \ icalcomponent.c \ icalcomponent.h \ @@ -12,7 +12,8 @@ libical_la_SOURCES = \ icalerror.c \ icalerror.h \ icalirip.h \ - icalitip.l \ + icalitipy.y \ + icalitipl.l \ icalmemory.c \ icalmemory.h \ icalparameter.c \ @@ -30,11 +31,9 @@ libical_la_SOURCES = \ icalvcal.h \ locking.c \ pvl.c \ - pvl.h \ - icalitip.y \ - icalitip.tab.c + pvl.h -EXTRA_DIST = .gdbinit base64.c +EXTRA_DIST = .gdbinit base64.c filelock.c filelock.h -YFLAGS=-picalparser_yy +YFLAGS=-picalparser_yy -d LFLAGS=-Picalparser_yy -olex.yy.c diff --git a/libical/src/libical/icalitip.l b/libical/src/libical/icalitip.l deleted file mode 100644 index 338c5c421f..0000000000 --- a/libical/src/libical/icalitip.l +++ /dev/null @@ -1,283 +0,0 @@ -%{ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalitip.y - CREATOR: eric 10 June 1999 - - DESCRIPTION: - - $Id: icalitip.l,v 1.2 2000/02/23 17:55:49 alves Exp $ - $Locker: $ - - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom - The original code is icalitip.y - - - - ======================================================================*/ -#include "icalitip.tab.h" -#include "icalparser.h" -#include "icalenums.h" -#include "icalmemory.h" -#include "assert.h" - -#include /* For strdup() */ - -#define ICAL_MAX_STR_CONST 1024 - -#undef YY_INPUT -#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) -#undef yywrap - -#undef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) icalparser_yyerror(msg) - -icalvalue_kind value_kind=ICAL_NO_VALUE; -void set_parser_value_state(); -extern enum icalparser_state_enum icalparser_state; -extern int yydebug; - -void icalparser_yyerror(char *s); - -void init_str_buf(); - -int last_state; - -char *str_buf; -char *str_buf_p; -size_t buf_sz; /* = ICAL_MAX_STR_CONST;*/ - - -%} - -crlf \x0D\x0A -nl \n -lbreak \x0D\x0A\x20 -ulbreak \x0A\x20 -space [ ] -qsafechar [^\x00-\x1F\"] -safechar [^\x00-\x1F\"\:\;\,] -tsafechar [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E] -valuechar [^\x00-\x08\x10-\x1F] -xname X-[a-zA-Z0-9\-]+ -xname2 [a-zA-Z0-9\-\ ] -paramtext {safechar}+ -value {valuechar}+ -quotedstring \"{qsafechar}+\" -digit [0-9] - -%array /* Make yytext an array. Slow, but handy. HACK */ - -%option caseless - - -%s quoted_string -%s binary_value boolean_value uri_value time_value duration_value number_value period_value recur_value text_value utcoffset_value -%s enum_param_value string_param_value stringlist_param_value keyword line_start component seperator parameter end_of_value paramtext - - - -%% - -%{ -%} - - -{ -.* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); - return STRING;} -{crlf}|\n { return EOL;} - -} - -{ -. { return CHARACTER; } -{crlf}|\n { return EOL;} - -} - -{ -.* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); - return STRING;} -{crlf}|\n { return EOL;} - -} - - -{ -{digit}* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); - return DIGITS; } -T { return TIME_CHAR; } -Z { return UTC_CHAR; } -{crlf}|\n { return EOL;} -} - -{ -{digit}+ { icalparser_yylval.v_string =icalmemory_tmp_copy(yytext); - return DIGITS; } -T { return TIME_CHAR; } -[\+\-PTWHMSD] { return yytext[0]; } -{crlf}|\n { return EOL;} - -} - -{ -[\+\-\.0-9]+ { icalparser_yylval.v_int=atoi(yytext); return INTNUMBER; } -{crlf}|\n { return EOL;} -} - -{ -{digit}+ { icalparser_yylval.v_string =icalmemory_tmp_copy(yytext) ; - return DIGITS; } -T { return TIME_CHAR; } -Z { return UTC_CHAR; } -[\/\+\-PWHMSD] { return yytext[0]; } -{crlf}|\n { return EOL;} - -} - -{ -INTERVAL { return INTERVAL; } -COUNT { return COUNT; } -UNTIL { return UNTIL; } -FREQ { return FREQ; } -BYDAY { return BYDAY; } -BYHOUR { return BYHOUR; } -BYMINUTE { return BYMINUTE; } -BYMONTH { return BYMONTH; } -BYMONTHDAY { return BYMONTHDAY; } -BYSECOND { return BYSECOND; } -BYSETPOS { return BYSETPOS; } -BYWEEKNO { return BYWEEKNO; } -BYYEARDAY { return BYYEARDAY; } -DAILY { return DAILY; } -SECONDLY { return SECONDLY; } -MINUTELY { return MINUTELY; } -HOURLY { return HOURLY; } -MONTHLY { return MONTHLY; } -WEEKLY { return WEEKLY; } -YEARLY { return YEARLY; } -WKST { return WKST; } -MO { return MO; } -SA { return SA; } -SU { return SU; } -TU { return TU; } -WE { return WE; } -TH { return TH; } -FR { return FR; } -= { return EQUALS; } -, { return COMMA; } -; { return SEMICOLON; } -[\-\+0-9]+ { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); - return DIGITS; } -T { return TIME_CHAR; } -Z { return UTC_CHAR; } -{crlf}|\n { return EOL;} -} - -{ -{crlf}|\n { return EOL;} -\-|\+ { return yytext[0]; } -{digit}{digit} { icalparser_yylval.v_int=atoi(yytext); return INTNUMBER; } - -} - -{ -. { return CHARACTER; } -{crlf}|\n { return EOL;} - -} - -{ -, { BEGIN(last_state); return COMMA; } -} - - -%% - -int yywrap() -{ - return 1; -} - - -void set_parser_value_state(icalvalue_kind kind) -{ - - switch (kind){ - - case ICAL_ATTACH_VALUE: - case ICAL_BINARY_VALUE: - {BEGIN(binary_value);break;} - - case ICAL_BOOLEAN_VALUE: - case ICAL_INTEGER_VALUE: - case ICAL_FLOAT_VALUE: - {BEGIN(number_value);break;} - - case ICAL_UTCOFFSET_VALUE: - {BEGIN(utcoffset_value);break;} - - case ICAL_TEXT_VALUE: - {BEGIN(text_value); - init_str_buf(); - break;} - - case ICAL_CALADDRESS_VALUE: - case ICAL_URI_VALUE: - {BEGIN(uri_value);break;} - - case ICAL_DATE_VALUE: - case ICAL_DATETIME_VALUE: - case ICAL_DATETIMEDATE_VALUE: - case ICAL_DATETIMEPERIOD_VALUE: - case ICAL_TIME_VALUE: - {BEGIN(time_value);break;} - - case ICAL_DURATION_VALUE: - {BEGIN(duration_value);break;} - - case ICAL_PERIOD_VALUE: - {BEGIN(period_value);break;} - - case ICAL_GEO_VALUE: - case ICAL_QUERY_VALUE: - {BEGIN(text_value);break;} - - case ICAL_RECUR_VALUE: - {BEGIN(recur_value);break;} - - case ICAL_NO_VALUE: - { - /* The value is probably actually a component name */ - {BEGIN(component); break;} - } - default: - { - assert(1==0); - } - } -} - -void init_str_buf() -{ - str_buf = icalmemory_tmp_buffer(ICAL_MAX_STR_CONST); - str_buf_p = str_buf; - buf_sz = ICAL_MAX_STR_CONST; - - -} - diff --git a/libical/src/libical/icalitip.y b/libical/src/libical/icalitip.y deleted file mode 100644 index 8e4f16b553..0000000000 --- a/libical/src/libical/icalitip.y +++ /dev/null @@ -1,434 +0,0 @@ -%{ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalitip.y - CREATOR: eric 10 June 1999 - - DESCRIPTION: - - $Id: icalitip.y,v 1.1.1.2 2000/02/21 13:19:26 alves Exp $ - $Locker: $ - - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom - The original code is icalitip.y - - - - ================================b======================================*/ - -#include -#include /* for strdup() */ -#include /* for SHRT_MAX*/ -#include "icalparser.h" -#include "ical.h" -#include "pvl.h" - -#define YYERROR_VERBOSE -#define YYDEBUG 1 - -icalvalue *icalparser_yy_value; /* Current Value */ - -/* Globals for UTCOFFSET values */ -int utc; -int utc_b; -int utcsign; - -/* Globals for DURATION values */ -struct icaldurationtype duration; - -/* Globals for RECUR values */ -struct icalrecurrencetype recur; -short skiplist[367]; -short skippos; - -void copy_list(short* array, size_t size); -void clear_recur(); -void add_prop(icalproperty_kind); -void icalparser_fill_date(struct tm* t, char* dstr); -void icalparser_fill_time(struct tm* t, char* tstr); -void set_value_type(icalvalue_kind kind); -void yyerror(char *s); /* Don't know why I need this.... */ -int yylex(void); /* Or this. */ -void set_parser_value_state(); -struct icaltimetype fill_datetime(char* d, char* t); - - - -/* Set the state of the lexer so it will interpret values ( iCAL - VALUEs, that is, ) correctly. */ - -%} - -%union { - float v_float; - int v_int; - char* v_string; - -} - -%token DIGITS -%token INTNUMBER -%token FLOATNUMBER -%token STRING -%token EOL EQUALS CHARACTER COLON COMMA SEMICOLON TIMESEPERATOR - -%token TRUE FALSE - -%token FREQ BYDAY BYHOUR BYMINUTE BYMONTH BYMONTHDAY BYSECOND BYSETPOS BYWEEKNO -%token BYYEARDAY DAILY MINUTELY MONTHLY SECONDLY WEEKLY HOURLY YEARLY -%token INTERVAL COUNT UNTIL WKST MO SA SU TU WE TH FR - -%token BIT8 ACCEPTED ADD AUDIO BASE64 BINARY BOOLEAN BUSY BUSYTENTATIVE -%token BUSYUNAVAILABLE CALADDRESS CANCEL CANCELLED CHAIR CHILD COMPLETED -%token CONFIDENTIAL CONFIRMED COUNTER DATE DATETIME DECLINECOUNTER DECLINED -%token DELEGATED DISPLAY DRAFT DURATION EMAIL END FINAL FLOAT FREE GREGORIAN -%token GROUP INDIVIDUAL INPROCESS INTEGER NEEDSACTION NONPARTICIPANT -%token OPAQUE OPTPARTICIPANT PARENT PERIOD PRIVATE PROCEDURE PUBLIC PUBLISH -%token RECUR REFRESH REPLY REQPARTICIPANT REQUEST RESOURCE ROOM SIBLING -%token START TENTATIVE TEXT THISANDFUTURE THISANDPRIOR TIME TRANSPAENT -%token UNKNOWN UTCOFFSET XNAME - -%token ALTREP CN CUTYPE DAYLIGHT DIR ENCODING EVENT FBTYPE FMTTYPE LANGUAGE -%token MEMBER PARTSTAT RANGE RELATED RELTYPE ROLE RSVP SENTBY STANDARD URI - -%token TIME_CHAR UTC_CHAR - - -%% - -value: - binary_value - | boolean_value - | date_value - | datetime_value - | duration_value - | period_value - | recur_value - | utcoffset_value - | error { - icalparser_yy_value = 0; - icalparser_clear_flex_input(); - yyclearin; - } - -binary_value: "unimplemented2" - -boolean_value: - TRUE - { icalparser_yy_value = icalvalue_new_boolean(1); } - | FALSE - { icalparser_yy_value = icalvalue_new_boolean(0); } - -date_value: DIGITS - { - struct icaltimetype stm; - - stm = fill_datetime($1,0); - - stm.hour = -1; - stm.minute = -1; - stm.second = -1; - stm.is_utc = 0; - stm.is_date = 1; - - icalparser_yy_value = icalvalue_new_date(stm); - } - -utc_char: - /*empty*/ {utc = 0;} - | UTC_CHAR {utc = 1;} - -/* This is used in the period_value, where there may be two utc characters per rule. */ -utc_char_b: - /*empty*/ {utc_b = 0;} - | UTC_CHAR {utc_b = 1;} - -datetime_value: - DIGITS TIME_CHAR DIGITS utc_char - { - struct icaltimetype stm; - stm = fill_datetime($1, $3); - stm.is_utc = utc; - stm.is_date = 0; - - icalparser_yy_value = - icalvalue_new_datetime(stm); - } - - -/* Duration */ - - -dur_date: dur_day - | dur_day dur_time - -dur_week: DIGITS 'W' - { - duration.weeks = atoi($1); - } - -dur_time: TIME_CHAR dur_hour - { - } - | TIME_CHAR dur_minute - { - } - | TIME_CHAR dur_second - { - } - -dur_hour: DIGITS 'H' - { - duration.hours = atoi($1); - } - | DIGITS 'H' dur_minute - { - duration.hours = atoi($1); - } - -dur_minute: DIGITS 'M' - { - duration.minutes = atoi($1); - } - | DIGITS 'M' dur_second - { - duration.minutes = atoi($1); - } - -dur_second: DIGITS 'S' - { - duration.seconds = atoi($1); - } - -dur_day: DIGITS 'D' - { - duration.days = atoi($1); - } - -dur_prefix: /* empty */ - { - } - | '+' - { - } - | '-' - { - } - -duration_value: dur_prefix 'P' dur_date - { - icalparser_yy_value = icalvalue_new_duration(duration); - memset(&duration,0, sizeof(duration)); - } - | dur_prefix 'P' dur_time - { - icalparser_yy_value = icalvalue_new_duration(duration); - memset(&duration,0, sizeof(duration)); - } - | dur_prefix 'P' dur_week - { - icalparser_yy_value = icalvalue_new_duration(duration); - memset(&duration,0, sizeof(duration)); - } - - -/* Period */ - -period_value: DIGITS TIME_CHAR DIGITS utc_char '/' DIGITS TIME_CHAR DIGITS utc_char_b - { - struct icalperiodtype p; - - p.start = fill_datetime($1,$3); - p.start.is_utc = utc; - p.start.is_date = 0; - - - p.end = fill_datetime($6,$8); - p.end.is_utc = utc_b; - p.end.is_date = 0; - - p.duration.days = -1; - p.duration.weeks = -1; - p.duration.hours = -1; - p.duration.minutes = -1; - p.duration.seconds = -1; - - icalparser_yy_value = icalvalue_new_period(p); - } - | DIGITS TIME_CHAR DIGITS utc_char '/' duration_value - { - struct icalperiodtype p; - - p.start = fill_datetime($1,$3); - p.start.is_utc = utc; - p.start.is_date = 0; - - p.end.year = -1; - p.end.month = -1; - p.end.day = -1; - p.end.hour = -1; - p.end.minute = -1; - p.end.second = -1; - - /* The duration_value rule setes the global 'duration' - variable, but it also creates a new value in - icalparser_yy_value. So, free that, then copy - 'duration' into the icalperiodtype struct. */ - - p.duration = icalvalue_get_duration(icalparser_yy_value); - icalvalue_free(icalparser_yy_value); - icalparser_yy_value = 0; - - icalparser_yy_value = icalvalue_new_period(p); - - } - - - -/* Recur */ - -recur_start: - FREQ EQUALS SECONDLY {clear_recur();recur.freq = ICAL_SECONDLY_RECURRENCE;} - | FREQ EQUALS MINUTELY {clear_recur();recur.freq = ICAL_MINUTELY_RECURRENCE;} - | FREQ EQUALS HOURLY {clear_recur();recur.freq = ICAL_HOURLY_RECURRENCE;} - | FREQ EQUALS DAILY {clear_recur();recur.freq = ICAL_DAILY_RECURRENCE;} - | FREQ EQUALS WEEKLY {clear_recur();recur.freq = ICAL_WEEKLY_RECURRENCE;} - | FREQ EQUALS MONTHLY {clear_recur();recur.freq = ICAL_MONTHLY_RECURRENCE;} - | FREQ EQUALS YEARLY {clear_recur();recur.freq = ICAL_YEARLY_RECURRENCE;} - ; - - -weekday: - SU { skiplist[skippos]=ICAL_SUNDAY_WEEKDAY; if( skippos<8) skippos++;} - | MO { skiplist[skippos]=ICAL_MONDAY_WEEKDAY;if( skippos<8) skippos++;} - | TU { skiplist[skippos]=ICAL_TUESDAY_WEEKDAY;if( skippos<8) skippos++;} - | WE { skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY;if( skippos<8) skippos++;} - | TH { skiplist[skippos]=ICAL_THURSDAY_WEEKDAY;if( skippos<8) skippos++;} - | FR { skiplist[skippos]=ICAL_FRIDAY_WEEKDAY;if( skippos<8) skippos++;} - | SA { skiplist[skippos]=ICAL_SATURDAY_WEEKDAY;if( skippos<8) skippos++;} - ; - - -weekday_list: - weekday - | DIGITS weekday { } /* HACK Incorectly handles int in BYDAY */ - | weekday_list COMMA weekday - - -recur_list: - DIGITS { skiplist[skippos] = atoi($1); skippos++;} - | recur_list COMMA DIGITS { skiplist[skippos] = atoi($3); if (skippos<367) skippos++;} - ; - -recur_skip: - INTERVAL EQUALS DIGITS {recur.interval = atoi($3);} - | WKST EQUALS SU {recur.week_start = ICAL_SUNDAY_WEEKDAY;} - | WKST EQUALS MO {recur.week_start = ICAL_MONDAY_WEEKDAY;} - | WKST EQUALS TU {recur.week_start = ICAL_TUESDAY_WEEKDAY;} - | WKST EQUALS WE {recur.week_start = ICAL_WEDNESDAY_WEEKDAY;} - | WKST EQUALS TH {recur.week_start = ICAL_THURSDAY_WEEKDAY;} - | WKST EQUALS FR {recur.week_start = ICAL_FRIDAY_WEEKDAY;} - | WKST EQUALS SA {recur.week_start = ICAL_SATURDAY_WEEKDAY;} - | BYSECOND EQUALS recur_list{copy_list(recur.by_second,60);} - | BYMINUTE EQUALS recur_list{copy_list(recur.by_minute,60);} - | BYHOUR EQUALS recur_list{copy_list(recur.by_hour,24);} - | BYDAY EQUALS weekday_list{copy_list(recur.by_day,7);} - | BYMONTH EQUALS recur_list{copy_list(recur.by_month,12);} - | BYMONTHDAY EQUALS recur_list{copy_list(recur.by_month_day,31);} - | BYYEARDAY EQUALS recur_list{copy_list(recur.by_year_day,366);} - | BYWEEKNO EQUALS recur_list{copy_list(recur.by_week_no,53);} - | BYSETPOS EQUALS recur_list{copy_list(recur.by_set_pos,366);} - | UNTIL EQUALS datetime_value - { recur.until = icalvalue_get_datetime(icalparser_yy_value); - icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;} - | UNTIL EQUALS date_value - { recur.until = icalvalue_get_date(icalparser_yy_value); - icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;} - | COUNT EQUALS DIGITS - { recur.count = atoi($3); } - ; - -recur_skip_list: - /* empty */ - | recur_skip_list SEMICOLON recur_skip - -recur_value: - recur_start recur_skip_list - { icalparser_yy_value = icalvalue_new_recur(recur); } - - - -/* UTC Offset */ - -plusminus: '+' { utcsign = 1; } - | '-' { utcsign = -1; } - -utcoffset_value: - plusminus INTNUMBER INTNUMBER - { - icalparser_yy_value = icalvalue_new_utcoffset( utcsign * ($2*3600) + ($3*60) ); - } - - | plusminus INTNUMBER INTNUMBER INTNUMBER - { - icalparser_yy_value = icalvalue_new_utcoffset(utcsign * ($2*3600) + ($3*60) +($4)); - } - - - -%% - - -void clear_recur() -{ - memset(&skiplist, ICAL_RECURRENCE_ARRAY_MAX_BYTE, sizeof(skiplist)); - skippos = 0; - - icalrecurrencetype_clear(&recur); -} - -void copy_list(short* array, size_t size) -{ - memcpy(array, skiplist, size*sizeof(short)); - memset(&skiplist,ICAL_RECURRENCE_ARRAY_MAX_BYTE, sizeof(skiplist)); - skippos = 0; -} - -struct icaltimetype fill_datetime(char* datestr, char* timestr) -{ - struct icaltimetype stm; - - memset(&stm,0,sizeof(stm)); - - if (datestr != 0){ - sscanf(datestr,"%4d%2d%2d",&(stm.year), &(stm.month), - &(stm.day)); - } - - if (timestr != 0){ - sscanf(timestr,"%2d%2d%2d", &(stm.hour), &(stm.minute), - &(stm.second)); - } - - return stm; - -} - -void yyerror(char* s) -{ - /*fprintf(stderr,"Parse error \'%s\'\n", s);*/ -} - diff --git a/libical/src/libical/icalitipl.l b/libical/src/libical/icalitipl.l new file mode 100644 index 0000000000..5ca5adc18a --- /dev/null +++ b/libical/src/libical/icalitipl.l @@ -0,0 +1,283 @@ +%{ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalitip.y + CREATOR: eric 10 June 1999 + + DESCRIPTION: + + $Id: icalitipl.l,v 1.1 2000/02/26 13:39:37 alves Exp $ + $Locker: $ + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + The original author is Eric Busboom + The original code is icalitip.y + + + + ======================================================================*/ +#include "icalitipy.h" +#include "icalparser.h" +#include "icalenums.h" +#include "icalmemory.h" +#include "assert.h" + +#include /* For strdup() */ + +#define ICAL_MAX_STR_CONST 1024 + +#undef YY_INPUT +#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) +#undef yywrap + +#undef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) icalparser_yyerror(msg) + +icalvalue_kind value_kind=ICAL_NO_VALUE; +void set_parser_value_state(); +extern enum icalparser_state_enum icalparser_state; +extern int yydebug; + +void icalparser_yyerror(char *s); + +void init_str_buf(); + +int last_state; + +char *str_buf; +char *str_buf_p; +size_t buf_sz; /* = ICAL_MAX_STR_CONST;*/ + + +%} + +crlf \x0D\x0A +nl \n +lbreak \x0D\x0A\x20 +ulbreak \x0A\x20 +space [ ] +qsafechar [^\x00-\x1F\"] +safechar [^\x00-\x1F\"\:\;\,] +tsafechar [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E] +valuechar [^\x00-\x08\x10-\x1F] +xname X-[a-zA-Z0-9\-]+ +xname2 [a-zA-Z0-9\-\ ] +paramtext {safechar}+ +value {valuechar}+ +quotedstring \"{qsafechar}+\" +digit [0-9] + +%array /* Make yytext an array. Slow, but handy. HACK */ + +%option caseless + + +%s quoted_string +%s binary_value boolean_value uri_value time_value duration_value number_value period_value recur_value text_value utcoffset_value +%s enum_param_value string_param_value stringlist_param_value keyword line_start component seperator parameter end_of_value paramtext + + + +%% + +%{ +%} + + +{ +.* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); + return STRING;} +{crlf}|\n { return EOL;} + +} + +{ +. { return CHARACTER; } +{crlf}|\n { return EOL;} + +} + +{ +.* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); + return STRING;} +{crlf}|\n { return EOL;} + +} + + +{ +{digit}* { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); + return DIGITS; } +T { return TIME_CHAR; } +Z { return UTC_CHAR; } +{crlf}|\n { return EOL;} +} + +{ +{digit}+ { icalparser_yylval.v_string =icalmemory_tmp_copy(yytext); + return DIGITS; } +T { return TIME_CHAR; } +[\+\-PTWHMSD] { return yytext[0]; } +{crlf}|\n { return EOL;} + +} + +{ +[\+\-\.0-9]+ { icalparser_yylval.v_int=atoi(yytext); return INTNUMBER; } +{crlf}|\n { return EOL;} +} + +{ +{digit}+ { icalparser_yylval.v_string =icalmemory_tmp_copy(yytext) ; + return DIGITS; } +T { return TIME_CHAR; } +Z { return UTC_CHAR; } +[\/\+\-PWHMSD] { return yytext[0]; } +{crlf}|\n { return EOL;} + +} + +{ +INTERVAL { return INTERVAL; } +COUNT { return COUNT; } +UNTIL { return UNTIL; } +FREQ { return FREQ; } +BYDAY { return BYDAY; } +BYHOUR { return BYHOUR; } +BYMINUTE { return BYMINUTE; } +BYMONTH { return BYMONTH; } +BYMONTHDAY { return BYMONTHDAY; } +BYSECOND { return BYSECOND; } +BYSETPOS { return BYSETPOS; } +BYWEEKNO { return BYWEEKNO; } +BYYEARDAY { return BYYEARDAY; } +DAILY { return DAILY; } +SECONDLY { return SECONDLY; } +MINUTELY { return MINUTELY; } +HOURLY { return HOURLY; } +MONTHLY { return MONTHLY; } +WEEKLY { return WEEKLY; } +YEARLY { return YEARLY; } +WKST { return WKST; } +MO { return MO; } +SA { return SA; } +SU { return SU; } +TU { return TU; } +WE { return WE; } +TH { return TH; } +FR { return FR; } += { return EQUALS; } +, { return COMMA; } +; { return SEMICOLON; } +[\-\+0-9]+ { icalparser_yylval.v_string= icalmemory_tmp_copy(yytext); + return DIGITS; } +T { return TIME_CHAR; } +Z { return UTC_CHAR; } +{crlf}|\n { return EOL;} +} + +{ +{crlf}|\n { return EOL;} +\-|\+ { return yytext[0]; } +{digit}{digit} { icalparser_yylval.v_int=atoi(yytext); return INTNUMBER; } + +} + +{ +. { return CHARACTER; } +{crlf}|\n { return EOL;} + +} + +{ +, { BEGIN(last_state); return COMMA; } +} + + +%% + +int yywrap() +{ + return 1; +} + + +void set_parser_value_state(icalvalue_kind kind) +{ + + switch (kind){ + + case ICAL_ATTACH_VALUE: + case ICAL_BINARY_VALUE: + {BEGIN(binary_value);break;} + + case ICAL_BOOLEAN_VALUE: + case ICAL_INTEGER_VALUE: + case ICAL_FLOAT_VALUE: + {BEGIN(number_value);break;} + + case ICAL_UTCOFFSET_VALUE: + {BEGIN(utcoffset_value);break;} + + case ICAL_TEXT_VALUE: + {BEGIN(text_value); + init_str_buf(); + break;} + + case ICAL_CALADDRESS_VALUE: + case ICAL_URI_VALUE: + {BEGIN(uri_value);break;} + + case ICAL_DATE_VALUE: + case ICAL_DATETIME_VALUE: + case ICAL_DATETIMEDATE_VALUE: + case ICAL_DATETIMEPERIOD_VALUE: + case ICAL_TIME_VALUE: + {BEGIN(time_value);break;} + + case ICAL_DURATION_VALUE: + {BEGIN(duration_value);break;} + + case ICAL_PERIOD_VALUE: + {BEGIN(period_value);break;} + + case ICAL_GEO_VALUE: + case ICAL_QUERY_VALUE: + {BEGIN(text_value);break;} + + case ICAL_RECUR_VALUE: + {BEGIN(recur_value);break;} + + case ICAL_NO_VALUE: + { + /* The value is probably actually a component name */ + {BEGIN(component); break;} + } + default: + { + assert(1==0); + } + } +} + +void init_str_buf() +{ + str_buf = icalmemory_tmp_buffer(ICAL_MAX_STR_CONST); + str_buf_p = str_buf; + buf_sz = ICAL_MAX_STR_CONST; + + +} + diff --git a/libical/src/libical/icalitipy.y b/libical/src/libical/icalitipy.y new file mode 100644 index 0000000000..220d61fff0 --- /dev/null +++ b/libical/src/libical/icalitipy.y @@ -0,0 +1,434 @@ +%{ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalitip.y + CREATOR: eric 10 June 1999 + + DESCRIPTION: + + $Id: icalitipy.y,v 1.1 2000/02/26 13:39:37 alves Exp $ + $Locker: $ + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + The original author is Eric Busboom + The original code is icalitip.y + + + + ================================b======================================*/ + +#include +#include /* for strdup() */ +#include /* for SHRT_MAX*/ +#include "icalparser.h" +#include "ical.h" +#include "pvl.h" + +#define YYERROR_VERBOSE +#define YYDEBUG 1 + +icalvalue *icalparser_yy_value; /* Current Value */ + +/* Globals for UTCOFFSET values */ +int utc; +int utc_b; +int utcsign; + +/* Globals for DURATION values */ +struct icaldurationtype duration; + +/* Globals for RECUR values */ +struct icalrecurrencetype recur; +short skiplist[367]; +short skippos; + +void copy_list(short* array, size_t size); +void clear_recur(); +void add_prop(icalproperty_kind); +void icalparser_fill_date(struct tm* t, char* dstr); +void icalparser_fill_time(struct tm* t, char* tstr); +void set_value_type(icalvalue_kind kind); +void yyerror(char *s); /* Don't know why I need this.... */ +int yylex(void); /* Or this. */ +void set_parser_value_state(); +struct icaltimetype fill_datetime(char* d, char* t); + + + +/* Set the state of the lexer so it will interpret values ( iCAL + VALUEs, that is, ) correctly. */ + +%} + +%union { + float v_float; + int v_int; + char* v_string; + +} + +%token DIGITS +%token INTNUMBER +%token FLOATNUMBER +%token STRING +%token EOL EQUALS CHARACTER COLON COMMA SEMICOLON TIMESEPERATOR + +%token TRUE FALSE + +%token FREQ BYDAY BYHOUR BYMINUTE BYMONTH BYMONTHDAY BYSECOND BYSETPOS BYWEEKNO +%token BYYEARDAY DAILY MINUTELY MONTHLY SECONDLY WEEKLY HOURLY YEARLY +%token INTERVAL COUNT UNTIL WKST MO SA SU TU WE TH FR + +%token BIT8 ACCEPTED ADD AUDIO BASE64 BINARY BOOLEAN BUSY BUSYTENTATIVE +%token BUSYUNAVAILABLE CALADDRESS CANCEL CANCELLED CHAIR CHILD COMPLETED +%token CONFIDENTIAL CONFIRMED COUNTER DATE DATETIME DECLINECOUNTER DECLINED +%token DELEGATED DISPLAY DRAFT DURATION EMAIL END FINAL FLOAT FREE GREGORIAN +%token GROUP INDIVIDUAL INPROCESS INTEGER NEEDSACTION NONPARTICIPANT +%token OPAQUE OPTPARTICIPANT PARENT PERIOD PRIVATE PROCEDURE PUBLIC PUBLISH +%token RECUR REFRESH REPLY REQPARTICIPANT REQUEST RESOURCE ROOM SIBLING +%token START TENTATIVE TEXT THISANDFUTURE THISANDPRIOR TIME TRANSPAENT +%token UNKNOWN UTCOFFSET XNAME + +%token ALTREP CN CUTYPE DAYLIGHT DIR ENCODING EVENT FBTYPE FMTTYPE LANGUAGE +%token MEMBER PARTSTAT RANGE RELATED RELTYPE ROLE RSVP SENTBY STANDARD URI + +%token TIME_CHAR UTC_CHAR + + +%% + +value: + binary_value + | boolean_value + | date_value + | datetime_value + | duration_value + | period_value + | recur_value + | utcoffset_value + | error { + icalparser_yy_value = 0; + icalparser_clear_flex_input(); + yyclearin; + } + +binary_value: "unimplemented2" + +boolean_value: + TRUE + { icalparser_yy_value = icalvalue_new_boolean(1); } + | FALSE + { icalparser_yy_value = icalvalue_new_boolean(0); } + +date_value: DIGITS + { + struct icaltimetype stm; + + stm = fill_datetime($1,0); + + stm.hour = -1; + stm.minute = -1; + stm.second = -1; + stm.is_utc = 0; + stm.is_date = 1; + + icalparser_yy_value = icalvalue_new_date(stm); + } + +utc_char: + /*empty*/ {utc = 0;} + | UTC_CHAR {utc = 1;} + +/* This is used in the period_value, where there may be two utc characters per rule. */ +utc_char_b: + /*empty*/ {utc_b = 0;} + | UTC_CHAR {utc_b = 1;} + +datetime_value: + DIGITS TIME_CHAR DIGITS utc_char + { + struct icaltimetype stm; + stm = fill_datetime($1, $3); + stm.is_utc = utc; + stm.is_date = 0; + + icalparser_yy_value = + icalvalue_new_datetime(stm); + } + + +/* Duration */ + + +dur_date: dur_day + | dur_day dur_time + +dur_week: DIGITS 'W' + { + duration.weeks = atoi($1); + } + +dur_time: TIME_CHAR dur_hour + { + } + | TIME_CHAR dur_minute + { + } + | TIME_CHAR dur_second + { + } + +dur_hour: DIGITS 'H' + { + duration.hours = atoi($1); + } + | DIGITS 'H' dur_minute + { + duration.hours = atoi($1); + } + +dur_minute: DIGITS 'M' + { + duration.minutes = atoi($1); + } + | DIGITS 'M' dur_second + { + duration.minutes = atoi($1); + } + +dur_second: DIGITS 'S' + { + duration.seconds = atoi($1); + } + +dur_day: DIGITS 'D' + { + duration.days = atoi($1); + } + +dur_prefix: /* empty */ + { + } + | '+' + { + } + | '-' + { + } + +duration_value: dur_prefix 'P' dur_date + { + icalparser_yy_value = icalvalue_new_duration(duration); + memset(&duration,0, sizeof(duration)); + } + | dur_prefix 'P' dur_time + { + icalparser_yy_value = icalvalue_new_duration(duration); + memset(&duration,0, sizeof(duration)); + } + | dur_prefix 'P' dur_week + { + icalparser_yy_value = icalvalue_new_duration(duration); + memset(&duration,0, sizeof(duration)); + } + + +/* Period */ + +period_value: DIGITS TIME_CHAR DIGITS utc_char '/' DIGITS TIME_CHAR DIGITS utc_char_b + { + struct icalperiodtype p; + + p.start = fill_datetime($1,$3); + p.start.is_utc = utc; + p.start.is_date = 0; + + + p.end = fill_datetime($6,$8); + p.end.is_utc = utc_b; + p.end.is_date = 0; + + p.duration.days = -1; + p.duration.weeks = -1; + p.duration.hours = -1; + p.duration.minutes = -1; + p.duration.seconds = -1; + + icalparser_yy_value = icalvalue_new_period(p); + } + | DIGITS TIME_CHAR DIGITS utc_char '/' duration_value + { + struct icalperiodtype p; + + p.start = fill_datetime($1,$3); + p.start.is_utc = utc; + p.start.is_date = 0; + + p.end.year = -1; + p.end.month = -1; + p.end.day = -1; + p.end.hour = -1; + p.end.minute = -1; + p.end.second = -1; + + /* The duration_value rule setes the global 'duration' + variable, but it also creates a new value in + icalparser_yy_value. So, free that, then copy + 'duration' into the icalperiodtype struct. */ + + p.duration = icalvalue_get_duration(icalparser_yy_value); + icalvalue_free(icalparser_yy_value); + icalparser_yy_value = 0; + + icalparser_yy_value = icalvalue_new_period(p); + + } + + + +/* Recur */ + +recur_start: + FREQ EQUALS SECONDLY {clear_recur();recur.freq = ICAL_SECONDLY_RECURRENCE;} + | FREQ EQUALS MINUTELY {clear_recur();recur.freq = ICAL_MINUTELY_RECURRENCE;} + | FREQ EQUALS HOURLY {clear_recur();recur.freq = ICAL_HOURLY_RECURRENCE;} + | FREQ EQUALS DAILY {clear_recur();recur.freq = ICAL_DAILY_RECURRENCE;} + | FREQ EQUALS WEEKLY {clear_recur();recur.freq = ICAL_WEEKLY_RECURRENCE;} + | FREQ EQUALS MONTHLY {clear_recur();recur.freq = ICAL_MONTHLY_RECURRENCE;} + | FREQ EQUALS YEARLY {clear_recur();recur.freq = ICAL_YEARLY_RECURRENCE;} + ; + + +weekday: + SU { skiplist[skippos]=ICAL_SUNDAY_WEEKDAY; if( skippos<8) skippos++;} + | MO { skiplist[skippos]=ICAL_MONDAY_WEEKDAY;if( skippos<8) skippos++;} + | TU { skiplist[skippos]=ICAL_TUESDAY_WEEKDAY;if( skippos<8) skippos++;} + | WE { skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY;if( skippos<8) skippos++;} + | TH { skiplist[skippos]=ICAL_THURSDAY_WEEKDAY;if( skippos<8) skippos++;} + | FR { skiplist[skippos]=ICAL_FRIDAY_WEEKDAY;if( skippos<8) skippos++;} + | SA { skiplist[skippos]=ICAL_SATURDAY_WEEKDAY;if( skippos<8) skippos++;} + ; + + +weekday_list: + weekday + | DIGITS weekday { } /* HACK Incorectly handles int in BYDAY */ + | weekday_list COMMA weekday + + +recur_list: + DIGITS { skiplist[skippos] = atoi($1); skippos++;} + | recur_list COMMA DIGITS { skiplist[skippos] = atoi($3); if (skippos<367) skippos++;} + ; + +recur_skip: + INTERVAL EQUALS DIGITS {recur.interval = atoi($3);} + | WKST EQUALS SU {recur.week_start = ICAL_SUNDAY_WEEKDAY;} + | WKST EQUALS MO {recur.week_start = ICAL_MONDAY_WEEKDAY;} + | WKST EQUALS TU {recur.week_start = ICAL_TUESDAY_WEEKDAY;} + | WKST EQUALS WE {recur.week_start = ICAL_WEDNESDAY_WEEKDAY;} + | WKST EQUALS TH {recur.week_start = ICAL_THURSDAY_WEEKDAY;} + | WKST EQUALS FR {recur.week_start = ICAL_FRIDAY_WEEKDAY;} + | WKST EQUALS SA {recur.week_start = ICAL_SATURDAY_WEEKDAY;} + | BYSECOND EQUALS recur_list{copy_list(recur.by_second,60);} + | BYMINUTE EQUALS recur_list{copy_list(recur.by_minute,60);} + | BYHOUR EQUALS recur_list{copy_list(recur.by_hour,24);} + | BYDAY EQUALS weekday_list{copy_list(recur.by_day,7);} + | BYMONTH EQUALS recur_list{copy_list(recur.by_month,12);} + | BYMONTHDAY EQUALS recur_list{copy_list(recur.by_month_day,31);} + | BYYEARDAY EQUALS recur_list{copy_list(recur.by_year_day,366);} + | BYWEEKNO EQUALS recur_list{copy_list(recur.by_week_no,53);} + | BYSETPOS EQUALS recur_list{copy_list(recur.by_set_pos,366);} + | UNTIL EQUALS datetime_value + { recur.until = icalvalue_get_datetime(icalparser_yy_value); + icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;} + | UNTIL EQUALS date_value + { recur.until = icalvalue_get_date(icalparser_yy_value); + icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;} + | COUNT EQUALS DIGITS + { recur.count = atoi($3); } + ; + +recur_skip_list: + /* empty */ + | recur_skip_list SEMICOLON recur_skip + +recur_value: + recur_start recur_skip_list + { icalparser_yy_value = icalvalue_new_recur(recur); } + + + +/* UTC Offset */ + +plusminus: '+' { utcsign = 1; } + | '-' { utcsign = -1; } + +utcoffset_value: + plusminus INTNUMBER INTNUMBER + { + icalparser_yy_value = icalvalue_new_utcoffset( utcsign * ($2*3600) + ($3*60) ); + } + + | plusminus INTNUMBER INTNUMBER INTNUMBER + { + icalparser_yy_value = icalvalue_new_utcoffset(utcsign * ($2*3600) + ($3*60) +($4)); + } + + + +%% + + +void clear_recur() +{ + memset(&skiplist, ICAL_RECURRENCE_ARRAY_MAX_BYTE, sizeof(skiplist)); + skippos = 0; + + icalrecurrencetype_clear(&recur); +} + +void copy_list(short* array, size_t size) +{ + memcpy(array, skiplist, size*sizeof(short)); + memset(&skiplist,ICAL_RECURRENCE_ARRAY_MAX_BYTE, sizeof(skiplist)); + skippos = 0; +} + +struct icaltimetype fill_datetime(char* datestr, char* timestr) +{ + struct icaltimetype stm; + + memset(&stm,0,sizeof(stm)); + + if (datestr != 0){ + sscanf(datestr,"%4d%2d%2d",&(stm.year), &(stm.month), + &(stm.day)); + } + + if (timestr != 0){ + sscanf(timestr,"%2d%2d%2d", &(stm.hour), &(stm.minute), + &(stm.second)); + } + + return stm; + +} + +void yyerror(char* s) +{ + /*fprintf(stderr,"Parse error \'%s\'\n", s);*/ +} + -- cgit v1.2.3