Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 7ad14fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/analysis/raster/qgsrastercalclexer.ll
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/raster/qgsrastercalcparser.yy
Expand Up @@ -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
Expand All @@ -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); }
Expand Down

0 comments on commit 7ad14fc

Please sign in to comment.