summaryrefslogtreecommitdiffstats
path: root/generic/tclGetDate.y
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2019-07-15 12:12:05 (GMT)
committersebres <sebres@users.sourceforge.net>2019-07-15 12:12:05 (GMT)
commitc587280d004ba2c60c5b1ce29dfecd3b6dc12e6d (patch)
tree62480d498b87837f4e1f9bc8f1b8aa8d7db7b236 /generic/tclGetDate.y
parentcf0b861eb9fdb52c27d15aa46635608146226c6b (diff)
downloadtcl-c587280d004ba2c60c5b1ce29dfecd3b6dc12e6d.zip
tcl-c587280d004ba2c60c5b1ce29dfecd3b6dc12e6d.tar.gz
tcl-c587280d004ba2c60c5b1ce29dfecd3b6dc12e6d.tar.bz2
**interim** try simplify info-structure (replace yyHave... with flags)
Diffstat (limited to 'generic/tclGetDate.y')
-rw-r--r--generic/tclGetDate.y46
1 files changed, 22 insertions, 24 deletions
diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y
index 88432ec..cf1f674 100644
--- a/generic/tclGetDate.y
+++ b/generic/tclGetDate.y
@@ -75,6 +75,13 @@
#define SECSPERDAY (24L * 60L * 60L)
#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
+#define yyIncrFlags(f) \
+ do { \
+ info->errFlags |= (info->flags & (f)); \
+ if (info->errFlags) { YYABORT; } \
+ info->flags |= (f); \
+ } while (0);
+
/*
* An entry in the lexical lookup table.
*/
@@ -163,31 +170,28 @@ spec : /* NULL */
;
item : time {
- yyHaveTime++;
+ yyIncrFlags(CLF_TIME);
}
| zone {
- yyHaveZone++;
+ yyIncrFlags(CLF_ZONE);
}
| date {
- yyHaveDate++;
+ yyIncrFlags(CLF_HAVEDATE);
}
| ordMonth {
- yyHaveOrdinalMonth++;
+ yyIncrFlags(CLF_ORDINALMONTH);
}
| day {
- yyHaveDay++;
+ yyIncrFlags(CLF_DAYOFWEEK);
}
| relspec {
- yyHaveRel++;
+ yyIncrFlags(CLF_RELCONV);
}
| iso {
- yyHaveTime++;
- yyHaveDate++;
+ yyIncrFlags(CLF_TIME|CLF_HAVEDATE);
}
| trek {
- yyHaveTime++;
- yyHaveDate++;
- yyHaveRel++;
+ yyIncrFlags(CLF_TIME|CLF_HAVEDATE|CLF_RELCONV);
}
| number
;
@@ -245,32 +249,26 @@ comma : ','
day : tDAY {
yyDayOrdinal = 1;
yyDayOfWeek = $1;
- info->flags |= CLF_DAYOFWEEK;
}
| tDAY comma {
yyDayOrdinal = 1;
yyDayOfWeek = $1;
- info->flags |= CLF_DAYOFWEEK;
}
| tUNUMBER tDAY {
yyDayOrdinal = $1;
yyDayOfWeek = $2;
- info->flags |= CLF_DAYOFWEEK;
}
| sign SP tUNUMBER tDAY {
yyDayOrdinal = $1 * $3;
yyDayOfWeek = $4;
- info->flags |= CLF_DAYOFWEEK;
}
| sign tUNUMBER tDAY {
yyDayOrdinal = $1 * $2;
yyDayOfWeek = $3;
- info->flags |= CLF_DAYOFWEEK;
}
| tNEXT tDAY {
yyDayOrdinal = 2;
yyDayOfWeek = $2;
- info->flags |= CLF_DAYOFWEEK;
}
;
@@ -450,10 +448,10 @@ INTNUM : tUNUMBER {
;
number : INTNUM {
- if (yyHaveTime && yyHaveDate && !yyHaveRel) {
+ if ((info->flags & (CLF_TIME|CLF_HAVEDATE|CLF_RELCONV)) == (CLF_TIME|CLF_HAVEDATE)) {
yyYear = $1;
} else {
- yyHaveTime++;
+ yyIncrFlags(CLF_TIME);
if (yyDigitCount <= 2) {
yyHour = $1;
yyMinutes = 0;
@@ -1029,31 +1027,31 @@ TclClockFreeScan(
}
Tcl_DecrRefCount(info->messages);
- if (yyHaveDate > 1) {
+ if (info->errFlags & CLF_HAVEDATE) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("more than one date in string", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", NULL);
return TCL_ERROR;
}
- if (yyHaveTime > 1) {
+ if (info->errFlags & CLF_TIME) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("more than one time of day in string", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", NULL);
return TCL_ERROR;
}
- if (yyHaveZone > 1) {
+ if (info->errFlags & CLF_ZONE) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("more than one time zone in string", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", NULL);
return TCL_ERROR;
}
- if (yyHaveDay > 1) {
+ if (info->errFlags & CLF_DAYOFWEEK) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("more than one weekday in string", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", NULL);
return TCL_ERROR;
}
- if (yyHaveOrdinalMonth > 1) {
+ if (info->errFlags & CLF_ORDINALMONTH) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("more than one ordinal month in string", -1));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", NULL);