Commit ea02c485 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

expr: added support for operator ?:,&&,||

parent 76943353
2015-09-26 Uwe Schulzweida
* expr: added support for operator ?:,&&,||
2015-03-26 Uwe Schulzweida
* Version 1.6.8 released
......
CDO NEWS
--------
Version 1.6.9 (26 September 2015):
New features:
* expr: added support for operator ?:,&&,||
Version 1.6.8 (26 March 2015):
New features:
......
complete -W "
-- \
-- \
-- \
-L \
-M \
-O \
......@@ -29,6 +32,10 @@ adisit -adisit \
aexpr -aexpr \
aexprf -aexprf \
anomaly -anomaly \
ap2pl -ap2pl \
ap2pl_lp -ap2pl_lp \
ap2plx -ap2plx \
ap2plx_lp -ap2plx_lp \
asin -asin \
atan -atan \
atan2 -atan2 \
......@@ -54,16 +61,17 @@ chunit -chunit \
chvar -chvar \
cloudlayer -cloudlayer \
cmd -cmd \
collgrid -collgrid \
com -com \
command -command \
complextorect -complextorect \
consecsum -consecsum \
consects -consects \
const -const \
contour -contour \
conv_cmor_table -conv_cmor_table \
copy -copy \
cos -cos \
coshill -coshill \
covar0 -covar0 \
covar0r -covar0r \
dayavg -dayavg \
......@@ -93,6 +101,7 @@ diffc -diffc \
diffn -diffn \
diffp -diffp \
diffv -diffv \
distgrid -distgrid \
div -div \
divc -divc \
divcoslat -divcoslat \
......@@ -206,21 +215,20 @@ genbic -genbic \
genbil -genbil \
gencon -gencon \
gencon2 -gencon2 \
gencons -gencons \
gendis -gendis \
gengrid -gengrid \
genlaf -genlaf \
gennn -gennn \
genycon -genycon \
geopotheight -geopotheight \
ggstat -ggstat \
ggstats -ggstats \
gheight -gheight \
globavg -globavg \
gp2fc -gp2fc \
gp2sp -gp2sp \
gp2spl -gp2spl \
gradsdes -gradsdes \
graph -graph \
grfill -grfill \
gridarea -gridarea \
gridboxavg -gridboxavg \
gridboxmax -gridboxmax \
......@@ -423,7 +431,6 @@ remapbil -remapbil \
remapcon -remapcon \
remapcon1 -remapcon1 \
remapcon2 -remapcon2 \
remapcons -remapcons \
remapdis -remapdis \
remapdis1 -remapdis1 \
remapeta -remapeta \
......@@ -432,6 +439,7 @@ remapeta_z -remapeta_z \
remaplaf -remaplaf \
remapnn -remapnn \
remapsum -remapsum \
remapycon -remapycon \
replace -replace \
retocomplex -retocomplex \
rhopot -rhopot \
......@@ -533,7 +541,6 @@ setvar -setvar \
setvrange -setvrange \
setyear -setyear \
setzaxis -setzaxis \
shaded -shaded \
shifttime -shifttime \
showcode -showcode \
showdate -showdate \
......@@ -570,6 +577,7 @@ sp2fc -sp2fc \
sp2gp -sp2gp \
sp2gpl -sp2gpl \
sp2sp -sp2sp \
spartab -spartab \
spcut -spcut \
specinfo -specinfo \
spectrum -spectrum \
......@@ -588,6 +596,7 @@ splitsel -splitsel \
splittabnum -splittabnum \
splitvar -splitvar \
splityear -splityear \
splityearmon -splityearmon \
splitzaxis -splitzaxis \
sqr -sqr \
sqrt -sqrt \
......@@ -595,7 +604,6 @@ ssopar -ssopar \
stdatm -stdatm \
stimelogo -stimelogo \
strbre -strbre \
stream -stream \
strgal -strgal \
strwin -strwin \
studentt -studentt \
......@@ -610,7 +618,9 @@ template1 -template1 \
template2 -template2 \
test -test \
test2 -test2 \
testcellsearch -testcellsearch \
testdata -testdata \
testpointsearch -testpointsearch \
thinout -thinout \
timavg -timavg \
timcor -timcor \
......@@ -653,8 +663,8 @@ varquot2test -varquot2test \
varrms -varrms \
vct -vct \
vct2 -vct2 \
vector -vector \
vertavg -vertavg \
vertint -vertint \
vertmax -vertmax \
vertmean -vertmean \
vertmin -vertmin \
......@@ -734,12 +744,16 @@ ymonsub -ymonsub \
ymonsum -ymonsum \
ymonvar -ymonvar \
ymonvar1 -ymonvar1 \
yseasadd -yseasadd \
yseasavg -yseasavg \
yseasdiv -yseasdiv \
yseasmax -yseasmax \
yseasmean -yseasmean \
yseasmin -yseasmin \
yseasmul -yseasmul \
yseaspctl -yseaspctl \
yseasstd -yseasstd \
yseassub -yseassub \
yseassum -yseassum \
yseasvar -yseasvar \
zaxisdes -zaxisdes \
......
set cdoCmpl = (\
- \
- \
- \
L \
M \
O \
......@@ -29,6 +32,10 @@ adisit \
aexpr \
aexprf \
anomaly \
ap2pl \
ap2pl_lp \
ap2plx \
ap2plx_lp \
asin \
atan \
atan2 \
......@@ -54,16 +61,17 @@ chunit \
chvar \
cloudlayer \
cmd \
collgrid \
com \
command \
complextorect \
consecsum \
consects \
const \
contour \
conv_cmor_table \
copy \
cos \
coshill \
covar0 \
covar0r \
dayavg \
......@@ -93,6 +101,7 @@ diffc \
diffn \
diffp \
diffv \
distgrid \
div \
divc \
divcoslat \
......@@ -206,21 +215,20 @@ genbic \
genbil \
gencon \
gencon2 \
gencons \
gendis \
gengrid \
genlaf \
gennn \
genycon \
geopotheight \
ggstat \
ggstats \
gheight \
globavg \
gp2fc \
gp2sp \
gp2spl \
gradsdes \
graph \
grfill \
gridarea \
gridboxavg \
gridboxmax \
......@@ -423,7 +431,6 @@ remapbil \
remapcon \
remapcon1 \
remapcon2 \
remapcons \
remapdis \
remapdis1 \
remapeta \
......@@ -432,6 +439,7 @@ remapeta_z \
remaplaf \
remapnn \
remapsum \
remapycon \
replace \
retocomplex \
rhopot \
......@@ -533,7 +541,6 @@ setvar \
setvrange \
setyear \
setzaxis \
shaded \
shifttime \
showcode \
showdate \
......@@ -570,6 +577,7 @@ sp2fc \
sp2gp \
sp2gpl \
sp2sp \
spartab \
spcut \
specinfo \
spectrum \
......@@ -588,6 +596,7 @@ splitsel \
splittabnum \
splitvar \
splityear \
splityearmon \
splitzaxis \
sqr \
sqrt \
......@@ -595,7 +604,6 @@ ssopar \
stdatm \
stimelogo \
strbre \
stream \
strgal \
strwin \
studentt \
......@@ -610,7 +618,9 @@ template1 \
template2 \
test \
test2 \
testcellsearch \
testdata \
testpointsearch \
thinout \
timavg \
timcor \
......@@ -653,8 +663,8 @@ varquot2test \
varrms \
vct \
vct2 \
vector \
vertavg \
vertint \
vertmax \
vertmean \
vertmin \
......@@ -734,12 +744,16 @@ ymonsub \
ymonsum \
ymonvar \
ymonvar1 \
yseasadd \
yseasavg \
yseasdiv \
yseasmax \
yseasmean \
yseasmin \
yseasmul \
yseaspctl \
yseasstd \
yseassub \
yseassum \
yseasvar \
zaxisdes \
......
compctl -k "(
-- \
-- \
-- \
-L \
-M \
-O \
......@@ -29,6 +32,10 @@ adisit -adisit \
aexpr -aexpr \
aexprf -aexprf \
anomaly -anomaly \
ap2pl -ap2pl \
ap2pl_lp -ap2pl_lp \
ap2plx -ap2plx \
ap2plx_lp -ap2plx_lp \
asin -asin \
atan -atan \
atan2 -atan2 \
......@@ -54,16 +61,17 @@ chunit -chunit \
chvar -chvar \
cloudlayer -cloudlayer \
cmd -cmd \
collgrid -collgrid \
com -com \
command -command \
complextorect -complextorect \
consecsum -consecsum \
consects -consects \
const -const \
contour -contour \
conv_cmor_table -conv_cmor_table \
copy -copy \
cos -cos \
coshill -coshill \
covar0 -covar0 \
covar0r -covar0r \
dayavg -dayavg \
......@@ -93,6 +101,7 @@ diffc -diffc \
diffn -diffn \
diffp -diffp \
diffv -diffv \
distgrid -distgrid \
div -div \
divc -divc \
divcoslat -divcoslat \
......@@ -206,21 +215,20 @@ genbic -genbic \
genbil -genbil \
gencon -gencon \
gencon2 -gencon2 \
gencons -gencons \
gendis -gendis \
gengrid -gengrid \
genlaf -genlaf \
gennn -gennn \
genycon -genycon \
geopotheight -geopotheight \
ggstat -ggstat \
ggstats -ggstats \
gheight -gheight \
globavg -globavg \
gp2fc -gp2fc \
gp2sp -gp2sp \
gp2spl -gp2spl \
gradsdes -gradsdes \
graph -graph \
grfill -grfill \
gridarea -gridarea \
gridboxavg -gridboxavg \
gridboxmax -gridboxmax \
......@@ -423,7 +431,6 @@ remapbil -remapbil \
remapcon -remapcon \
remapcon1 -remapcon1 \
remapcon2 -remapcon2 \
remapcons -remapcons \
remapdis -remapdis \
remapdis1 -remapdis1 \
remapeta -remapeta \
......@@ -432,6 +439,7 @@ remapeta_z -remapeta_z \
remaplaf -remaplaf \
remapnn -remapnn \
remapsum -remapsum \
remapycon -remapycon \
replace -replace \
retocomplex -retocomplex \
rhopot -rhopot \
......@@ -533,7 +541,6 @@ setvar -setvar \
setvrange -setvrange \
setyear -setyear \
setzaxis -setzaxis \
shaded -shaded \
shifttime -shifttime \
showcode -showcode \
showdate -showdate \
......@@ -570,6 +577,7 @@ sp2fc -sp2fc \
sp2gp -sp2gp \
sp2gpl -sp2gpl \
sp2sp -sp2sp \
spartab -spartab \
spcut -spcut \
specinfo -specinfo \
spectrum -spectrum \
......@@ -588,6 +596,7 @@ splitsel -splitsel \
splittabnum -splittabnum \
splitvar -splitvar \
splityear -splityear \
splityearmon -splityearmon \
splitzaxis -splitzaxis \
sqr -sqr \
sqrt -sqrt \
......@@ -595,7 +604,6 @@ ssopar -ssopar \
stdatm -stdatm \
stimelogo -stimelogo \
strbre -strbre \
stream -stream \
strgal -strgal \
strwin -strwin \
studentt -studentt \
......@@ -610,7 +618,9 @@ template1 -template1 \
template2 -template2 \
test -test \
test2 -test2 \
testcellsearch -testcellsearch \
testdata -testdata \
testpointsearch -testpointsearch \
thinout -thinout \
timavg -timavg \
timcor -timcor \
......@@ -653,8 +663,8 @@ varquot2test -varquot2test \
varrms -varrms \
vct -vct \
vct2 -vct2 \
vector -vector \
vertavg -vertavg \
vertint -vertint \
vertmax -vertmax \
vertmean -vertmean \
vertmin -vertmin \
......@@ -734,12 +744,16 @@ ymonsub -ymonsub \
ymonsum -ymonsum \
ymonvar -ymonvar \
ymonvar1 -ymonvar1 \
yseasadd -yseasadd \
yseasavg -yseasavg \
yseasdiv -yseasdiv \
yseasmax -yseasmax \
yseasmean -yseasmean \
yseasmin -yseasmin \
yseasmul -yseasmul \
yseaspctl -yseaspctl \
yseasstd -yseasstd \
yseassub -yseassub \
yseassum -yseassum \
yseasvar -yseasvar \
zaxisdes -zaxisdes \
......
......@@ -18,14 +18,18 @@
#define COMPGE(x,y) ((x) >= (y) ? 1 : 0)
#define COMPNE(x,y) (IS_NOT_EQUAL(x,y) ? 1 : 0)
#define COMPEQ(x,y) (IS_EQUAL(x,y) ? 1 : 0)
#define COMPLEG(x,y) ((x) < (y) ? -1 : ((x) > (y) ? 1 : 0))
#define COMPLEG(x,y) ((x) < (y) ? -1 : ((x) > (y) ? 1 : 0))
#define COMPAND(x,y) (IS_NOT_EQUAL(x,0) && IS_NOT_EQUAL(y,0) ? 1 : 0)
#define COMPOR(x,y) (IS_NOT_EQUAL(x,0) || IS_NOT_EQUAL(y,0) ? 1 : 0)
#define MVCOMPLT(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPLT(x,y))
#define MVCOMPGT(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPGT(x,y))
#define MVCOMPLE(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPLE(x,y))
#define MVCOMPGE(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPGE(x,y))
#define MVCOMPNE(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPNE(x,y))
#define MVCOMPEQ(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPEQ(x,y))
#define MVCOMPLEG(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPLEG(x,y))
#define MVCOMPLEG(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPLEG(x,y))
#define MVCOMPAND(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPAND(x,y))
#define MVCOMPOR(x,y) (DBL_IS_EQUAL((x),missval1) ? missval1 : COMPOR(x,y))
static double f_int(double x) { return ((int)(x)); }
static double f_nint(double x) { return (round(x)); }
......@@ -179,6 +183,13 @@ nodeType *expr_con_var(int oper, nodeType *p1, nodeType *p2)
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPLEG(cval, idat[i]);
else for ( i=0; i<n; ++i ) odat[i] = COMPLEG(cval, idat[i]);
break;
case AND:
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPAND(cval, idat[i]);
else for ( i=0; i<n; ++i ) odat[i] = COMPAND(cval, idat[i]);
case OR:
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPOR(cval, idat[i]);
else for ( i=0; i<n; ++i ) odat[i] = COMPOR(cval, idat[i]);
break;
default:
cdoAbort("%s: operator %c unsupported!", __func__, oper);
break;
......@@ -273,6 +284,14 @@ nodeType *expr_var_con(int oper, nodeType *p1, nodeType *p2)
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPLEG(idat[i], cval);
else for ( i=0; i<n; ++i ) odat[i] = COMPLEG(idat[i], cval);
break;
case AND:
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPAND(idat[i], cval);
else for ( i=0; i<n; ++i ) odat[i] = COMPAND(idat[i], cval);
break;
case OR:
if ( nmiss ) for ( i=0; i<n; ++i ) odat[i] = MVCOMPOR(idat[i], cval);
else for ( i=0; i<n; ++i ) odat[i] = COMPOR(idat[i], cval);
break;
default:
cdoAbort("%s: operator %c unsupported!", __func__, oper);
break;
......@@ -297,8 +316,8 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
long loff, loff1, loff2;
int nmiss;
int nmiss1 = p1->nmiss;
int nmiss2 = p2->nmiss;
int nmiss1 = p1->nmiss;
int nmiss2 = p2->nmiss;
double missval1 = p1->missval;
double missval2 = p2->missval;
......@@ -416,8 +435,16 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLEG(idat1[i], idat2[i]);
else for ( i=0; i<ngp; ++i ) odat[i] = COMPLEG(idat1[i], idat2[i]);
break;
case AND:
if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPAND(idat1[i], idat2[i]);
else for ( i=0; i<ngp; ++i ) odat[i] = COMPAND(idat1[i], idat2[i]);
break;
case OR:
if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPOR(idat1[i], idat2[i]);
else for ( i=0; i<ngp; ++i ) odat[i] = COMPOR(idat1[i], idat2[i]);
break;
default:
cdoAbort("%s: operator %c unsupported!", __func__, oper);
cdoAbort("%s: operator %d (%c) unsupported!", __func__, (int)oper, oper);
break;
}
}
......@@ -1053,6 +1080,8 @@ nodeType *expr_run(nodeType *p, parse_parm_t *parse_arg)
case NE: printf("\tcompNE\n"); break;
case EQ: printf("\tcompEQ\n"); break;
case LEG: printf("\tcompLEG\n"); break;
case AND: printf("\tcompAND\n"); break;
case OR: printf("\tcompOR\n"); break;
}
}
else
......
......@@ -350,8 +350,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 15
#define YY_END_OF_BUFFER 16
#define YY_NUM_RULES 17
#define YY_END_OF_BUFFER 18
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
......@@ -359,26 +359,27 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_acclist[85] =
static yyconst flex_int16_t yy_acclist[91] =
{ 0,
4, 4, 16, 14, 15, 13, 14, 15, 13, 15,
14, 15, 1, 14, 15, 7, 14, 15, 4, 7,
14, 15, 4, 14, 15, 7, 14, 15, 7, 14,
15, 7, 14, 15, 6, 14, 15,16389, 4, 6,
14, 15,16389, 6, 14, 15,16389, 6, 14, 15,
16389, 13, 12, 1, 4, 4, 4, 4, 10, 11,
9, 8197, 6,16389, 4, 6,16389, 6,16389, 4,
4, 8, 4, 6,16389, 3, 6,16389, 6,16389,
4, 2, 6,16389
4, 4, 18, 16, 17, 15, 16, 17, 15, 17,
16, 17, 1, 16, 17, 16, 17, 7, 16, 17,
4, 7, 16, 17, 4, 16, 17, 7, 16, 17,
7, 16, 17, 7, 16, 17, 6, 16, 17,16389,
4, 6, 16, 17,16389, 6, 16, 17,16389, 6,
16, 17,16389, 16, 17, 15, 12, 1, 13, 4,
4, 4, 4, 10, 11, 9, 8197, 6,16389, 4,
6,16389, 6,16389, 14, 4, 4, 8, 4, 6,
16389, 3, 6,16389, 6,16389, 4, 2, 6,16389
} ;
static yyconst flex_int16_t yy_accept[48] =
static yyconst flex_int16_t yy_accept[52] =
{ 0,
1, 2, 3, 4, 6, 9, 11, 13, 16, 19,
23, 26, 29, 32, 35, 39, 44, 48, 52, 53,
54, 55, 56, 57, 57, 58, 59, 59, 60, 61,
62, 62, 63, 65, 65, 68, 70, 70, 71, 72,
73, 76, 79, 81, 82, 85, 85
1, 2, 3, 4, 6, 9, 11, 13, 16, 18,
21, 25, 28, 31, 34, 37, 41, 46, 50, 54,
56, 57, 58, 59, 60, 61, 62, 62, 63, 64,
64, 65, 66, 67, 67, 68, 70, 70, 73, 75,
76, 76, 77, 78, 79, 82, 85, 87, 88, 91,
91
} ;
static yyconst flex_int32_t yy_ec[256] =
......@@ -386,17 +387,17 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 4, 5, 1, 6, 1, 1, 1, 1, 7,
8, 8, 9, 1, 9, 10, 8, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 8, 8, 12,
13, 14, 8, 1, 15, 15, 15, 16, 17, 15,
15, 15, 18, 15, 15, 16, 19, 15, 15, 20,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1, 1, 1, 8, 21, 1, 15, 15, 15, 16,
22, 15, 15, 15, 15, 15, 15, 16, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 8, 1, 8, 1, 1, 1, 1, 1,
1, 4, 5, 1, 6, 1, 1, 7, 1, 8,
9, 9, 10, 1, 10, 11, 9, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 9, 9, 13,
14, 15, 9, 1, 16, 16, 16, 17, 18, 16,
16, 16, 19, 16, 16, 17, 20, 16, 16, 21,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
1, 1, 1, 9, 22, 1, 16, 16, 16, 17,
23, 16, 16, 16, 16, 16, 16, 17, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 9, 24, 9, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,