I'm trying to compile the provided c++ example from the doc:
%{
#include <iostream>
using namespace std;
int mylineno = 0;
%}
%option noyywrap c++
string \"[^\n"]+\"
ws [ \t]+
alpha [A-Za-z]
dig [0-9]
name ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])*
num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)?
num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
number {num1}|{num2}
%%
{ws} /* skip blanks and tabs */
"/*" {
int c;
while((c = yyinput()) != 0)
{
if(c == '\n')
++mylineno;
else if(c == '*')
{
if((c = yyinput()) == '/')
break;
else
unput(c);
}
}
}
{number} cout << "number " << YYText() << '\n';
\n mylineno++;
{name} cout << "name " << YYText() << '\n';
{string} cout << "string " << YYText() << '\n';
%%
// This include is required if main() is an another source file.
//#include <FlexLexer.h>
int main( int /* argc */, char** /* argv */ )
{
FlexLexer* lexer = new yyFlexLexer;
while(lexer->yylex() != 0)
;
return 0;
}
I've also put the path to the winflexbison folder in my PATH environment variable. Using this CMake file:
cmake_minimum_required(VERSION 3.17)
project(myproject)
set(CMAKE_CXX_STANDARD 11)
find_package(BISON)
find_package(FLEX)
FLEX_TARGET(lexer lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)
add_executable(myproject main.cpp ${FLEX_lexer_OUTPUTS})
It will always say:
fatal error: FlexLexer.h: No such file or directory
^
compilation terminated.
Inside the lexer.cpp file generated is not able to localize FlexLexer.h. Am I missing something?
I'm trying to compile the provided c++ example from the doc:
I've also put the path to the winflexbison folder in my PATH environment variable. Using this CMake file:
It will always say:
Inside the
lexer.cppfile generated is not able to localizeFlexLexer.h. Am I missing something?