summaryrefslogtreecommitdiffstats
path: root/Source/LexerParser/cmExprLexer.in.l
diff options
context:
space:
mode:
authorDaniel Franke <franke@edf-online.de>2018-05-18 19:59:46 (GMT)
committerBrad King <brad.king@kitware.com>2018-06-26 18:15:21 (GMT)
commit7c4c13ffef87d748b896e2c762ad0b2c00afcd31 (patch)
tree912ac1661b74cc13fbc735eb8a38f617c1598de9 /Source/LexerParser/cmExprLexer.in.l
parent5b0f73a15a7b49461123a969bbebceff4284df9c (diff)
downloadCMake-7c4c13ffef87d748b896e2c762ad0b2c00afcd31.zip
CMake-7c4c13ffef87d748b896e2c762ad0b2c00afcd31.tar.gz
CMake-7c4c13ffef87d748b896e2c762ad0b2c00afcd31.tar.bz2
math: Reject unexpected expression input explicitly
Switch to C++ exceptions for lexer/parser error handling. Teach the lexer/parser to fail on unexpected input.
Diffstat (limited to 'Source/LexerParser/cmExprLexer.in.l')
-rw-r--r--Source/LexerParser/cmExprLexer.in.l6
1 files changed, 5 insertions, 1 deletions
diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l
index e5f177a..0c4eb9e 100644
--- a/Source/LexerParser/cmExprLexer.in.l
+++ b/Source/LexerParser/cmExprLexer.in.l
@@ -28,6 +28,8 @@ Modify cmExprLexer.cxx:
/* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h"
+#include <string>
+
/*--------------------------------------------------------------------------*/
%}
@@ -38,8 +40,9 @@ Modify cmExprLexer.cxx:
%pointer
%%
+[ \t] {}
-[0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
+[0-9][0-9]* { yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; }
"+" { return exp_PLUS; }
"-" { return exp_MINUS; }
@@ -54,5 +57,6 @@ Modify cmExprLexer.cxx:
">>" { return exp_SHIFTRIGHT; }
"(" { return exp_OPENPARENT; }
")" { return exp_CLOSEPARENT; }
+. {return exp_UNEXPECTED;}
%%