Flex fail on call second program
Greetings to all and thanks advances for paying attention to my mail
I have a mistake just baffling
I run my first program and next gets output correct
Number : 1
.
Number : 1
.
Number : 0
-
Stage : snapshot
Build : 20190729201751
So y run a second program but i get a incorrect result
Name :1
Should be Number : 1 like in first ran program
The program entry is the same, they differ in that one is the test
program (cunit) and the second is the productive program, in both cases
the complete scanner is called from a shared library generated in cmake
and the scanner is generated in C ++
the first rule in flex file is
Code:
{DIGIT}{1,11} {
std::cout << "Number : " <<
yytext << std::endl;
yylval->build< int >(atoi(yytext));
return token::NUMBER;
}
when run the second program no call this rule it call final rule
Code:
{NAME} {
std::cout << "Name: " << yytext << std::endl;
yylval->build< std::string >( yytext );
return token::NAME;
}
my question is why this differ is the same input, the same class scanner
only different program.
first program https://github.com/azaeldevel/toolkit.git commit
8b4845dda686321fbaf0d9e6a5abc04992dd6f24
second program https://github.com/azaeldevel/apidb.git commit
c887addfdc0a7fbad80df3571a8214c5e0bb8d34
I appreciate any comments
Re: Flex fail on call second program
Well I can see in the first rule the cout << "Number" and in the second cout << "Name" - which is what you're seeing displayed. So why do you expect to see Number displayed from the second?
Re: Flex fail on call second program
2kaud I expect the same result in both programs bacause I use the same Analyzer with the same input
Re: Flex fail on call second program
this is the flex file
Code:
{DIGIT}{1,11} {
std::cout << "Number : " << yytext << std::endl;
yylval->build< int >( atoi(yytext) );
return token::NUMBER;
}
"." {
std::cout << yytext << std::endl;
return token::DOT;
}
"-" {
std::cout <<yytext << std::endl;
return token::DASH;
}
"snapshot" {std::cout << "Stage : " << yytext << std::endl;yylval->build< std::string >( yytext );return token::SNAPSHOT;}
"alpha" {std::cout << "Stage : " << yytext << std::endl;yylval->build< std::string >( yytext );return token::ALPHA;}
"beta" {std::cout << "Stage : " << yytext << std::endl;yylval->build< std::string >( yytext );return token::BETA;}
"rc" {std::cout << "Stage : " << yytext << std::endl;yylval->build< std::string >( yytext );return token::RC;}
"release" {std::cout << "Stage : " << yytext << std::endl;yylval->build< std::string >( yytext );return token::RELEASE;}
{DIGIT}{12,16} {
std::cout << "Build : " << yytext << std::endl;
yylval->build< unsigned long >( std::stoul(yytext) );
return token::BUILD;
}
{NAME} {std::cout << "Name: " << yytext << std::endl; yylval->build< std::string >( yytext ); return token::NAME;}
{SPACE}+ ;
[\n\0] {return token::END;}
. {
ECHO;
}
<<EOF>> yyterminate() ;