diff options
author | ericm <ericm> | 2000-05-18 22:29:55 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-05-18 22:29:55 (GMT) |
commit | b18b0c87fd558e2ac08afee5f57cf63d26e8616c (patch) | |
tree | 09f7bd8bceecf28f329ecac1c3595ad42b49d34c /generic/tclGetDate.y | |
parent | a8277571fc968b11adf51c2fb8071937cd1bdf2e (diff) | |
download | tcl-b18b0c87fd558e2ac08afee5f57cf63d26e8616c.zip tcl-b18b0c87fd558e2ac08afee5f57cf63d26e8616c.tar.gz tcl-b18b0c87fd558e2ac08afee5f57cf63d26e8616c.tar.bz2 |
* tests/clock.test: Added test for "2 days 2 hours ago" style
specifications.
* generic/tclDate.c: Regenerated from tclGetDate.y.
* generic/tclGetDate.y: Tweaked grammar to properly handle the
"ago" keyword when it follows multiple relative unit specifiers,
as in "2 days 2 hours ago". [Bug: 5497].
Diffstat (limited to 'generic/tclGetDate.y')
-rw-r--r-- | generic/tclGetDate.y | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index f34cb9c..b7da254 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclGetDate.y,v 1.15 2000/02/28 18:49:42 ericm Exp $ + * RCS: @(#) $Id: tclGetDate.y,v 1.16 2000/05/18 22:29:56 ericm Exp $ */ %{ @@ -147,7 +147,7 @@ yyparse _ANSI_ARGS_((void)); %type <Number> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT tDST %type <Number> tSEC_UNIT tSNUMBER tUNUMBER tZONE tISOBASE tDAY_UNIT -%type <Number> unit ago sign tNEXT tSTARDATE +%type <Number> unit sign tNEXT tSTARDATE %type <Meridian> tMERIDIAN o_merid %% @@ -357,11 +357,18 @@ trek : tSTARDATE tUNUMBER '.' tUNUMBER { } ; -relspec : sign tUNUMBER unit ago { *yyRelPointer += $1 * $2 * $3 * $4; } - | tUNUMBER unit ago { *yyRelPointer += $1 * $2 * $3; } - | tNEXT unit { *yyRelPointer += $2; } - | tNEXT tUNUMBER unit { *yyRelPointer += $2 * $3; } - | unit ago { *yyRelPointer += $1 * $2; } +relspec : relunits tAGO { + yyRelSeconds *= -1; + yyRelMonth *= -1; + yyRelDay *= -1; + } + | relunits + ; +relunits : sign tUNUMBER unit { *yyRelPointer += $1 * $2 * $3; } + | tUNUMBER unit { *yyRelPointer += $1 * $2; } + | tNEXT unit { *yyRelPointer += $2; } + | tNEXT tUNUMBER unit { *yyRelPointer += $2 * $3; } + | unit { *yyRelPointer += $1; } ; sign : '-' { $$ = -1; } | '+' { $$ = 1; } @@ -370,9 +377,6 @@ unit : tSEC_UNIT { $$ = $1; yyRelPointer = &yyRelSeconds; } | tDAY_UNIT { $$ = $1; yyRelPointer = &yyRelDay; } | tMONTH_UNIT { $$ = $1; yyRelPointer = &yyRelMonth; } ; -ago : tAGO { $$ = -1; } - | { $$ = 1; } - ; number : tUNUMBER { |