/** Copyright 2002 Cyril Picard This file is part of the GEDCOMParser library (developed within the Genealogy Free Software Tools project). The GEDCOMParser library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GEDCOMParser library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the GEDCOMParser library ; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ %{ #include "GEDCOMParser/DateManagement/datevalueparser_decl.hh" #include "GEDCOMParser/DateManagement/datevalueparser.h" #include #include void datevalue_error(char * const s); #define yylex datevaluelex int datevaluelex(void); #include #include GEDCOMParser::DateManagement::DateValue * _date_value; GEDCOMParser::DateManagement::Date * _date; GEDCOMParser::DateManagement::Period * _date_period; GEDCOMParser::DateManagement::Range * _date_range; GEDCOMParser::DateManagement::DatePhrase * _date_phrase; %} %token CAL_GREGORIAN %token CAL_JULIAN %token CAL_HEBREW %token CAL_FRENCH %token CAL_ROMAN %token CAL_UNKNOWN %token MONTH_JAN %token MONTH_FEB %token MONTH_MAR %token MONTH_APR %token MONTH_MAY %token MONTH_JUN %token MONTH_JUL %token MONTH_AUG %token MONTH_SEP %token MONTH_OCT %token MONTH_NOV %token MONTH_DEC %token MONTH_HEBR_TSH %token MONTH_HEBR_CSH %token MONTH_HEBR_KSL %token MONTH_HEBR_TVT %token MONTH_HEBR_SHV %token MONTH_HEBR_ADR %token MONTH_HEBR_ADS %token MONTH_HEBR_NSN %token MONTH_HEBR_IYR %token MONTH_HEBR_SVN %token MONTH_HEBR_TMZ %token MONTH_HEBR_AAV %token MONTH_HEBR_ELL %token MONTH_FREN_VEND %token MONTH_FREN_BRUM %token MONTH_FREN_FRIM %token MONTH_FREN_NIVO %token MONTH_FREN_PLUV %token MONTH_FREN_VENT %token MONTH_FREN_GERM %token MONTH_FREN_FLOR %token MONTH_FREN_PRAI %token MONTH_FREN_MESS %token MONTH_FREN_THER %token MONTH_FREN_FRUC %token MONTH_FREN_COMP %token FROM %token TO %token BEF %token AFT %token BET %token AND %token INT %token ABT %token CAL %token EST %token BC %token SLASH %token SPACE %token NUMBER %token DATEPHRASE %% date_value: date { _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_Date); _date_value->setDate(*_date); delete _date; _date = 0; } | date_period { _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_Period); _date_value->setPeriod(*_date_period); delete _date_period; _date_period = 0; } | date_range { _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_Range); _date_value->setRange(*_date_range); delete _date_range; _date_range = 0; } | date_approximated { _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_Date); _date_value->setDate(*_date); delete _date; _date = 0; } | INT date SPACE DATEPHRASE { _date_phrase = new GEDCOMParser::DateManagement::DatePhrase($4); _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_Interpreted); _date_value->setDatePhrase(*_date_phrase); _date_value->setDate(*_date); delete _date_phrase; _date_phrase = 0; delete _date; _date = 0; } | DATEPHRASE { _date_phrase = new GEDCOMParser::DateManagement::DatePhrase($1); _date_value->setType(GEDCOMParser::DateManagement::DateValue::e_DatePhrase); _date_value->setDatePhrase(*_date_phrase); delete _date_phrase; _date_phrase = 0; } ; date: date_greg | CAL_GREGORIAN date_greg | CAL_JULIAN date_juln { _date->setCalendar(GEDCOMParser::DateManagement::Date::e_Julian); } | CAL_HEBREW date_hebr { _date->setCalendar(GEDCOMParser::DateManagement::Date::e_Hebrew); } | CAL_FRENCH date_fren { _date->setCalendar(GEDCOMParser::DateManagement::Date::e_French); } | CAL_ROMAN date_future { _date->setCalendar(GEDCOMParser::DateManagement::Date::e_Unknown); } | CAL_UNKNOWN date_future { _date->setCalendar(GEDCOMParser::DateManagement::Date::e_Unknown); } ; date_greg: | NUMBER SPACE month SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setDay($1); _date->setYear($5); } | month SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($3); } | NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($1); } | date_greg SLASH NUMBER // TO DO : ACTION | date_greg BC // TO DO : ACTION ; month: MONTH_JAN { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Jan); } | MONTH_FEB { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Feb); } | MONTH_MAR { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Mar); } | MONTH_APR { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Apr); } | MONTH_MAY { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_May); } | MONTH_JUN { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Jun); } | MONTH_JUL { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Jul); } | MONTH_AUG { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Aug); } | MONTH_SEP { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Sep); } | MONTH_OCT { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Oct); } | MONTH_NOV { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Nov); } | MONTH_DEC { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Dec); } ; date_hebr: NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($1); } | month_hebr SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($3); } | NUMBER SPACE month_hebr SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setDay($1); _date->setYear($5); } ; month_hebr: MONTH_HEBR_TSH { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Tsh); } | MONTH_HEBR_CSH { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Csh); } | MONTH_HEBR_KSL { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Ksl); } | MONTH_HEBR_TVT { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Tvt); } | MONTH_HEBR_SHV { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Shv); } | MONTH_HEBR_ADR { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Adr); } | MONTH_HEBR_ADS { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Ads); } | MONTH_HEBR_NSN { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Nsn); } | MONTH_HEBR_IYR { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Iyr); } | MONTH_HEBR_SVN { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Svn); } | MONTH_HEBR_TMZ { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Tmz); } | MONTH_HEBR_AAV { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Aav); } | MONTH_HEBR_ELL { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Hebr_Ell); } ; date_juln: NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($1); } | month SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($3); } | NUMBER SPACE month SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setDay($1); _date->setYear($5); } ; date_fren: NUMBER SPACE month_fren SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setDay($1); _date->setYear($5); } | month_fren SPACE NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($3); } |NUMBER { if (_date == 0) _date = new GEDCOMParser::DateManagement::Date(); _date->setYear($1); } ; month_fren: MONTH_FREN_VEND { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Vend); } | MONTH_FREN_BRUM { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Brum); } | MONTH_FREN_FRIM { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Frim); } | MONTH_FREN_NIVO { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Nivo); } | MONTH_FREN_PLUV { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Pluv); } | MONTH_FREN_VENT { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Vent); } | MONTH_FREN_GERM { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Germ); } | MONTH_FREN_FLOR { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Flor); } | MONTH_FREN_PRAI { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Prai); } | MONTH_FREN_MESS { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Mess); } | MONTH_FREN_THER { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Ther); } | MONTH_FREN_FRUC { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Fruc); } | MONTH_FREN_COMP { if (_date == 0) { _date = new GEDCOMParser::DateManagement::Date(); } _date->setMonth(GEDCOMParser::DateManagement::Date::e_Fren_Comp); } ; date_future: DATEPHRASE { if (_date_phrase == 0) _date_phrase = new GEDCOMParser::DateManagement::DatePhrase($1); } ; date_period: date_period SPACE TO date { if (_date_period == 0) { _date_period = new GEDCOMParser::DateManagement::Period(); } _date_period->setDateTo(*_date); delete _date; _date = 0; } | FROM date { if (_date_period == 0) { _date_period = new GEDCOMParser::DateManagement::Period(); } _date_period->setDateFrom(*_date); delete _date; _date = 0; } | TO date { if (_date_period == 0) { _date_period = new GEDCOMParser::DateManagement::Period(); } _date_period->setDateTo(*_date); delete _date; _date = 0; } ; date_range: date_range AND date { if (_date_range == 0) { _date_range = new GEDCOMParser::DateManagement::Range(); } _date_range->setBound2(*_date); _date_range->setType(GEDCOMParser::DateManagement::Range::e_Between); delete _date; _date = 0; } | BEF date { if (_date_range == 0) { _date_range = new GEDCOMParser::DateManagement::Range(); } _date_range->setBound1(*_date); _date_range->setType(GEDCOMParser::DateManagement::Range::e_Before); delete _date; _date = 0; } | AFT date { if (_date_range == 0) { _date_range = new GEDCOMParser::DateManagement::Range(); } _date_range->setBound1(*_date); _date_range->setType(GEDCOMParser::DateManagement::Range::e_After); delete _date; _date = 0; } | BET date { if (_date_range == 0) { _date_range = new GEDCOMParser::DateManagement::Range(); } _date_range->setBound1(*_date); _date_range->setType(GEDCOMParser::DateManagement::Range::e_Between); delete _date; _date = 0; } ; date_approximated: ABT date { _date->setPrecision(GEDCOMParser::DateManagement::Date::e_About); } | CAL date { _date->setPrecision(GEDCOMParser::DateManagement::Date::e_Calculated); } | EST date { _date->setPrecision(GEDCOMParser::DateManagement::Date::e_Estimated); } ; %% void datevalue_error(char * const s) { std::cerr << s << std::endl; return ; } void datevalue_runparse(std::string const &s, GEDCOMParser::DateManagement::DateValue * date_value, int debug = 0) { yydebug = debug; _date = 0; _date_period = 0; _date_range = 0; _date_phrase = 0; _date_value = date_value; datevalue_scan_string(s.c_str()); datevalue_parse(); delete _date; _date = 0; delete _date_period; _date_period = 0; _date_range = 0; _date_phrase = 0; }