diff options
Diffstat (limited to 'Source/cmExprParserHelper.cxx')
-rw-r--r-- | Source/cmExprParserHelper.cxx | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index c5ecde4..2ba9b8d 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -16,7 +16,7 @@ #include "cmExprLexer.h" -int cmExpr_yyparse( yyscan_t yyscanner ); +int cmExpr_yyparse(yyscan_t yyscanner); // cmExprParserHelper::cmExprParserHelper() { @@ -24,7 +24,6 @@ cmExprParserHelper::cmExprParserHelper() this->FileName = 0; } - cmExprParserHelper::~cmExprParserHelper() { this->CleanupParser(); @@ -32,11 +31,10 @@ cmExprParserHelper::~cmExprParserHelper() int cmExprParserHelper::ParseString(const char* str, int verb) { - if ( !str) - { + if (!str) { return 0; - } - //printf("Do some parsing: %s\n", str); + } + // printf("Do some parsing: %s\n", str); this->Verbose = verb; this->InputBuffer = str; @@ -50,20 +48,18 @@ int cmExprParserHelper::ParseString(const char* str, int verb) cmExpr_yyset_extra(this, yyscanner); int res = cmExpr_yyparse(yyscanner); cmExpr_yylex_destroy(yyscanner); - if ( res != 0 ) - { - //str << "CAL_Parser returned: " << res << std::endl; - //std::cerr << "When parsing: [" << str << "]" << std::endl; + if (res != 0) { + // str << "CAL_Parser returned: " << res << std::endl; + // std::cerr << "When parsing: [" << str << "]" << std::endl; return 0; - } + } this->CleanupParser(); - if ( Verbose ) - { - std::cerr << "Expanding [" << str << "] produced: [" - << this->Result << "]" << std::endl; - } + if (Verbose) { + std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]" + << std::endl; + } return 1; } @@ -73,27 +69,22 @@ void cmExprParserHelper::CleanupParser() int cmExprParserHelper::LexInput(char* buf, int maxlen) { - //std::cout << "JPLexInput "; - //std::cout.write(buf, maxlen); - //std::cout << std::endl; - if ( maxlen < 1 ) - { + // std::cout << "JPLexInput "; + // std::cout.write(buf, maxlen); + // std::cout << std::endl; + if (maxlen < 1) { return 0; + } + if (this->InputBufferPos < this->InputBuffer.size()) { + buf[0] = this->InputBuffer[this->InputBufferPos++]; + if (buf[0] == '\n') { + this->CurrentLine++; } - if ( this->InputBufferPos < this->InputBuffer.size() ) - { - buf[0] = this->InputBuffer[ this->InputBufferPos++ ]; - if ( buf[0] == '\n' ) - { - this->CurrentLine ++; - } - return(1); - } - else - { + return (1); + } else { buf[0] = '\n'; - return( 0 ); - } + return (0); + } } void cmExprParserHelper::Error(const char* str) @@ -108,5 +99,3 @@ void cmExprParserHelper::SetResult(int value) { this->Result = value; } - - |