1 /* Lexer for Gedcom dates
2 Copyright (C) 2001 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
6 The Gedcom parser library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The Gedcom parser library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the Gedcom parser library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 #include "gedcom_date.tab.h"
30 static char buf[MAX_DATE_TOKEN][MAX_PHRASE_LEN+1];
31 static int token_nr = 0;
34 %option case-insensitive
41 #define SIMPLE_RETURN(TOKEN) \
42 { if (token_nr >= MAX_DATE_TOKEN) { \
43 gedcom_date_error(_("Date token stack overflow")); \
46 memset(buf[token_nr], 0, MAX_PHRASE_LEN+1); \
47 strncpy(buf[token_nr], yytext, yyleng); \
48 gedcom_date_lval.string = buf[token_nr++]; \
53 [ \t]+ /* ignore whitespace between tokens */
55 @#DGREGORIAN@ SIMPLE_RETURN(ESC_DATE_GREG)
56 @#DJULIAN@ SIMPLE_RETURN(ESC_DATE_JULN)
57 @#DHEBREW@ SIMPLE_RETURN(ESC_DATE_HEBR)
58 "@#DFRENCH R@" SIMPLE_RETURN(ESC_DATE_FREN)
60 FROM SIMPLE_RETURN(MOD_FROM)
61 TO SIMPLE_RETURN(MOD_TO)
62 BEF SIMPLE_RETURN(MOD_BEF)
63 AFT SIMPLE_RETURN(MOD_AFT)
64 BET SIMPLE_RETURN(MOD_BET)
65 AND SIMPLE_RETURN(MOD_AND)
66 ABT SIMPLE_RETURN(MOD_ABT)
67 CAL SIMPLE_RETURN(MOD_CAL)
68 EST SIMPLE_RETURN(MOD_EST)
69 INT SIMPLE_RETURN(MOD_INT)
71 JAN SIMPLE_RETURN(MON_JAN)
72 FEB SIMPLE_RETURN(MON_FEB)
73 MAR SIMPLE_RETURN(MON_MAR)
74 APR SIMPLE_RETURN(MON_APR)
75 MAY SIMPLE_RETURN(MON_MAY)
76 JUN SIMPLE_RETURN(MON_JUN)
77 JUL SIMPLE_RETURN(MON_JUL)
78 AUG SIMPLE_RETURN(MON_AUG)
79 SEP SIMPLE_RETURN(MON_SEP)
80 OCT SIMPLE_RETURN(MON_OCT)
81 NOV SIMPLE_RETURN(MON_NOV)
82 DEC SIMPLE_RETURN(MON_DEC)
83 TSH SIMPLE_RETURN(MON_TSH)
84 CSH SIMPLE_RETURN(MON_CSH)
85 KSL SIMPLE_RETURN(MON_KSL)
86 TVT SIMPLE_RETURN(MON_TVT)
87 SHV SIMPLE_RETURN(MON_SHV)
88 ADR SIMPLE_RETURN(MON_ADR)
89 ADS SIMPLE_RETURN(MON_ADS)
90 NSN SIMPLE_RETURN(MON_NSN)
91 IYR SIMPLE_RETURN(MON_IYR)
92 SVN SIMPLE_RETURN(MON_SVN)
93 TMZ SIMPLE_RETURN(MON_TMZ)
94 AAV SIMPLE_RETURN(MON_AAV)
95 ELL SIMPLE_RETURN(MON_ELL)
96 VEND SIMPLE_RETURN(MON_VEND)
97 BRUM SIMPLE_RETURN(MON_BRUM)
98 FRIM SIMPLE_RETURN(MON_FRIM)
99 NIVO SIMPLE_RETURN(MON_NIVO)
100 PLUV SIMPLE_RETURN(MON_PLUV)
101 VENT SIMPLE_RETURN(MON_VENT)
102 GERM SIMPLE_RETURN(MON_GERM)
103 FLOR SIMPLE_RETURN(MON_FLOR)
104 PRAI SIMPLE_RETURN(MON_PRAI)
105 MESS SIMPLE_RETURN(MON_MESS)
106 THER SIMPLE_RETURN(MON_THER)
107 FRUC SIMPLE_RETURN(MON_FRUC)
108 COMP SIMPLE_RETURN(MON_COMP)
113 <PHRASE>[^\)]* SIMPLE_RETURN(TEXT);
114 <PHRASE>")" { BEGIN(INITIAL);
115 SIMPLE_RETURN(CLOSE);
118 "/" SIMPLE_RETURN(SLASH)
119 [0-9]+ SIMPLE_RETURN(NUMBER)
128 static YY_BUFFER_STATE hndl;
130 void init_gedcom_date_lex(char* string)
133 hndl = yy_scan_string(string);
136 void close_gedcom_date_lex()
138 yy_delete_buffer(hndl);