Skip to content
Permalink
Browse files

Fix lexer/parser for raster calculator and min/max functions

  • Loading branch information
pblottiere authored and nyalldawson committed Jun 17, 2020
1 parent c0f8dea commit 7ad14fcd4fa7a611738ec9f67a6f8c17d7eb06a6
Showing with 4 additions and 3 deletions.
  1. +2 −2 src/analysis/raster/qgsrastercalclexer.ll
  2. +2 −1 src/analysis/raster/qgsrastercalcparser.yy
@@ -63,8 +63,8 @@ raster_band_ref_quoted \"(\\.|[^"])*\"
"ln" { rasterlval.op = QgsRasterCalcNode::opLOG; return FUNCTION;}
"log10" { rasterlval.op = QgsRasterCalcNode::opLOG10; return FUNCTION;}
"abs" { rasterlval.op = QgsRasterCalcNode::opABS; return FUNCTION;}
"min" { rasterlval.op = QgsRasterCalcNode::opMIN; return FUNCTION;}
"max" { rasterlval.op = QgsRasterCalcNode::opMAX; return FUNCTION;}
"min" { rasterlval.op = QgsRasterCalcNode::opMIN; return FUNCTION_2_ARGS;}
"max" { rasterlval.op = QgsRasterCalcNode::opMAX; return FUNCTION_2_ARGS;}
"AND" { return AND; }
"OR" { return OR; }
@@ -56,6 +56,7 @@
%token RASTER_BAND_REF
%token<number> NUMBER
%token<op> FUNCTION
%token<op> FUNCTION_2_ARGS

%type <node> root
%type <node> raster_exp
@@ -79,7 +80,7 @@ root: raster_exp{}

raster_exp:
FUNCTION '(' raster_exp ')' { $$ = new QgsRasterCalcNode($1, $3, 0); joinTmpNodes($$, $3, 0);}
| FUNCTION '(' raster_exp ',' raster_exp ')' { $$ = new QgsRasterCalcNode($1, $3, $5); joinTmpNodes($$, $3, $5);}
| FUNCTION_2_ARGS '(' raster_exp ',' raster_exp ')' { $$ = new QgsRasterCalcNode($1, $3, $5); joinTmpNodes($$, $3, $5);}
| raster_exp AND raster_exp { $$ = new QgsRasterCalcNode( QgsRasterCalcNode::opAND, $1, $3 ); joinTmpNodes($$,$1,$3); }
| raster_exp OR raster_exp { $$ = new QgsRasterCalcNode( QgsRasterCalcNode::opOR, $1, $3 ); joinTmpNodes($$,$1,$3); }
| raster_exp '=' raster_exp { $$ = new QgsRasterCalcNode( QgsRasterCalcNode::opEQ, $1, $3 ); joinTmpNodes($$,$1,$3); }

0 comments on commit 7ad14fc

Please sign in to comment.
You can’t perform that action at this time.