summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Doxyfile10
-rw-r--r--Makefile.am10
-rw-r--r--Makefile.in97
-rw-r--r--acconf.h.in4
-rw-r--r--amount.cc2
-rwxr-xr-xconfigure321
-rw-r--r--configure.in9
-rw-r--r--docs/date-examples.txt36
-rw-r--r--gnucash.cc2
-rw-r--r--parsetime.cc1914
-rw-r--r--parsetime.h67
-rw-r--r--parsetime.yy272
-rw-r--r--qif.cc2
-rw-r--r--scantime.cc1577
-rw-r--r--scantime.ll29
-rw-r--r--tests/corelib/numerics/DateTime.cc122
-rw-r--r--textual.cc13
-rw-r--r--times.cc88
-rw-r--r--times.h64
-rw-r--r--xmlparse.cc4
-rwxr-xr-xylwrap223
21 files changed, 4737 insertions, 129 deletions
diff --git a/Doxyfile b/Doxyfile
index 220b5fd6..a03b54d4 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -37,7 +37,7 @@ TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
-BUILTIN_STL_SUPPORT = NO
+BUILTIN_STL_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
@@ -175,12 +175,12 @@ TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
+GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
+PAPER_TYPE = usletter
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
@@ -245,13 +245,13 @@ PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = NO
+CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
-UML_LOOK = NO
+UML_LOOK = YES
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
diff --git a/Makefile.am b/Makefile.am
index 408b1ed0..3b84ae37 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,10 +17,15 @@ if HAVE_BOOST_PYTHON
lib_LTLIBRARIES += libpyledger.la
endif
+AM_YFLAGS = -d
+AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
+
libledger_la_CXXFLAGS = $(WARNFLAGS) -I$(top_builddir)/gdtoa
libledger_la_SOURCES = \
amount.cc \
times.cc \
+ parsetime.yy \
+ scantime.ll \
quotes.cc \
balance.cc \
value.cc \
@@ -84,6 +89,7 @@ libpyledger_la_LDFLAGS = -release 3.0
pkginclude_HEADERS = \
amount.h \
times.h \
+ parsetime.h \
balance.h \
binary.h \
csv.h \
@@ -124,7 +130,8 @@ bin_PROGRAMS = ledger
ledger_CXXFLAGS =
ledger_SOURCES = option.cc main.cc
-ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la
+ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la $(LEXLIB)
+
if HAVE_EXPAT
ledger_CXXFLAGS += -DHAVE_EXPAT=1
endif
@@ -206,6 +213,7 @@ UnitTests_SOURCES = tests/UnitTests.cc \
\
tests/corelib/numerics/BasicAmount.cc \
tests/corelib/numerics/CommodityAmount.cc \
+ tests/corelib/numerics/DateTime.cc \
tests/corelib/numerics/Commodity.cc
UnitTests_LDADD = $(lib_LTLIBRARIES) gdtoa/libgdtoa.la -lcppunit
diff --git a/Makefile.in b/Makefile.in
index c81693fc..562f2c18 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -69,7 +69,8 @@ DIST_COMMON = README $(am__configure_deps) $(pkginclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/acconf.h.in $(top_srcdir)/configure AUTHORS COPYING \
ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \
- elisp-comp install-sh ltmain.sh missing texinfo.tex
+ elisp-comp install-sh ltmain.sh missing parsetime.cc \
+ parsetime.h scantime.cc texinfo.tex ylwrap
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -91,17 +92,19 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libledger_la_LIBADD =
-am__libledger_la_SOURCES_DIST = amount.cc times.cc quotes.cc \
- balance.cc value.cc xml.cc xpath.cc mask.cc format.cc util.cc \
- session.cc journal.cc parser.cc textual.cc binary.cc \
- xmlparse.cc qif.cc report.cc transform.cc csv.cc derive.cc \
- emacs.cc reconcile.cc gnucash.cc ofx.cc debug.cc trace.cc
+am__libledger_la_SOURCES_DIST = amount.cc times.cc parsetime.yy \
+ scantime.ll quotes.cc balance.cc value.cc xml.cc xpath.cc \
+ mask.cc format.cc util.cc session.cc journal.cc parser.cc \
+ textual.cc binary.cc xmlparse.cc qif.cc report.cc transform.cc \
+ csv.cc derive.cc emacs.cc reconcile.cc gnucash.cc ofx.cc \
+ debug.cc trace.cc
@HAVE_EXPAT_TRUE@am__objects_1 = libledger_la-gnucash.lo
@HAVE_XMLPARSE_TRUE@am__objects_2 = libledger_la-gnucash.lo
@HAVE_LIBOFX_TRUE@am__objects_3 = libledger_la-ofx.lo
@DEBUG_TRUE@am__objects_4 = libledger_la-debug.lo \
@DEBUG_TRUE@ libledger_la-trace.lo
am_libledger_la_OBJECTS = libledger_la-amount.lo libledger_la-times.lo \
+ libledger_la-parsetime.lo libledger_la-scantime.lo \
libledger_la-quotes.lo libledger_la-balance.lo \
libledger_la-value.lo libledger_la-xml.lo \
libledger_la-xpath.lo libledger_la-mask.lo \
@@ -137,7 +140,7 @@ PyUnitTests_LDADD = $(LDADD)
am_UnitTests_OBJECTS = UnitTests-UnitTests.$(OBJEXT) \
UnitTests-BasicAmount.$(OBJEXT) \
UnitTests-CommodityAmount.$(OBJEXT) \
- UnitTests-Commodity.$(OBJEXT)
+ UnitTests-DateTime.$(OBJEXT) UnitTests-Commodity.$(OBJEXT)
UnitTests_OBJECTS = $(am_UnitTests_OBJECTS)
UnitTests_DEPENDENCIES = $(lib_LTLIBRARIES) gdtoa/libgdtoa.la
UnitTests_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -145,8 +148,9 @@ UnitTests_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(CXXFLAGS) $(UnitTests_LDFLAGS) $(LDFLAGS) -o $@
am_ledger_OBJECTS = ledger-option.$(OBJEXT) ledger-main.$(OBJEXT)
ledger_OBJECTS = $(am_ledger_OBJECTS)
+am__DEPENDENCIES_1 =
ledger_DEPENDENCIES = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la \
- $(am__append_16)
+ $(am__DEPENDENCIES_1) $(am__append_16)
ledger_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(ledger_CXXFLAGS) $(CXXFLAGS) \
$(ledger_LDFLAGS) $(LDFLAGS) -o $@
@@ -166,6 +170,13 @@ CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = $(top_srcdir)/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS)
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -261,6 +272,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
@@ -286,6 +300,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -349,15 +365,17 @@ ESC_builddir = `echo "$(top_builddir)" | sed 's/\//\\\\\//g'`
ESC_distdir = `echo "$(distdir)" | sed 's/\//\\\\\//g'`
EXTRA_DIST = docs tests ledger.pdf ledger.info
lib_LTLIBRARIES = libledger.la $(am__append_1)
+AM_YFLAGS = -d
+AM_LFLAGS = -o $(LEX_OUTPUT_ROOT).c
libledger_la_CXXFLAGS = $(WARNFLAGS) -I$(top_builddir)/gdtoa \
$(am__append_2) $(am__append_4) $(am__append_6) \
$(am__append_8) $(am__append_10)
-libledger_la_SOURCES = amount.cc times.cc quotes.cc balance.cc \
- value.cc xml.cc xpath.cc mask.cc format.cc util.cc session.cc \
- journal.cc parser.cc textual.cc binary.cc xmlparse.cc qif.cc \
- report.cc transform.cc csv.cc derive.cc emacs.cc reconcile.cc \
- $(am__append_3) $(am__append_5) $(am__append_7) \
- $(am__append_9)
+libledger_la_SOURCES = amount.cc times.cc parsetime.yy scantime.ll \
+ quotes.cc balance.cc value.cc xml.cc xpath.cc mask.cc \
+ format.cc util.cc session.cc journal.cc parser.cc textual.cc \
+ binary.cc xmlparse.cc qif.cc report.cc transform.cc csv.cc \
+ derive.cc emacs.cc reconcile.cc $(am__append_3) \
+ $(am__append_5) $(am__append_7) $(am__append_9)
libledger_la_LDFLAGS = -release 3.0
libpyledger_la_CXXFLAGS = -DUSE_BOOST_PYTHON=1 $(am__append_11)
libpyledger_la_SOURCES = \
@@ -368,6 +386,7 @@ libpyledger_la_LDFLAGS = -release 3.0
pkginclude_HEADERS = \
amount.h \
times.h \
+ parsetime.h \
balance.h \
binary.h \
csv.h \
@@ -405,7 +424,7 @@ pkginclude_HEADERS = \
ledger_CXXFLAGS = $(am__append_12) $(am__append_13) $(am__append_14) \
$(am__append_15) $(am__append_17)
ledger_SOURCES = option.cc main.cc
-ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la \
+ledger_LDADD = $(LIBOBJS) libledger.la gdtoa/libgdtoa.la $(LEXLIB) \
$(am__append_16)
ledger_LDFLAGS = -static # for the sake of command-line speed
info_TEXINFOS = ledger.texi
@@ -422,6 +441,7 @@ UnitTests_SOURCES = tests/UnitTests.cc \
\
tests/corelib/numerics/BasicAmount.cc \
tests/corelib/numerics/CommodityAmount.cc \
+ tests/corelib/numerics/DateTime.cc \
tests/corelib/numerics/Commodity.cc
UnitTests_LDADD = $(lib_LTLIBRARIES) gdtoa/libgdtoa.la -lcppunit
@@ -433,7 +453,7 @@ all: acconf.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
-.SUFFIXES: .cc .dvi .html .info .lo .o .obj .pdf .ps .texi
+.SUFFIXES: .cc .dvi .html .info .ll .lo .o .obj .pdf .ps .texi .yy
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@@ -511,6 +531,11 @@ clean-libLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
+parsetime.h: parsetime.cc
+ @if test ! -f $@; then \
+ rm -f parsetime.cc; \
+ $(MAKE) $(AM_MAKEFLAGS) parsetime.cc; \
+ else :; fi
libledger.la: $(libledger_la_OBJECTS) $(libledger_la_DEPENDENCIES)
$(libledger_la_LINK) -rpath $(libdir) $(libledger_la_OBJECTS) $(libledger_la_LIBADD) $(LIBS)
libpyledger.la: $(libpyledger_la_OBJECTS) $(libpyledger_la_DEPENDENCIES)
@@ -576,6 +601,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnitTests-BasicAmount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnitTests-Commodity.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnitTests-CommodityAmount.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnitTests-DateTime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnitTests-UnitTests.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ledger-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ledger-option.Po@am__quote@
@@ -592,10 +618,12 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-mask.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-ofx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-parser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-parsetime.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-qif.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-quotes.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-reconcile.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-report.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-scantime.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-session.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-textual.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libledger_la-times.Plo@am__quote@
@@ -645,6 +673,20 @@ libledger_la-times.lo: times.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-times.lo `test -f 'times.cc' || echo '$(srcdir)/'`times.cc
+libledger_la-parsetime.lo: parsetime.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-parsetime.lo -MD -MP -MF $(DEPDIR)/libledger_la-parsetime.Tpo -c -o libledger_la-parsetime.lo `test -f 'parsetime.cc' || echo '$(srcdir)/'`parsetime.cc
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-parsetime.Tpo $(DEPDIR)/libledger_la-parsetime.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='parsetime.cc' object='libledger_la-parsetime.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-parsetime.lo `test -f 'parsetime.cc' || echo '$(srcdir)/'`parsetime.cc
+
+libledger_la-scantime.lo: scantime.cc
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-scantime.lo -MD -MP -MF $(DEPDIR)/libledger_la-scantime.Tpo -c -o libledger_la-scantime.lo `test -f 'scantime.cc' || echo '$(srcdir)/'`scantime.cc
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-scantime.Tpo $(DEPDIR)/libledger_la-scantime.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='scantime.cc' object='libledger_la-scantime.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-scantime.lo `test -f 'scantime.cc' || echo '$(srcdir)/'`scantime.cc
+
libledger_la-quotes.lo: quotes.cc
@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-quotes.lo -MD -MP -MF $(DEPDIR)/libledger_la-quotes.Tpo -c -o libledger_la-quotes.lo `test -f 'quotes.cc' || echo '$(srcdir)/'`quotes.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-quotes.Tpo $(DEPDIR)/libledger_la-quotes.Plo
@@ -876,6 +918,20 @@ UnitTests-CommodityAmount.obj: tests/corelib/numerics/CommodityAmount.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -c -o UnitTests-CommodityAmount.obj `if test -f 'tests/corelib/numerics/CommodityAmount.cc'; then $(CYGPATH_W) 'tests/corelib/numerics/CommodityAmount.cc'; else $(CYGPATH_W) '$(srcdir)/tests/corelib/numerics/CommodityAmount.cc'; fi`
+UnitTests-DateTime.o: tests/corelib/numerics/DateTime.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -MT UnitTests-DateTime.o -MD -MP -MF $(DEPDIR)/UnitTests-DateTime.Tpo -c -o UnitTests-DateTime.o `test -f 'tests/corelib/numerics/DateTime.cc' || echo '$(srcdir)/'`tests/corelib/numerics/DateTime.cc
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/UnitTests-DateTime.Tpo $(DEPDIR)/UnitTests-DateTime.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tests/corelib/numerics/DateTime.cc' object='UnitTests-DateTime.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -c -o UnitTests-DateTime.o `test -f 'tests/corelib/numerics/DateTime.cc' || echo '$(srcdir)/'`tests/corelib/numerics/DateTime.cc
+
+UnitTests-DateTime.obj: tests/corelib/numerics/DateTime.cc
+@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -MT UnitTests-DateTime.obj -MD -MP -MF $(DEPDIR)/UnitTests-DateTime.Tpo -c -o UnitTests-DateTime.obj `if test -f 'tests/corelib/numerics/DateTime.cc'; then $(CYGPATH_W) 'tests/corelib/numerics/DateTime.cc'; else $(CYGPATH_W) '$(srcdir)/tests/corelib/numerics/DateTime.cc'; fi`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/UnitTests-DateTime.Tpo $(DEPDIR)/UnitTests-DateTime.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tests/corelib/numerics/DateTime.cc' object='UnitTests-DateTime.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -c -o UnitTests-DateTime.obj `if test -f 'tests/corelib/numerics/DateTime.cc'; then $(CYGPATH_W) 'tests/corelib/numerics/DateTime.cc'; else $(CYGPATH_W) '$(srcdir)/tests/corelib/numerics/DateTime.cc'; fi`
+
UnitTests-Commodity.o: tests/corelib/numerics/Commodity.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(UnitTests_CXXFLAGS) $(CXXFLAGS) -MT UnitTests-Commodity.o -MD -MP -MF $(DEPDIR)/UnitTests-Commodity.Tpo -c -o UnitTests-Commodity.o `test -f 'tests/corelib/numerics/Commodity.cc' || echo '$(srcdir)/'`tests/corelib/numerics/Commodity.cc
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/UnitTests-Commodity.Tpo $(DEPDIR)/UnitTests-Commodity.Po
@@ -918,6 +974,12 @@ ledger-main.obj: main.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ledger_CXXFLAGS) $(CXXFLAGS) -c -o ledger-main.obj `if test -f 'main.cc'; then $(CYGPATH_W) 'main.cc'; else $(CYGPATH_W) '$(srcdir)/main.cc'; fi`
+.ll.cc:
+ $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.yy.cc:
+ $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
mostlyclean-libtool:
-rm -f *.lo
@@ -1523,6 +1585,9 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
+ -rm -f parsetime.cc
+ -rm -f parsetime.h
+ -rm -f scantime.cc
@HAVE_BOOST_PYTHON_FALSE@install-exec-hook:
clean: clean-recursive
diff --git a/acconf.h.in b/acconf.h.in
index e1f233dd..9c64213f 100644
--- a/acconf.h.in
+++ b/acconf.h.in
@@ -81,5 +81,9 @@
/* Version number of package */
#undef VERSION
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+#undef YYTEXT_POINTER
+
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
diff --git a/amount.cc b/amount.cc
index 7b294026..5d2cdccd 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1172,7 +1172,7 @@ bool parse_annotations(std::istream& in, amount_t& price,
else
throw new amount_error("Commodity date lacks closing bracket");
- date = ptime_from_local_date_string(buf);
+ date = parse_datetime(buf);
has_date = true;
}
else if (c == '(') {
diff --git a/configure b/configure
index 68e439e5..2c3280fc 100755
--- a/configure
+++ b/configure
@@ -872,6 +872,11 @@ F77
FFLAGS
ac_ct_F77
LIBTOOL
+YACC
+YFLAGS
+LEX
+LEX_OUTPUT_ROOT
+LEXLIB
EMACS
EMACSLOADPATH
lispdir
@@ -918,6 +923,8 @@ CPP
CXXCPP
F77
FFLAGS
+YACC
+YFLAGS
EMACS
EMACSLOADPATH'
ac_subdirs_all='gdtoa'
@@ -1534,6 +1541,11 @@ Some influential environment variables:
CXXCPP C++ preprocessor
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
+ YACC The `Yet Another C Compiler' implementation to use. Defaults to
+ the first program found out of: `bison -y', `byacc', `yacc'.
+ YFLAGS The list of arguments that will be passed by default to $YACC.
+ This script will default YFLAGS to the empty string to avoid a
+ default value of `-d' given by some make applications.
EMACS the Emacs editor command
EMACSLOADPATH
the Emacs library search path
@@ -4848,7 +4860,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4851 "configure"' > conftest.$ac_ext
+ echo '#line 4863 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -7107,11 +7119,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7110: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7122: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7114: \$? = $ac_status" >&5
+ echo "$as_me:7126: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7375,11 +7387,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7378: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7390: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7382: \$? = $ac_status" >&5
+ echo "$as_me:7394: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7479,11 +7491,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7482: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7494: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7486: \$? = $ac_status" >&5
+ echo "$as_me:7498: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9787,7 +9799,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9790 "configure"
+#line 9802 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9887,7 +9899,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9890 "configure"
+#line 9902 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12223,11 +12235,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12226: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12238: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12230: \$? = $ac_status" >&5
+ echo "$as_me:12242: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -12327,11 +12339,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12330: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12342: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12334: \$? = $ac_status" >&5
+ echo "$as_me:12346: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -13897,11 +13909,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13900: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13912: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13904: \$? = $ac_status" >&5
+ echo "$as_me:13916: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -14001,11 +14013,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14004: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14016: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14008: \$? = $ac_status" >&5
+ echo "$as_me:14020: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16199,11 +16211,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16202: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16214: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16206: \$? = $ac_status" >&5
+ echo "$as_me:16218: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16467,11 +16479,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16470: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16482: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16474: \$? = $ac_status" >&5
+ echo "$as_me:16486: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16571,11 +16583,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16574: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16586: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16578: \$? = $ac_status" >&5
+ echo "$as_me:16590: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -19235,6 +19247,262 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+for ac_prog in 'bison -y' byacc
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_YACC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$YACC"; then
+ ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_YACC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+YACC=$ac_cv_prog_YACC
+if test -n "$YACC"; then
+ { echo "$as_me:$LINENO: result: $YACC" >&5
+echo "${ECHO_T}$YACC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="yacc"
+
+
+for ac_prog in flex lex
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_LEX+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$LEX"; then
+ ac_cv_prog_LEX="$LEX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_LEX="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+LEX=$ac_cv_prog_LEX
+if test -n "$LEX"; then
+ { echo "$as_me:$LINENO: result: $LEX" >&5
+echo "${ECHO_T}$LEX" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ test -n "$LEX" && break
+done
+test -n "$LEX" || LEX=":"
+
+if test "x$LEX" != "x:"; then
+ cat >conftest.l <<_ACEOF
+%%
+a { ECHO; }
+b { REJECT; }
+c { yymore (); }
+d { yyless (1); }
+e { yyless (input () != 0); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
+%%
+#ifdef YYTEXT_POINTER
+extern char *yytext;
+#endif
+int
+main (void)
+{
+ return ! yylex () + ! yywrap ();
+}
+_ACEOF
+{ (ac_try="$LEX conftest.l"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$LEX conftest.l") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ echo "$as_me:$LINENO: checking lex output file root" >&5
+echo $ECHO_N "checking lex output file root... $ECHO_C" >&6; }
+if test "${ac_cv_prog_lex_root+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test -f lex.yy.c; then
+ ac_cv_prog_lex_root=lex.yy
+elif test -f lexyy.c; then
+ ac_cv_prog_lex_root=lexyy
+else
+ { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5
+echo "$as_me: error: cannot find output from $LEX; giving up" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5
+echo "${ECHO_T}$ac_cv_prog_lex_root" >&6; }
+LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
+
+if test -z "${LEXLIB+set}"; then
+ { echo "$as_me:$LINENO: checking lex library" >&5
+echo $ECHO_N "checking lex library... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lex+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ ac_save_LIBS=$LIBS
+ ac_cv_lib_lex='none needed'
+ for ac_lib in '' -lfl -ll; do
+ LIBS="$ac_lib $ac_save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_lex=$ac_lib
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ test "$ac_cv_lib_lex" != 'none needed' && break
+ done
+ LIBS=$ac_save_LIBS
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lex" >&5
+echo "${ECHO_T}$ac_cv_lib_lex" >&6; }
+ test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
+fi
+
+
+{ echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5
+echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6; }
+if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # POSIX says lex can declare yytext either as a pointer or an array; the
+# default is implementation-dependent. Figure out which it is, since
+# not all implementations provide the %pointer and %array declarations.
+ac_cv_prog_lex_yytext_pointer=no
+ac_save_LIBS=$LIBS
+LIBS="$LEXLIB $ac_save_LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_prog_lex_yytext_pointer=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_save_LIBS
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5
+echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6; }
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define YYTEXT_POINTER 1
+_ACEOF
+
+fi
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
+
+fi
+if test "$LEX" != flex; then
+ LEX="$SHELL $missing_dir/missing flex"
+ LEX_OUTPUT_ROOT=lex.yy
+
+ LEXLIB=''
+
+fi
+
# Checks for emacs lisp path
# If set to t, that means we are running in a shell under Emacs.
# If you have an Emacs named "t", then use the full path.
@@ -22221,6 +22489,11 @@ F77!$F77$ac_delim
FFLAGS!$FFLAGS$ac_delim
ac_ct_F77!$ac_ct_F77$ac_delim
LIBTOOL!$LIBTOOL$ac_delim
+YACC!$YACC$ac_delim
+YFLAGS!$YFLAGS$ac_delim
+LEX!$LEX$ac_delim
+LEX_OUTPUT_ROOT!$LEX_OUTPUT_ROOT$ac_delim
+LEXLIB!$LEXLIB$ac_delim
EMACS!$EMACS$ac_delim
EMACSLOADPATH!$EMACSLOADPATH$ac_delim
lispdir!$lispdir$ac_delim
@@ -22253,7 +22526,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 35; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 40; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index f4f1e9b7..d1f953e2 100644
--- a/configure.in
+++ b/configure.in
@@ -17,6 +17,15 @@ AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL
+AC_PROG_YACC
+
+AC_PROG_LEX
+if test "$LEX" != flex; then
+ LEX="$SHELL $missing_dir/missing flex"
+ AC_SUBST(LEX_OUTPUT_ROOT, lex.yy)
+ AC_SUBST(LEXLIB, '')
+fi
+
# Checks for emacs lisp path
AM_PATH_LISPDIR
diff --git a/docs/date-examples.txt b/docs/date-examples.txt
new file mode 100644
index 00000000..948d6980
--- /dev/null
+++ b/docs/date-examples.txt
@@ -0,0 +1,36 @@
+2002-02-02
+2002/02/02
+2002.02.02
+02-02-2002
+02/02/2002
+02.02.2002
+02-02-02
+02/02/02
+02.02.02
+02-02
+02/02
+02.02
+20020202
+20020202T023318
+20020202T023318-0700
+20020202T023318-0100
+02-Feb-2002
+2002-Feb-02
+02 Feb 2002
+02-Feb-2002
+02 February 2002
+02-February-2002
+2002 Feb 02
+2002-Feb-02
+2002 February 02
+2002-February-02
+02 Feb
+02-Feb
+02 February
+02-February
+Feb 02
+Feb-02
+February 02
+February-02
+Feb 02, 2002
+February 02, 2002
diff --git a/gnucash.cc b/gnucash.cc
index ab04dfd5..0b7b2786 100644
--- a/gnucash.cc
+++ b/gnucash.cc
@@ -219,7 +219,7 @@ void dataHandler(void *userData, const char *s, int len)
break;
case gnucash_parser_t::ENTRY_DATE:
- parser->curr_entry->_date = ptime_from_local_date_string(std::string(s, len));
+ parser->curr_entry->_date = parse_datetime(std::string(s, len));
break;
case gnucash_parser_t::ENTRY_DESC:
diff --git a/parsetime.cc b/parsetime.cc
new file mode 100644
index 00000000..2d447185
--- /dev/null
+++ b/parsetime.cc
@@ -0,0 +1,1914 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program 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, or (at your option)
+ any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.3"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TOK_FOURNUM = 258,
+ TOK_TWONUM = 259,
+ TOK_ONENUM = 260,
+ TOK_MONTH = 261,
+ TOK_SPACE = 262
+ };
+#endif
+/* Tokens. */
+#define TOK_FOURNUM 258
+#define TOK_TWONUM 259
+#define TOK_ONENUM 260
+#define TOK_MONTH 261
+#define TOK_SPACE 262
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 1 "parsetime.yy"
+
+#define YYSTYPE struct ledger::intorchar
+
+#include "times.h"
+#include "FlexLexer.h"
+
+static struct std::tm * timeval;
+
+namespace {
+ boost::posix_time::ptime moment;
+
+ yyFlexLexer * lexer;
+
+ inline void yyerror(const char *str) {
+ throw new ledger::datetime_error(str);
+ }
+
+ inline int yylex(void) {
+ return lexer->yylex();
+ }
+
+ int month_to_int(char * name)
+ {
+ switch (std::toupper(name[0])) {
+ case 'J':
+ if (name[1] == std::tolower('a'))
+ return 1;
+ else if (name[2] == std::tolower('n'))
+ return 6;
+ else
+ return 7;
+ case 'F':
+ return 2;
+ case 'M':
+ if (name[2] == std::tolower('r'))
+ return 3;
+ else
+ return 5;
+ case 'A':
+ if (name[1] == std::tolower('p'))
+ return 4;
+ else
+ return 8;
+ case 'S':
+ return 9;
+ case 'O':
+ return 10;
+ case 'N':
+ return 11;
+ case 'D':
+ return 12;
+ default:
+ std::cerr << "What?? (" << name << ")" << std::endl;
+ assert(0);
+ return -1;
+ }
+ }
+
+ void set_mdy(const ledger::intorchar& month,
+ const ledger::intorchar& day,
+ const ledger::intorchar& year = ledger::intorchar(),
+ bool shortyear = false)
+ {
+ if (ledger::day_before_month) {
+ timeval->tm_mon = (day.ival == -1 ?
+ month_to_int(day.sval) : day.ival) - 1;
+ timeval->tm_mday = month.ival;
+ } else {
+ timeval->tm_mon = (month.ival == -1 ?
+ month_to_int(month.sval) : month.ival) - 1;
+ timeval->tm_mday = day.ival;
+ }
+
+ if (year.ival != -1)
+ timeval->tm_year = (shortyear ?
+ (year.ival < 70 ? year.ival + 100 : year.ival) :
+ year.ival - 1900);
+ }
+}
+
+
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 216 of yacc.c. */
+#line 202 "parsetime.cc"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+ int i;
+#endif
+{
+ return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss;
+ YYSTYPE yyvs;
+ };
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 13
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 73
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 14
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 10
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 36
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 72
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 262
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 13, 12, 9, 10, 8, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 11, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 6, 7, 9, 11, 17, 23, 29,
+ 35, 41, 47, 51, 55, 59, 65, 71, 77, 79,
+ 85, 91, 95, 99, 105, 111, 115, 119, 126, 130,
+ 131, 136, 137, 140, 143, 145, 147
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 15, 0, -1, 17, 16, -1, -1, 7, -1, 18,
+ -1, 22, 8, 23, 8, 23, -1, 22, 9, 23,
+ 9, 23, -1, 22, 10, 23, 10, 23, -1, 23,
+ 8, 23, 8, 22, -1, 23, 9, 23, 9, 22,
+ -1, 23, 10, 23, 10, 22, -1, 23, 10, 23,
+ -1, 23, 8, 23, -1, 23, 9, 23, -1, 23,
+ 8, 23, 8, 4, -1, 23, 9, 23, 9, 4,
+ -1, 23, 10, 23, 10, 4, -1, 19, -1, 22,
+ 7, 6, 7, 23, -1, 23, 7, 6, 7, 22,
+ -1, 6, 7, 23, -1, 23, 7, 6, -1, 22,
+ 9, 6, 9, 23, -1, 23, 9, 6, 9, 22,
+ -1, 6, 9, 23, -1, 23, 9, 6, -1, 6,
+ 7, 23, 12, 7, 22, -1, 22, 3, 20, -1,
+ -1, 11, 3, 4, 21, -1, -1, 9, 3, -1,
+ 13, 3, -1, 3, -1, 4, -1, 5, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint8 yyrline[] =
+{
+ 0, 94, 94, 96, 96, 98, 109, 113, 117, 121,
+ 125, 129, 133, 137, 141, 145, 149, 153, 157, 159,
+ 163, 167, 171, 175, 179, 183, 187, 191, 197, 204,
+ 205, 212, 213, 216, 220, 223, 224
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "TOK_FOURNUM", "TOK_TWONUM",
+ "TOK_ONENUM", "TOK_MONTH", "TOK_SPACE", "'/'", "'-'", "'.'", "'T'",
+ "','", "'+'", "$accept", "input", "optspace", "date", "absdate",
+ "isodate", "opttime", "optzone", "year", "morday", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 47, 45,
+ 46, 84, 44, 43
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 14, 15, 16, 16, 17, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 19, 20,
+ 20, 21, 21, 21, 22, 23, 23
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 2, 0, 1, 1, 5, 5, 5, 5,
+ 5, 5, 3, 3, 3, 5, 5, 5, 1, 5,
+ 5, 3, 3, 5, 5, 3, 3, 6, 3, 0,
+ 4, 0, 2, 2, 1, 1, 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 34, 35, 36, 0, 0, 3, 5, 18, 0,
+ 0, 0, 0, 1, 4, 2, 29, 0, 0, 0,
+ 0, 0, 0, 0, 0, 21, 25, 0, 28, 0,
+ 0, 0, 0, 0, 22, 13, 26, 14, 12, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 31, 19, 6, 23, 7, 8, 20, 15,
+ 9, 24, 16, 10, 17, 11, 27, 0, 0, 30,
+ 32, 33
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 5, 15, 6, 7, 8, 28, 69, 9, 10
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -29
+static const yytype_int8 yypact[] =
+{
+ 21, -29, -29, -29, 36, 42, 37, -29, -29, 7,
+ 28, 24, 24, -29, -29, -29, 41, 48, 24, -1,
+ 24, 49, 24, 35, 24, 44, -29, 50, -29, 51,
+ 52, 53, 54, 55, 57, 58, 59, 60, 61, 63,
+ 68, 24, 24, 24, 24, 24, 56, 43, 56, 45,
+ 47, 56, -7, -29, -29, -29, -29, -29, -29, -29,
+ -29, -29, -29, -29, -29, -29, -29, 64, 70, -29,
+ -29, -29
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -29, -29, -29, -29, -29, -29, -29, -29, -28, -11
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 25, 26, 67, 2, 3, 31, 68, 30, 32, 33,
+ 16, 35, 37, 38, 17, 18, 19, 20, 58, 60,
+ 61, 63, 65, 66, 1, 2, 3, 4, 2, 3,
+ 53, 54, 55, 56, 57, 21, 22, 23, 24, 2,
+ 3, 36, 13, 11, 14, 12, 1, 59, 1, 62,
+ 1, 64, 27, 40, 29, 34, 39, 0, 41, 1,
+ 42, 0, 43, 44, 46, 45, 47, 70, 48, 49,
+ 51, 50, 52, 71
+};
+
+static const yytype_int8 yycheck[] =
+{
+ 11, 12, 9, 4, 5, 6, 13, 18, 19, 20,
+ 3, 22, 23, 24, 7, 8, 9, 10, 46, 47,
+ 48, 49, 50, 51, 3, 4, 5, 6, 4, 5,
+ 41, 42, 43, 44, 45, 7, 8, 9, 10, 4,
+ 5, 6, 0, 7, 7, 9, 3, 4, 3, 4,
+ 3, 4, 11, 3, 6, 6, 12, -1, 7, 3,
+ 8, -1, 9, 9, 7, 10, 8, 3, 9, 9,
+ 7, 10, 4, 3
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 3, 4, 5, 6, 15, 17, 18, 19, 22,
+ 23, 7, 9, 0, 7, 16, 3, 7, 8, 9,
+ 10, 7, 8, 9, 10, 23, 23, 11, 20, 6,
+ 23, 6, 23, 23, 6, 23, 6, 23, 23, 12,
+ 3, 7, 8, 9, 9, 10, 7, 8, 9, 9,
+ 10, 7, 4, 23, 23, 23, 23, 23, 22, 4,
+ 22, 22, 4, 22, 4, 22, 22, 9, 13, 21,
+ 3, 3
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto yyerrlab
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+#else
+static void
+yy_stack_print (bottom, top)
+ yytype_int16 *bottom;
+ yytype_int16 *top;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ fprintf (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ fprintf (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ including the terminating null byte. If YYRESULT is null, do not
+ copy anything; just return the number of bytes that would be
+ copied. As a special case, return 0 if an ordinary "syntax error"
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
+ size calculation. */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
+{
+ int yyn = yypact[yystate];
+
+ if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+ return 0;
+ else
+ {
+ int yytype = YYTRANSLATE (yychar);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ int yysize_overflow = 0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ int yyx;
+
+# if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+ char *yyfmt;
+ char const *yyf;
+ static char const yyunexpected[] = "syntax error, unexpected %s";
+ static char const yyexpecting[] = ", expecting %s";
+ static char const yyor[] = " or %s";
+ char yyformat[sizeof yyunexpected
+ + sizeof yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof yyor - 1))];
+ char const *yyprefix = yyexpecting;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 1;
+
+ yyarg[0] = yytname[yytype];
+ yyfmt = yystpcpy (yyformat, yyunexpected);
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ yyformat[sizeof yyunexpected - 1] = '\0';
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+ yyfmt = yystpcpy (yyfmt, yyprefix);
+ yyprefix = yyor;
+ }
+
+ yyf = YY_(yyformat);
+ yysize1 = yysize + yystrlen (yyf);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+
+ if (yysize_overflow)
+ return YYSIZE_MAXIMUM;
+
+ if (yyresult)
+ {
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *yyp = yyresult;
+ int yyi = 0;
+ while ((*yyp = *yyf) != '\0')
+ {
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyf += 2;
+ }
+ else
+ {
+ yyp++;
+ yyf++;
+ }
+ }
+ }
+ return yysize;
+ }
+}
+#endif /* YYERROR_VERBOSE */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+/* The look-ahead symbol. */
+int yychar;
+
+/* The semantic value of the look-ahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+
+ int yystate;
+ int yyn;
+ int yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+ /* Look-ahead token as an internal (translated) token number. */
+ int yytoken = 0;
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+ /* Three stacks and their tools:
+ `yyss': related to states,
+ `yyvs': related to semantic values,
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss = yyssa;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ YYSIZE_T yystacksize = YYINITDEPTH;
+
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss);
+ YYSTACK_RELOCATE (yyvs);
+
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ look-ahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to look-ahead token. */
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a look-ahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 5:
+#line 98 "parsetime.yy"
+ {
+ if (timeval->tm_gmtoff != -1) {
+ boost::posix_time::ptime::time_duration_type offset;
+ offset = boost::posix_time::seconds(timeval->tm_gmtoff);
+ moment = boost::posix_time::from_time_t(timegm(timeval)) - offset;
+ } else {
+ moment = boost::posix_time::ptime_from_tm(*timeval);
+ }
+}
+ break;
+
+ case 6:
+#line 109 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), (yyvsp[(1) - (5)]));
+ }
+ break;
+
+ case 7:
+#line 113 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), (yyvsp[(1) - (5)]));
+ }
+ break;
+
+ case 8:
+#line 117 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), (yyvsp[(1) - (5)]));
+ }
+ break;
+
+ case 9:
+#line 121 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));
+ }
+ break;
+
+ case 10:
+#line 125 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));
+ }
+ break;
+
+ case 11:
+#line 129 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));
+ }
+ break;
+
+ case 12:
+#line 133 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
+ }
+ break;
+
+ case 13:
+#line 137 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
+ }
+ break;
+
+ case 14:
+#line 141 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
+ }
+ break;
+
+ case 15:
+#line 145 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), true);
+ }
+ break;
+
+ case 16:
+#line 149 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), true);
+ }
+ break;
+
+ case 17:
+#line 153 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), true);
+ }
+ break;
+
+ case 19:
+#line 159 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), (yyvsp[(1) - (5)]));
+ }
+ break;
+
+ case 20:
+#line 163 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(1) - (5)]), (yyvsp[(5) - (5)]));
+ }
+ break;
+
+ case 21:
+#line 167 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
+ }
+ break;
+
+ case 22:
+#line 171 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (3)]), (yyvsp[(1) - (3)]));
+ }
+ break;
+
+ case 23:
+#line 175 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]), (yyvsp[(1) - (5)]));
+ }
+ break;
+
+ case 24:
+#line 179 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (5)]), (yyvsp[(1) - (5)]), (yyvsp[(5) - (5)]));
+ }
+ break;
+
+ case 25:
+#line 183 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
+ }
+ break;
+
+ case 26:
+#line 187 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(3) - (3)]), (yyvsp[(1) - (3)]));
+ }
+ break;
+
+ case 27:
+#line 191 "parsetime.yy"
+ {
+ set_mdy((yyvsp[(1) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(6) - (6)]));
+ }
+ break;
+
+ case 28:
+#line 198 "parsetime.yy"
+ {
+ timeval->tm_year = (yyvsp[(1) - (3)]).ival - 1900;
+ timeval->tm_mon = (yyvsp[(2) - (3)]).ival / 100 - 1;
+ timeval->tm_mday = (yyvsp[(3) - (3)]).ival % 100;
+}
+ break;
+
+ case 30:
+#line 206 "parsetime.yy"
+ {
+ timeval->tm_hour = (yyvsp[(2) - (4)]).ival / 100;
+ timeval->tm_min = (yyvsp[(2) - (4)]).ival % 100;
+ timeval->tm_sec = (yyvsp[(3) - (4)]).ival;
+}
+ break;
+
+ case 32:
+#line 213 "parsetime.yy"
+ {
+ timeval->tm_gmtoff = - (((yyvsp[(2) - (2)]).ival / 100) * 3600 + ((yyvsp[(2) - (2)]).ival % 100) * 60);
+ }
+ break;
+
+ case 33:
+#line 216 "parsetime.yy"
+ {
+ timeval->tm_gmtoff = (((yyvsp[(2) - (2)]).ival / 100) * 3600 + ((yyvsp[(2) - (2)]).ival % 100) * 60);
+ }
+ break;
+
+ case 34:
+#line 220 "parsetime.yy"
+ { (yyval) = (yyvsp[(1) - (1)]); }
+ break;
+
+ case 35:
+#line 223 "parsetime.yy"
+ { (yyval) = (yyvsp[(1) - (1)]); }
+ break;
+
+ case 36:
+#line 224 "parsetime.yy"
+ { (yyval) = (yyvsp[(1) - (1)]); }
+ break;
+
+
+/* Line 1267 of yacc.c. */
+#line 1653 "parsetime.cc"
+ default: break;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+ {
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+ {
+ YYSIZE_T yyalloc = 2 * yysize;
+ if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+ yyalloc = YYSTACK_ALLOC_MAXIMUM;
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+ if (yymsg)
+ yymsg_alloc = yyalloc;
+ else
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ }
+ }
+
+ if (0 < yysize && yysize <= yymsg_alloc)
+ {
+ (void) yysyntax_error (yymsg, yystate, yychar);
+ yyerror (yymsg);
+ }
+ else
+ {
+ yyerror (YY_("syntax error"));
+ if (yysize != 0)
+ goto yyexhaustedlab;
+ }
+ }
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse look-ahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse look-ahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#ifndef yyoverflow
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEOF && yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+#line 226 "parsetime.yy"
+
+
+int yywrap()
+{
+ return 1;
+}
+
+boost::posix_time::ptime parse_abs_datetime(std::istream& input)
+{
+ lexer = new yyFlexLexer(&input);
+
+ struct std::tm temp;
+ std::memset(&temp, 0, sizeof(struct std::tm));
+ temp.tm_year = 2002 - 1900;
+ temp.tm_gmtoff = -1;
+
+ timeval = &temp;
+ //yydebug = 1;
+
+ // jww (2007-04-19): Catch any boost errors thrown from here and
+ // push them onto the new error stack scheme.
+ try {
+ if (yyparse() == 0)
+ return moment;
+ }
+ catch (ledger::datetime_error *) {
+ throw;
+ }
+ catch (...) {
+ throw new ledger::datetime_error("Failed to parse date/time");
+ }
+ throw new ledger::datetime_error("Failed to parse date/time");
+}
+
+#ifdef MAIN
+
+namespace ledger {
+ bool day_before_month = false;
+}
+
+int main()
+{
+ std::cout << parse_abs_datetime(std::cin) << std::endl;
+ return 0;
+}
+
+#endif // MAIN
+
diff --git a/parsetime.h b/parsetime.h
new file mode 100644
index 00000000..5a9281de
--- /dev/null
+++ b/parsetime.h
@@ -0,0 +1,67 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program 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, or (at your option)
+ any later version.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TOK_FOURNUM = 258,
+ TOK_TWONUM = 259,
+ TOK_ONENUM = 260,
+ TOK_MONTH = 261,
+ TOK_SPACE = 262
+ };
+#endif
+/* Tokens. */
+#define TOK_FOURNUM 258
+#define TOK_TWONUM 259
+#define TOK_ONENUM 260
+#define TOK_MONTH 261
+#define TOK_SPACE 262
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+extern YYSTYPE yylval;
+
diff --git a/parsetime.yy b/parsetime.yy
new file mode 100644
index 00000000..ae7ca125
--- /dev/null
+++ b/parsetime.yy
@@ -0,0 +1,272 @@
+%{
+#define YYSTYPE struct ledger::intorchar
+
+#include "times.h"
+#include "FlexLexer.h"
+
+static struct std::tm * timeval;
+
+namespace {
+ boost::posix_time::ptime moment;
+
+ yyFlexLexer * lexer;
+
+ inline void yyerror(const char *str) {
+ throw new ledger::datetime_error(str);
+ }
+
+ inline int yylex(void) {
+ return lexer->yylex();
+ }
+
+ int month_to_int(char * name)
+ {
+ switch (std::toupper(name[0])) {
+ case 'J':
+ if (name[1] == std::tolower('a'))
+ return 1;
+ else if (name[2] == std::tolower('n'))
+ return 6;
+ else
+ return 7;
+ case 'F':
+ return 2;
+ case 'M':
+ if (name[2] == std::tolower('r'))
+ return 3;
+ else
+ return 5;
+ case 'A':
+ if (name[1] == std::tolower('p'))
+ return 4;
+ else
+ return 8;
+ case 'S':
+ return 9;
+ case 'O':
+ return 10;
+ case 'N':
+ return 11;
+ case 'D':
+ return 12;
+ default:
+ std::cerr << "What?? (" << name << ")" << std::endl;
+ assert(0);
+ return -1;
+ }
+ }
+
+ void set_mdy(const ledger::intorchar& month,
+ const ledger::intorchar& day,
+ const ledger::intorchar& year = ledger::intorchar(),
+ bool shortyear = false)
+ {
+ if (ledger::day_before_month) {
+ timeval->tm_mon = (day.ival == -1 ?
+ month_to_int(day.sval) : day.ival) - 1;
+ timeval->tm_mday = month.ival;
+ } else {
+ timeval->tm_mon = (month.ival == -1 ?
+ month_to_int(month.sval) : month.ival) - 1;
+ timeval->tm_mday = day.ival;
+ }
+
+ if (year.ival != -1)
+ timeval->tm_year = (shortyear ?
+ (year.ival < 70 ? year.ival + 100 : year.ival) :
+ year.ival - 1900);
+ }
+}
+
+%}
+
+%token TOK_FOURNUM
+%token TOK_TWONUM
+%token TOK_ONENUM
+%token TOK_MONTH
+
+%token TOK_SPACE
+
+%left '/' '-' '.' 'T'
+
+%%
+
+input: date optspace ;
+
+optspace: /* epsilon */ | TOK_SPACE ;
+
+date: absdate {
+ if (timeval->tm_gmtoff != -1) {
+ boost::posix_time::ptime::time_duration_type offset;
+ offset = boost::posix_time::seconds(timeval->tm_gmtoff);
+ moment = boost::posix_time::from_time_t(timegm(timeval)) - offset;
+ } else {
+ moment = boost::posix_time::ptime_from_tm(*timeval);
+ }
+};
+
+absdate:
+ year '/' morday '/' morday {
+ set_mdy($3, $5, $1);
+ }
+|
+ year '-' morday '-' morday {
+ set_mdy($3, $5, $1);
+ }
+|
+ year '.' morday '.' morday {
+ set_mdy($3, $5, $1);
+ }
+|
+ morday '/' morday '/' year {
+ set_mdy($1, $3, $5);
+ }
+|
+ morday '-' morday '-' year {
+ set_mdy($1, $3, $5);
+ }
+|
+ morday '.' morday '.' year {
+ set_mdy($1, $3, $5);
+ }
+|
+ morday '.' morday {
+ set_mdy($1, $3);
+ }
+|
+ morday '/' morday {
+ set_mdy($1, $3);
+ }
+|
+ morday '-' morday {
+ set_mdy($1, $3);
+ }
+|
+ morday '/' morday '/' TOK_TWONUM {
+ set_mdy($1, $3, $5, true);
+ }
+|
+ morday '-' morday '-' TOK_TWONUM {
+ set_mdy($1, $3, $5, true);
+ }
+|
+ morday '.' morday '.' TOK_TWONUM {
+ set_mdy($1, $3, $5, true);
+ }
+|
+ isodate
+|
+ year TOK_SPACE TOK_MONTH TOK_SPACE morday {
+ set_mdy($3, $5, $1);
+ }
+|
+ morday TOK_SPACE TOK_MONTH TOK_SPACE year {
+ set_mdy($3, $1, $5);
+ }
+|
+ TOK_MONTH TOK_SPACE morday {
+ set_mdy($1, $3);
+ }
+|
+ morday TOK_SPACE TOK_MONTH {
+ set_mdy($3, $1);
+ }
+|
+ year '-' TOK_MONTH '-' morday {
+ set_mdy($3, $5, $1);
+ }
+|
+ morday '-' TOK_MONTH '-' year {
+ set_mdy($3, $1, $5);
+ }
+|
+ TOK_MONTH '-' morday {
+ set_mdy($1, $3);
+ }
+|
+ morday '-' TOK_MONTH {
+ set_mdy($3, $1);
+ }
+|
+ TOK_MONTH TOK_SPACE morday ',' TOK_SPACE year {
+ set_mdy($1, $3, $6);
+ }
+;
+
+isodate:
+ year TOK_FOURNUM opttime
+{
+ timeval->tm_year = $1.ival - 1900;
+ timeval->tm_mon = $2.ival / 100 - 1;
+ timeval->tm_mday = $3.ival % 100;
+};
+
+opttime: /* epsilon */ |
+ 'T' TOK_FOURNUM TOK_TWONUM optzone
+{
+ timeval->tm_hour = $2.ival / 100;
+ timeval->tm_min = $2.ival % 100;
+ timeval->tm_sec = $3.ival;
+};
+
+optzone: /* epsilon */ |
+ '-' TOK_FOURNUM {
+ timeval->tm_gmtoff = - (($2.ival / 100) * 3600 + ($2.ival % 100) * 60);
+ }
+| '+' TOK_FOURNUM {
+ timeval->tm_gmtoff = (($2.ival / 100) * 3600 + ($2.ival % 100) * 60);
+ };
+
+year: TOK_FOURNUM { $$ = $1; };
+
+morday:
+ TOK_TWONUM { $$ = $1; }
+| TOK_ONENUM { $$ = $1; };
+
+%%
+
+int yywrap()
+{
+ return 1;
+}
+
+boost::posix_time::ptime parse_abs_datetime(std::istream& input)
+{
+ lexer = new yyFlexLexer(&input);
+
+ struct std::tm temp;
+ std::memset(&temp, 0, sizeof(struct std::tm));
+ temp.tm_year = 2002 - 1900;
+ temp.tm_gmtoff = -1;
+
+ timeval = &temp;
+ //yydebug = 1;
+
+ // jww (2007-04-19): Catch any boost errors thrown from here and
+ // push them onto the new error stack scheme.
+ try {
+ if (yyparse() == 0)
+ return moment;
+ }
+ catch (ledger::datetime_error *) {
+ throw;
+ }
+ catch (...) {
+ throw new ledger::datetime_error("Failed to parse date/time");
+ }
+ throw new ledger::datetime_error("Failed to parse date/time");
+}
+
+#ifdef MAIN
+
+namespace ledger {
+ bool day_before_month = false;
+}
+
+int main()
+{
+ std::cout << parse_abs_datetime(std::cin) << std::endl;
+ return 0;
+}
+
+#endif // MAIN
diff --git a/qif.cc b/qif.cc
index 0da093eb..393d1939 100644
--- a/qif.cc
+++ b/qif.cc
@@ -102,7 +102,7 @@ unsigned int qif_parser_t::parse(std::istream& in,
case 'D':
SET_BEG_POS_AND_LINE();
get_line(in);
- entry->_date = ptime_from_local_date_string(line);
+ entry->_date = parse_datetime(line);
break;
case 'T':
diff --git a/scantime.cc b/scantime.cc
new file mode 100644
index 00000000..d03cc365
--- /dev/null
+++ b/scantime.cc
@@ -0,0 +1,1577 @@
+#line 2 "scantime.cc"
+
+#line 4 "scantime.cc"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 33
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+ /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
+ * following macro. This is required in order to pass the c++-multiple-scanners
+ * test in the regression suite. We get reports that it breaks inheritance.
+ * We will address this in a future release of flex, or omit the C++ scanner
+ * altogether.
+ */
+ #define yyFlexLexer yyFlexLexer
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+/* begin standard C++ headers. */
+#include <iostream>
+#include <errno.h>
+#include <cstdlib>
+#include <cstring>
+/* end standard C++ headers. */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int yyleng;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+
+ std::istream* yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+
+#define yytext_ptr yytext
+#define YY_INTERACTIVE
+
+#include <FlexLexer.h>
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 9
+#define YY_END_OF_BUFFER 10
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[71] =
+ { 0,
+ 0, 0, 10, 8, 1, 2, 2, 5, 8, 8,
+ 8, 8, 8, 8, 8, 8, 4, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 3, 0, 0, 0, 0, 0, 7, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 1, 1, 1,
+ 1, 1, 1, 1, 6, 1, 1, 7, 1, 8,
+ 1, 1, 1, 9, 1, 1, 10, 11, 12, 1,
+ 1, 1, 13, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 14, 15, 16, 1,
+
+ 17, 1, 18, 19, 20, 1, 1, 21, 22, 23,
+ 24, 25, 1, 26, 27, 28, 29, 30, 1, 1,
+ 31, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[32] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1
+ } ;
+
+static yyconst flex_int16_t yy_base[72] =
+ { 0,
+ 0, 12, 89, 90, 90, 90, 90, 83, 1, 70,
+ 69, 13, 71, 60, 67, 65, 76, 54, 61, 62,
+ 62, 53, 8, 2, 45, 46, 48, 67, 51, 41,
+ 52, 42, 38, 35, 48, 48, 90, 46, 38, 33,
+ 90, 39, 32, 36, 28, 42, 90, 36, 32, 38,
+ 35, 23, 35, 35, 22, 32, 29, 23, 27, 17,
+ 10, 23, 13, 23, 11, 5, 9, 17, 6, 90,
+ 0
+ } ;
+
+static yyconst flex_int16_t yy_def[72] =
+ { 0,
+ 71, 71, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 0,
+ 70
+ } ;
+
+static yyconst flex_int16_t yy_nxt[122] =
+ { 0,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+ 14, 15, 16, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 18, 22, 36, 34, 19,
+ 35, 47, 37, 69, 47, 47, 47, 68, 47, 67,
+ 47, 23, 66, 65, 64, 63, 62, 61, 60, 59,
+ 47, 58, 57, 56, 47, 55, 54, 53, 52, 47,
+ 51, 50, 49, 48, 47, 47, 46, 45, 44, 43,
+ 42, 41, 40, 39, 38, 33, 32, 31, 30, 29,
+ 28, 27, 26, 25, 24, 21, 20, 17, 70, 3,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70
+ } ;
+
+static yyconst flex_int16_t yy_chk[122] =
+ { 0,
+ 71, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 9, 12, 24, 23, 9,
+ 23, 69, 24, 68, 67, 66, 65, 64, 63, 62,
+ 61, 12, 60, 59, 58, 57, 56, 55, 54, 53,
+ 52, 51, 50, 49, 48, 46, 45, 44, 43, 42,
+ 40, 39, 38, 36, 35, 34, 33, 32, 31, 30,
+ 29, 28, 27, 26, 25, 22, 21, 20, 19, 18,
+ 17, 16, 15, 14, 13, 11, 10, 8, 3, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
+ 70
+ } ;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+#line 1 "scantime.ll"
+#line 4 "scantime.ll"
+#define YYSTYPE struct ledger::intorchar
+
+extern int yywrap();
+
+#include "times.h"
+#include "parsetime.h"
+
+extern YYSTYPE yylval;
+#line 464 "scantime.cc"
+
+#define INITIAL 0
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+#define ECHO LexerOutput( yytext, yyleng )
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+\
+ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) LexerError( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+#define YY_DECL int yyFlexLexer::yylex()
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 17 "scantime.ll"
+
+
+#line 567 "scantime.cc"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = & std::cin;
+
+ if ( ! yyout )
+ yyout = & std::cout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE );
+ }
+
+ yy_load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of yytext. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 71 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 90 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 19 "scantime.ll"
+return TOK_SPACE;
+ YY_BREAK
+case 2:
+/* rule 2 can match eol */
+YY_RULE_SETUP
+#line 20 "scantime.ll"
+;
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 22 "scantime.ll"
+yylval = ledger::intorchar(std::atoi(yytext)); return TOK_FOURNUM;
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 23 "scantime.ll"
+yylval = ledger::intorchar(std::atoi(yytext)); return TOK_TWONUM;
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 24 "scantime.ll"
+yylval = ledger::intorchar(std::atoi(yytext)); return TOK_ONENUM;
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 26 "scantime.ll"
+yylval = ledger::intorchar(yytext); return TOK_MONTH;
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 27 "scantime.ll"
+yylval = ledger::intorchar(yytext); return TOK_MONTH;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 29 "scantime.ll"
+return (int) yytext[0];
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 30 "scantime.ll"
+ECHO;
+ YY_BREAK
+#line 696 "scantime.cc"
+case YY_STATE_EOF(INITIAL):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_c_buf_p);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( yywrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of yylex */
+
+yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
+{
+ yyin = arg_yyin;
+ yyout = arg_yyout;
+ yy_c_buf_p = 0;
+ yy_init = 0;
+ yy_start = 0;
+ yy_flex_debug = 0;
+ yylineno = 1; // this will only get updated if %option yylineno
+
+ yy_did_buffer_switch_on_eof = 0;
+
+ yy_looking_for_trail_begin = 0;
+ yy_more_flag = 0;
+ yy_more_len = 0;
+ yy_more_offset = yy_prev_more_offset = 0;
+
+ yy_start_stack_ptr = yy_start_stack_depth = 0;
+ yy_start_stack = NULL;
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+
+ yy_state_buf = 0;
+
+}
+
+yyFlexLexer::~yyFlexLexer()
+{
+ delete [] yy_state_buf;
+ yyfree(yy_start_stack );
+ yy_delete_buffer( YY_CURRENT_BUFFER );
+}
+
+void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
+{
+ if ( new_in )
+ {
+ yy_delete_buffer( YY_CURRENT_BUFFER );
+ yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
+ }
+
+ if ( new_out )
+ yyout = new_out;
+}
+
+#ifdef YY_INTERACTIVE
+int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
+#else
+int yyFlexLexer::LexerInput( char* buf, int max_size )
+#endif
+{
+ if ( yyin->eof() || yyin->fail() )
+ return 0;
+
+#ifdef YY_INTERACTIVE
+ yyin->get( buf[0] );
+
+ if ( yyin->eof() )
+ return 0;
+
+ if ( yyin->bad() )
+ return -1;
+
+ return 1;
+
+#else
+ (void) yyin->read( buf, max_size );
+
+ if ( yyin->bad() )
+ return -1;
+ else
+ return yyin->gcount();
+#endif
+}
+
+void yyFlexLexer::LexerOutput( const char* buf, int size )
+{
+ (void) yyout->write( buf, size );
+}
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+int yyFlexLexer::yy_get_next_buffer()
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ yy_state_type yyFlexLexer::yy_get_previous_state()
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 71 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 71 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 70);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+ void yyFlexLexer::yyunput( int c, register char* yy_bp)
+{
+ register char *yy_cp;
+
+ yy_cp = (yy_c_buf_p);
+
+ /* undo effects of setting up yytext */
+ *yy_cp = (yy_hold_char);
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ { /* need to shift things up to make room */
+ /* +2 for EOB chars. */
+ register int number_to_move = (yy_n_chars) + 2;
+ register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
+ register char *source =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
+
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+ (yytext_ptr) = yy_bp;
+ (yy_hold_char) = *yy_cp;
+ (yy_c_buf_p) = yy_cp;
+}
+
+ int yyFlexLexer::yyinput()
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve yytext */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ return c;
+}
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyFlexLexer::yyrestart( std::istream* input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE );
+ }
+
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file );
+ yy_load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+ void yyFlexLexer::yy_load_buffer_state()
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ *
+ */
+ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree((void *) b->yy_ch_buf );
+
+ yyfree((void *) b );
+}
+
+extern "C" int isatty (int );
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
+
+{
+ int oerrno = errno;
+
+ yy_flush_buffer( b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
+{
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack();
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void yyFlexLexer::yypop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+void yyFlexLexer::yyensure_buffer_stack(void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+ void yyFlexLexer::yy_push_state( int new_state )
+{
+ if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) )
+ {
+ yy_size_t new_size;
+
+ (yy_start_stack_depth) += YY_START_STACK_INCR;
+ new_size = (yy_start_stack_depth) * sizeof( int );
+
+ if ( ! (yy_start_stack) )
+ (yy_start_stack) = (int *) yyalloc(new_size );
+
+ else
+ (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size );
+
+ if ( ! (yy_start_stack) )
+ YY_FATAL_ERROR(
+ "out of memory expanding start-condition stack" );
+ }
+
+ (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START;
+
+ BEGIN(new_state);
+}
+
+ void yyFlexLexer::yy_pop_state()
+{
+ if ( --(yy_start_stack_ptr) < 0 )
+ YY_FATAL_ERROR( "start-condition stack underflow" );
+
+ BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
+}
+
+ int yyFlexLexer::yy_top_state()
+{
+ return (yy_start_stack)[(yy_start_stack_ptr) - 1];
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+void yyFlexLexer::LexerError( yyconst char msg[] )
+{
+ std::cerr << msg << std::endl;
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = (yy_hold_char); \
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *yyalloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *yyrealloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void yyfree (void * ptr )
+{
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 30 "scantime.ll"
diff --git a/scantime.ll b/scantime.ll
new file mode 100644
index 00000000..02d00d78
--- /dev/null
+++ b/scantime.ll
@@ -0,0 +1,29 @@
+%option c++ 8bit
+
+%{
+#define YYSTYPE struct ledger::intorchar
+
+extern int yywrap();
+
+#include "times.h"
+#include "parsetime.h"
+
+extern YYSTYPE yylval;
+%}
+
+shortmon (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)
+longmon (January|February|March|April|May|June|July|August|September|October|November|December)
+
+%%
+
+[ \t] return TOK_SPACE;
+[\r\n] ;
+
+[0-9]{4} yylval = ledger::intorchar(std::atoi(yytext)); return TOK_FOURNUM;
+[0-9]{2} yylval = ledger::intorchar(std::atoi(yytext)); return TOK_TWONUM;
+[0-9]{1} yylval = ledger::intorchar(std::atoi(yytext)); return TOK_ONENUM;
+
+{shortmon} yylval = ledger::intorchar(yytext); return TOK_MONTH;
+{longmon} yylval = ledger::intorchar(yytext); return TOK_MONTH;
+
+. return (int) yytext[0];
diff --git a/tests/corelib/numerics/DateTime.cc b/tests/corelib/numerics/DateTime.cc
index fe5ac68b..02dd7a0d 100644
--- a/tests/corelib/numerics/DateTime.cc
+++ b/tests/corelib/numerics/DateTime.cc
@@ -13,89 +13,71 @@ void DateTimeTestCase::tearDown() {}
void DateTimeTestCase::testConstructors()
{
- struct tm moment;
- std::memset(&moment, INT_MAX, sizeof(struct tm));
-
-#ifdef HAVE_STRPTIME
- strptime("2006/12/25 00:00:00", "%Y/%m/%d %H:%M:%S", &moment);
-#endif
-
-#ifdef HAVE_TIMEGM
- std::time_t gmtMoment = timegm(&moment);
-#endif
- std::time_t localMoment = std::mktime(&moment);
-
- date_t d1;
-#ifdef HAVE_TIMEGM
- date_t d2(gmtMoment);
-#endif
- date_t d3(localMoment);
- date_t d4("2006/12/25");
- date_t d5("12/25");
- date_t d6("2006.12.25");
- date_t d7("12.25");
- date_t d8("2006-12-25");
- date_t d9("12-25");
- date_t d10("tue");
- date_t d11("tuesday");
- date_t d12("feb");
- date_t d13("february");
- date_t d14("2006");
- date_t d15(d3);
-
-#ifdef HAVE_TIMEGM
- if (std::memcmp(&gmtMoment, &localMoment, sizeof(std::time_t)) == 0)
- assertEqual(d2, d3);
- else
- assertNotEqual(d2, d3);
+ std::time_t time_t_now = std::time(NULL);
+ struct tm * moment = std::localtime(&time_t_now);
+
+ std::time_t localMoment = std::mktime(moment);
+
+ ptime d0;
+ ptime d1(parse_datetime("1990/01/01"));
+ ptime d3(boost::posix_time::from_time_t(localMoment));
+ ptime d4(parse_datetime("2006/12/25"));
+ ptime d5(parse_datetime("12/25"));
+ ptime d6(parse_datetime("2006.12.25"));
+ ptime d7(parse_datetime("12.25"));
+ ptime d8(parse_datetime("2006-12-25"));
+ ptime d9(parse_datetime("12-25"));
+#if 0
+ ptime d10(parse_datetime("tue"));
+ ptime d11(parse_datetime("tuesday"));
+ ptime d12(parse_datetime("feb"));
+ ptime d13(parse_datetime("february"));
+ ptime d14(parse_datetime("2006"));
#endif
+ ptime d15(d3);
- assertFalse(d1);
- assertTrue(d4);
+ assertTrue(d0.is_not_a_date_time());
+ assertFalse(d1.is_not_a_date_time());
+ assertFalse(d4.is_not_a_date_time());
- assertTrue(date_t::now > d1);
- assertTrue(date_t::now > d3);
- assertTrue(date_t::now > d4);
+ assertTrue(now > d1);
+ assertTrue(now <= d3);
+ assertTrue(now > d4);
- assertEqual(d3, d4);
assertEqual(d3, d15);
assertEqual(d4, d6);
assertEqual(d4, d8);
assertEqual(d5, d7);
assertEqual(d5, d9);
+#if 0
assertEqual(d10, d11);
assertEqual(d12, d13);
+#endif
- assertThrow(date_t("2007/02/29"), date_error *);
- assertThrow(date_t("2007/13/01"), date_error *);
- assertThrow(date_t("2007/00/01"), date_error *);
- assertThrow(date_t("2007/01/00"), date_error *);
- assertThrow(date_t("2007/00/00"), date_error *);
- assertThrow(date_t("2007/05/32"), date_error *);
-
- assertThrow(date_t("2006x/12/25"), date_error *);
- assertThrow(date_t("2006/12x/25"), date_error *);
- assertThrow(date_t("2006/12/25x"), date_error *);
-
- assertThrow(date_t("feb/12/25"), date_error *);
- assertThrow(date_t("2006/mon/25"), date_error *);
- assertThrow(date_t("2006/12/web"), date_error *);
+ assertThrow(parse_datetime("2007/02/29"), datetime_error *);
+ assertThrow(parse_datetime("2007/13/01"), datetime_error *);
+ assertThrow(parse_datetime("2007/00/01"), datetime_error *);
+ assertThrow(parse_datetime("2007/01/00"), datetime_error *);
+ assertThrow(parse_datetime("2007/00/00"), datetime_error *);
+ assertThrow(parse_datetime("2007/05/32"), datetime_error *);
+
+ assertThrow(parse_datetime("2006x/12/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/12x/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/12/25x"), datetime_error *);
+
+ assertThrow(parse_datetime("feb/12/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/mon/25"), datetime_error *);
+ assertThrow(parse_datetime("2006/12/web"), datetime_error *);
+
+ assertThrow(parse_datetime("12*25"), datetime_error *);
+
+ assertThrow(parse_datetime("tuf"), datetime_error *);
+ assertThrow(parse_datetime("tufsday"), datetime_error *);
+ assertThrow(parse_datetime("fec"), datetime_error *);
+ assertThrow(parse_datetime("fecruary"), datetime_error *);
+ assertThrow(parse_datetime("207x"), datetime_error *);
+ assertThrow(parse_datetime("hello"), datetime_error *);
- assertThrow(date_t("12*25"), date_error *);
-
- assertThrow(date_t("tuf"), date_error *);
- assertThrow(date_t("tufsday"), date_error *);
- assertThrow(date_t("fec"), date_error *);
- assertThrow(date_t("fecruary"), date_error *);
- assertThrow(date_t("207x"), date_error *);
- assertThrow(date_t("hello"), date_error *);
-
- datetime_t dt1;
- datetime_t dt2;
- datetime_t dt3;
- datetime_t dt4;
- datetime_t dt5;
-
interval_t i1;
interval_t i2;
}
diff --git a/textual.cc b/textual.cc
index 9fca3910..ce203de6 100644
--- a/textual.cc
+++ b/textual.cc
@@ -276,10 +276,10 @@ transaction_t * parse_transaction(char * line,
if (char * p = std::strchr(buf, '=')) {
*p++ = '\0';
- xact->_date_eff = ptime_from_local_date_string(p);
+ xact->_date_eff = parse_datetime(p);
}
if (buf[0])
- xact->_date = ptime_from_local_date_string(buf);
+ xact->_date = parse_datetime(buf);
}
}
}
@@ -623,7 +623,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
time_entry_t event;
event.desc = n ? n : "";
- event.checkin = ptime_from_local_time_string(date);
+ event.checkin = parse_datetime(date);
event.account = account_stack.front()->find_account(p);
if (! time_entries.empty())
@@ -649,7 +649,7 @@ unsigned int textual_parser_t::parse(std::istream& in,
char * n = next_element(p, true);
clock_out_from_timelog
- (ptime_from_local_time_string(date),
+ (parse_datetime(date),
p ? account_stack.front()->find_account(p) : NULL, n, journal);
count++;
}
@@ -686,11 +686,10 @@ unsigned int textual_parser_t::parse(std::istream& in,
if (std::isdigit(time_field_ptr[0])) {
symbol_and_price = next_element(time_field_ptr);
if (! symbol_and_price) break;
- datetime = ptime_from_local_time_string(date_field + " " +
- time_field_ptr);
+ datetime = parse_datetime(date_field + " " + time_field_ptr);
} else {
symbol_and_price = time_field_ptr;
- datetime = ptime_from_local_date_string(date_field);
+ datetime = parse_datetime(date_field);
}
std::string symbol;
diff --git a/times.cc b/times.cc
index 60926112..bb75f8d9 100644
--- a/times.cc
+++ b/times.cc
@@ -2,6 +2,92 @@
namespace ledger {
- ptime now = boost::posix_time::second_clock::universal_time();
+ptime now = boost::posix_time::second_clock::universal_time();
+bool day_before_month = false;
+
+ptime parse_datetime(std::istream& in)
+{
+#if 1
+ return parse_abs_datetime(in);
+#else
+ std::string word;
+
+ if (! in.good() || in.eof())
+ return ptime();
+
+ in >> word;
+
+ // Grammar
+ //
+ // datetime: absdate [time]
+ // | reldate
+ // | datetime preposition
+ //
+ // reldate: NOW | TODAY | YESTERDAY | TOMORROW
+ // | skip_or_quantity specifier
+ //
+ // skip_or_quantity: skip | quantity
+ //
+ // skip: LAST | NEXT
+ //
+ // quantity: INTEGER | CARDINAL
+ //
+ // specifier: DAY | WEEK | MONTH | QUARTER | YEAR | DECADE
+ //
+ // preposition: AGO | BACK
+ // | BEFORE reldate
+ // | SINCE/FROM reldate
+ // | UNTIL reldate
+ // | AFTER reldate
+
+ if (std::isdigit(word[0])) {
+ // This could be any of a variety of formats:
+ //
+ // 20070702 [TIME]
+ // 22072007T171940
+ // 22072007T171940-0700
+ // 2007-07-02 [TIME]
+ // 2007/07/02 [TIME]
+ // 2007.07.02 [TIME]
+ // 2007-Jul-22 [TIME]
+ // 07-22-2007 [TIME]
+ // 07-22-07 [TIME]
+ // 07/22/2007 [TIME]
+ // 07/22/2007 [TIME]
+ // 07.22.2007 [TIME]
+ // 07.22.07 [TIME]
+ // 22-07-2007 [TIME]
+ // 22-07-07 [TIME]
+ // 22/07/2007 [TIME]
+ // 22/07/07 [TIME]
+ // 22.07.2007 [TIME]
+ // 22.07.07 [TIME]
+ // 22 Jul 2007 [TIME]
+ // 22 July 2007 [TIME]
+ //
+ // (NUMBER) (SPECIFIER)
+
+ } else {
+ // If there is no starting digit, then it could be any of these:
+ //
+ // now
+ // today
+ // yesterday
+ // tomorrow
+ // (last|next) (week|month|quarter|year|decade)
+ // (one|two|three|four|five|six|seven|eight|nine|ten) SPECIFIER
+ // PREPOSITION DATE
+ //
+ // PREPOSITION = (from|after|before|since|until)
+ // SPECIFIER = (weeks?|months?|quarters?|years?|decades?) (ago|back)
+ //
+ //
+ }
+#endif
+}
+
+ptime datetime_range_from_stream(std::istream& in)
+{
+}
}
diff --git a/times.h b/times.h
index da468a98..b0d9d22b 100644
--- a/times.h
+++ b/times.h
@@ -8,6 +8,9 @@
#include <ctime>
#include <string>
+#include <iostream>
+
+#include "error.h"
namespace ledger {
@@ -15,6 +18,12 @@ typedef boost::posix_time::ptime ptime;
typedef boost::posix_time::seconds seconds;
typedef ptime::time_duration_type time_duration;
+class datetime_error : public error {
+ public:
+ datetime_error(const std::string& _reason) throw() : error(_reason) {}
+ virtual ~datetime_error() throw() {}
+};
+
class interval_t
{
public:
@@ -31,6 +40,7 @@ public:
void parse(std::istream& in) {}
};
+#if 0
inline ptime ptime_local_to_utc(const ptime& when) {
struct std::tm tm_gmt = to_tm(when);
return boost::posix_time::from_time_t(std::mktime(&tm_gmt));
@@ -46,9 +56,63 @@ inline ptime ptime_from_local_date_string(const std::string& date_string) {
inline ptime ptime_from_local_time_string(const std::string& time_string) {
return ptime_local_to_utc(boost::posix_time::time_from_string(time_string));
}
+#endif
+
+ptime parse_datetime(std::istream& in);
+
+inline ptime parse_datetime(const std::string& str) {
+ std::istringstream instr(str);
+ return parse_datetime(instr);
+}
extern ptime now;
+extern bool day_before_month;
+
+struct intorchar
+{
+ int ival;
+ char * sval;
+
+ intorchar() : ival(-1), sval(NULL) {}
+ intorchar(int val) : ival(val), sval(NULL) {}
+ intorchar(char * val) : ival(-1), sval(NULL) {
+ set_sval(val);
+ }
+ intorchar(const intorchar& o) : ival(o.ival), sval(NULL) {
+ set_sval(o.sval);
+ }
+
+ ~intorchar() {
+ clear_sval();
+ }
+
+ intorchar& operator=(const intorchar& o) {
+ if (&o == this)
+ return *this;
+
+ ival = o.ival;
+ set_sval(o.sval);
+ }
+
+private:
+ void clear_sval() {
+ if (sval) {
+ delete[] sval;
+ sval = NULL;
+ }
+ }
+
+ void set_sval(char * val) {
+ clear_sval();
+ if (val) {
+ sval = new char[std::strlen(val) + 1];
+ std::strcpy(sval, val);
+ }
+ }
+};
}
+boost::posix_time::ptime parse_abs_datetime(std::istream& input);
+
#endif /* _TIMES_H */
diff --git a/xmlparse.cc b/xmlparse.cc
index 18158194..daf3b15b 100644
--- a/xmlparse.cc
+++ b/xmlparse.cc
@@ -79,10 +79,10 @@ static void endElement(void *userData, const char *name)
curr_entry = NULL;
}
else if (std::strcmp(name, "en:date") == 0) {
- curr_entry->_date = ptime_from_local_date_string(data);
+ curr_entry->_date = parse_datetime(data);
}
else if (std::strcmp(name, "en:date_eff") == 0) {
- curr_entry->_date_eff = ptime_from_local_date_string(data);
+ curr_entry->_date_eff = parse_datetime(data);
}
else if (std::strcmp(name, "en:code") == 0) {
curr_entry->code = data;
diff --git a/ylwrap b/ylwrap
new file mode 100755
index 00000000..102bd893
--- /dev/null
+++ b/ylwrap
@@ -0,0 +1,223 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program 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, or (at your option)
+# any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case "$1" in
+ '')
+ echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
+ exit 1
+ ;;
+ --basedir)
+ basedir=$2
+ shift 2
+ ;;
+ -h|--h*)
+ cat <<\EOF
+Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
+
+Wrapper for lex/yacc invocations, renaming files as desired.
+
+ INPUT is the input file
+ OUTPUT is one file PROG generates
+ DESIRED is the file we actually want instead of OUTPUT
+ PROGRAM is program to run
+ ARGS are passed to PROG
+
+Any number of OUTPUT,DESIRED pairs may be used.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v|--v*)
+ echo "ylwrap $scriptversion"
+ exit $?
+ ;;
+esac
+
+
+# The input.
+input="$1"
+shift
+case "$input" in
+ [\\/]* | ?:[\\/]*)
+ # Absolute path; do nothing.
+ ;;
+ *)
+ # Relative path. Make it absolute.
+ input="`pwd`/$input"
+ ;;
+esac
+
+pairlist=
+while test "$#" -ne 0; do
+ if test "$1" = "--"; then
+ shift
+ break
+ fi
+ pairlist="$pairlist $1"
+ shift
+done
+
+# The program to run.
+prog="$1"
+shift
+# Make any relative path in $prog absolute.
+case "$prog" in
+ [\\/]* | ?:[\\/]*) ;;
+ *[\\/]*) prog="`pwd`/$prog" ;;
+esac
+
+# FIXME: add hostname here for parallel makes that run commands on
+# other machines. But that might take us over the 14-char limit.
+dirname=ylwrap$$
+trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
+mkdir $dirname || exit 1
+
+cd $dirname
+
+case $# in
+ 0) $prog "$input" ;;
+ *) $prog "$@" "$input" ;;
+esac
+ret=$?
+
+if test $ret -eq 0; then
+ set X $pairlist
+ shift
+ first=yes
+ # Since DOS filename conventions don't allow two dots,
+ # the DOS version of Bison writes out y_tab.c instead of y.tab.c
+ # and y_tab.h instead of y.tab.h. Test to see if this is the case.
+ y_tab_nodot="no"
+ if test -f y_tab.c || test -f y_tab.h; then
+ y_tab_nodot="yes"
+ fi
+
+ # The directory holding the input.
+ input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
+ # Quote $INPUT_DIR so we can use it in a regexp.
+ # FIXME: really we should care about more than `.' and `\'.
+ input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
+
+ while test "$#" -ne 0; do
+ from="$1"
+ # Handle y_tab.c and y_tab.h output by DOS
+ if test $y_tab_nodot = "yes"; then
+ if test $from = "y.tab.c"; then
+ from="y_tab.c"
+ else
+ if test $from = "y.tab.h"; then
+ from="y_tab.h"
+ fi
+ fi
+ fi
+ if test -f "$from"; then
+ # If $2 is an absolute path name, then just use that,
+ # otherwise prepend `../'.
+ case "$2" in
+ [\\/]* | ?:[\\/]*) target="$2";;
+ *) target="../$2";;
+ esac
+
+ # We do not want to overwrite a header file if it hasn't
+ # changed. This avoid useless recompilations. However the
+ # parser itself (the first file) should always be updated,
+ # because it is the destination of the .y.c rule in the
+ # Makefile. Divert the output of all other files to a temporary
+ # file so we can compare them to existing versions.
+ if test $first = no; then
+ realtarget="$target"
+ target="tmp-`echo $target | sed s/.*[\\/]//g`"
+ fi
+ # Edit out `#line' or `#' directives.
+ #
+ # We don't want the resulting debug information to point at
+ # an absolute srcdir; it is better for it to just mention the
+ # .y file with no path.
+ #
+ # We want to use the real output file name, not yy.lex.c for
+ # instance.
+ #
+ # We want the include guards to be adjusted too.
+ FROM=`echo "$from" | sed \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
+ TARGET=`echo "$2" | sed \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
+
+ sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
+ -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
+
+ # Check whether header files must be updated.
+ if test $first = no; then
+ if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
+ echo "$2" is unchanged
+ rm -f "$target"
+ else
+ echo updating "$2"
+ mv -f "$target" "$realtarget"
+ fi
+ fi
+ else
+ # A missing file is only an error for the first file. This
+ # is a blatant hack to let us support using "yacc -d". If -d
+ # is not specified, we don't want an error when the header
+ # file is "missing".
+ if test $first = yes; then
+ ret=1
+ fi
+ fi
+ shift
+ shift
+ first=no
+ done
+else
+ ret=$?
+fi
+
+# Remove the directory.
+cd ..
+rm -rf $dirname
+
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End: