Skip to content

Commit fddc6b4

Browse files
authoredMay 1, 2020
Merge pull request #35996 from agiudiceandrea/patch-int64-qgsexpression
Fix int64 literals parsing in QgsExpression
2 parents 253c706 + aa5141c commit fddc6b4

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed
 

‎src/core/qgsexpressionlexer.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ string "'"{str_char}*"'"
209209
if( ok )
210210
return NUMBER_INT;
211211
212+
yylval->numberInt64 = cLocale()->toLongLong( QString::fromLatin1(yytext), &ok );
213+
if( ok )
214+
return NUMBER_INT64;
215+
212216
yylval->numberFloat = cLocale()->toDouble( QString::fromLatin1(yytext), &ok );
213217
if( ok )
214218
return NUMBER_FLOAT;

‎src/core/qgsexpressionparser.yy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void addParserLocation(YYLTYPE* yyloc, QgsExpressionNode *node)
9797
QgsExpressionNode::NamedNode* namednode;
9898
double numberFloat;
9999
int numberInt;
100+
qlonglong numberInt64;
100101
bool boolVal;
101102
QString* text;
102103
QgsExpressionNodeBinaryOperator::BinaryOperator b_op;
@@ -120,6 +121,7 @@ void addParserLocation(YYLTYPE* yyloc, QgsExpressionNode *node)
120121
// literals
121122
%token <numberFloat> NUMBER_FLOAT
122123
%token <numberInt> NUMBER_INT
124+
%token <numberInt64> NUMBER_INT64
123125
%token <boolVal> BOOLEAN
124126
%token NULLVALUE
125127

@@ -326,6 +328,7 @@ expression:
326328
// literals
327329
| NUMBER_FLOAT { $$ = new QgsExpressionNodeLiteral( QVariant($1) ); }
328330
| NUMBER_INT { $$ = new QgsExpressionNodeLiteral( QVariant($1) ); }
331+
| NUMBER_INT64 { $$ = new QgsExpressionNodeLiteral( QVariant($1) ); }
329332
| BOOLEAN { $$ = new QgsExpressionNodeLiteral( QVariant($1) ); }
330333
| STRING { $$ = new QgsExpressionNodeLiteral( QVariant(*$1) ); delete $1; }
331334
| NULLVALUE { $$ = new QgsExpressionNodeLiteral( QVariant() ); }

‎tests/src/core/testqgsexpression.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ class TestQgsExpression: public QObject
558558
// literal evaluation
559559
QTest::newRow( "literal null" ) << "NULL" << false << QVariant();
560560
QTest::newRow( "literal int" ) << "123" << false << QVariant( 123 );
561+
QTest::newRow( "literal int64" ) << "1234567890123456789" << false << QVariant( qlonglong( 1234567890123456789 ) );
561562
QTest::newRow( "literal double" ) << "1.2" << false << QVariant( 1.2 );
562563
QTest::newRow( "literal text" ) << "'hello'" << false << QVariant( "hello" );
563564
QTest::newRow( "literal double" ) << ".000001" << false << QVariant( 0.000001 );

0 commit comments

Comments
 (0)
Please sign in to comment.