FlexLexer.h kann nicht gefunden werden

RezaScript

Newbie
Registriert
Okt. 2018
Beiträge
7
Hallo,

ich habe die aktuellste Version des Programms Flex heruntergeladen und installiert.

Die Datei lex.yy.cpp habe ich mit dem Command flex scanner.l generieren lassen und die Datei scanner.cpp habe ich selber erstellt. Wenn ich also den Command gcc scanner.cpp lex.yy.cpp -o scanner eingebe, erhalte ich die Fehlermeldung:

scanner.cpp:239:10: fatal error: FlexLexer.h: No such file or directory

Die Datei lex.yy.cpp (welche automatisch generiert wurde), beinhaltet #include <FlexLexer.h>. Wieso kann die Datei denn nicht gefunden werden und wie komme ich zu dieser Datei?
 
Ich hab schon alles mögliche ausprobiert. sudo apt-get update,
#include <Win\FlexLexer.h> ... scheint nichts zu funktionieren?!
 
Suche nach "FlexLexer.h":
Code:
find / -name "FlexLexer.h"

Diese Suche spuckt (hoffentlich) (mindestens) einen Treffer aus in der Art
Code:
/xxx/yyy/zzzzzz/FlexLexer.h
aus.
Dann compilieren mit
Code:
gcc -I/xxx/yyy/zzzzzz/ scanner.cpp lex.yy.cpp -o scanner
Du fügst also mit "-I/xxx/yyy/zzzzzz/" den Pfad "/xxx/yyy/zzzzzz/" zu Deinem Include-Pfad hinzu.


HTH

BigNum
 
  • Gefällt mir
Reaktionen: BFF
Für mich sieht das so aus, als wäre flex nicht richtig installiert.
FlexLexer.h müsste sich erstmal in deinem Download-Ordner befinden und wird beim install nach /usr/...
kopiert und ist erst dann über den Standardpfad inkludierbar.

Ich kann dir also wie @BFF und @BigNum nur raten, einfach mal nach der Datei zu suchen, dann weißt du, woran du bist. Wenn sie in deinem Download-Verzeichnis nicht ist, kann es nicht funktionieren. Wenn sie unter /usr nicht auffindbar ist, wurde es nicht korrekt installiert.
 
  • Gefällt mir
Reaktionen: BFF
Also ich denke schon, dass Flex bei mir richtig installiert ist.
black@LAPTOP-AV68QI6I MINGW64 ~/Desktop/projects/C++/test
$ flex --version
C:\Flex Windows\Lex\bin\flex.exe version 2.5.4

Ich habe mir mal die Datei FlexLexer.h aus dem Internet heruntergeladen. In der generierten Datei (lex.yy.cpp) habe ich #include <FlexLexer.h> durch #include "FlexLexer.h" ersetzt und die Datei FlexLexer.h im selben Verzeichnis kopiert.

Wenn ich den Command nun ausführe, bekomme ich haufen Fehlermeldungen:
black@LAPTOP-AV68QI6I MINGW64 ~/Desktop/projects/C++
$ gcc scanner.cpp lex.yy.cpp -o scanner
scanner.l:25:16: error: macro "yywrap" passed 1 arguments, but takes just 0
int yywrap(void) {
^
lex.yy.cpp:233:18: error: expected unqualified-id before numeric constant
#define yywrap() 1
^
FlexLexer.h:145:15: note: in expansion of macro 'yywrap'
virtual int yywrap();
^~~~~~
lex.yy.cpp: In member function 'virtual int yyFlexLexer::yylex()':
lex.yy.cpp:496:12: error: 'cin' was not declared in this scope
yyin = &cin;
^~~
lex.yy.cpp:496:12: note: suggested alternative:
In file included from FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86 _64-w64-mingw32/8.1.0/include/c++/iostream:60:18: note: 'std::cin'
extern istream cin; /// Linked to standard input
^~~
lex.yy.cpp:499:13: error: 'cout' was not declared in this scope
yyout = &cout;
^~~~
lex.yy.cpp:499:13: note: suggested alternative:
In file included from FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86 _64-w64-mingw32/8.1.0/include/c++/iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^~~~
lex.yy.cpp:501:10: error: 'yy_current_buffer' was not declared in this scope
if ( ! yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:501:10: note: suggested alternative: 'yy_create_buffer'
if ( ! yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:628:8: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:628:8: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:651:23: error: 'yy_current_buffer' was not declared in this scope
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:651:23: note: suggested alternative: 'yy_create_buffer'
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:748:46: error: 'ostream' has not been declared
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
^~~~~~~
lex.yy.cpp:748:1: error: no declaration matches 'yyFlexLexer::yyFlexLexer(istrea m*, int*)'
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
FlexLexer.h:119:7: note: candidates are: 'yyFlexLexer::yyFlexLexer(const yyFlexL exer&)'
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
FlexLexer.h:124:3: note: 'yyFlexLexer::yyFlexLexer(std::istream* , std::ostream*)'
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
^~~~~~~~~~~
FlexLexer.h:123:3: note: 'yyFlexLexer::yyFlexLexer(std::istream& , std::ostream&)'
yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout );
^~~~~~~~~~~
FlexLexer.h:119:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In destructor 'virtual yyFlexLexer::~yyFlexLexer()':
lex.yy.cpp:780:20: error: 'yy_current_buffer' was not declared in this scope
yy_delete_buffer( yy_current_buffer );
^~~~~~~~~~~~~~~~~
lex.yy.cpp:780:20: note: suggested alternative: 'yy_create_buffer'
yy_delete_buffer( yy_current_buffer );
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:783:52: error: 'ostream' has not been declared
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
^~~~~~~
lex.yy.cpp:783:6: error: no declaration matches 'void yyFlexLexer::switch_stream s(istream*, int*)'
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
FlexLexer.h:144:16: note: candidates are: 'virtual void yyFlexLexer::switch_stre ams(std::istream*, std::ostream*)'
virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 );
^~~~~~~~~~~~~~
FlexLexer.h:143:16: note: 'virtual void yyFlexLexer::switch_stre ams(std::istream&, std::ostream&)'
virtual void switch_streams( std::istream& new_in, std::ostream& new_out );
^~~~~~~~~~~~~~
FlexLexer.h:119:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'virtual int yyFlexLexer::LexerInput(char*, int)' :
lex.yy.cpp:801:11: error: base operand of '->' has non-pointer type 'std::istrea m' {aka 'std::basic_istream<char>'}
if ( yyin->eof() || yyin->fail() )
^~
lex.yy.cpp:801:26: error: base operand of '->' has non-pointer type 'std::istrea m' {aka 'std::basic_istream<char>'}
if ( yyin->eof() || yyin->fail() )
^~
lex.yy.cpp:805:6: error: base operand of '->' has non-pointer type 'std::istream ' {aka 'std::basic_istream<char>'}
yyin->get( buf[0] );
^~
lex.yy.cpp:807:11: error: base operand of '->' has non-pointer type 'std::istrea m' {aka 'std::basic_istream<char>'}
if ( yyin->eof() )
^~
lex.yy.cpp:810:11: error: base operand of '->' has non-pointer type 'std::istrea m' {aka 'std::basic_istream<char>'}
if ( yyin->bad() )
^~
lex.yy.cpp: In member function 'virtual void yyFlexLexer::LexerOutput(const char *, int)':
lex.yy.cpp:827:14: error: base operand of '->' has non-pointer type 'std::ostrea m' {aka 'std::basic_ostream<char>'}
(void) yyout->write( buf, size );
^~
lex.yy.cpp: In member function 'int yyFlexLexer::yy_get_next_buffer()':
lex.yy.cpp:840:24: error: 'yy_current_buffer' was not declared in this scope
register char *dest = yy_current_buffer->yy_ch_buf;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:840:24: note: suggested alternative: 'yy_create_buffer'
register char *dest = yy_current_buffer->yy_ch_buf;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'void yyFlexLexer::yyunput(int, char*)':
lex.yy.cpp:1035:15: error: 'yy_current_buffer' was not declared in this scope
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1035:15: note: suggested alternative: 'yy_create_buffer'
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'int yyFlexLexer::yyinput()':
lex.yy.cpp:1077:22: error: 'yy_current_buffer' was not declared in this scope
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1077:22: note: suggested alternative: 'yy_create_buffer'
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1134:6: error: no declaration matches 'void yyFlexLexer::yyrestart(is tream*)'
void yyFlexLexer::yyrestart( istream* input_file )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
FlexLexer.h:137:8: note: candidates are: 'virtual void yyFlexLexer::yyrestart(st d::istream&)'
void yyrestart( std::istream& s );
^~~~~~~~~
FlexLexer.h:136:8: note: 'virtual void yyFlexLexer::yyrestart(st d::istream*)'
void yyrestart( std::istream* s );
^~~~~~~~~
FlexLexer.h:119:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'virtual void yyFlexLexer::yy_switch_to_buffer(YY _BUFFER_STATE)':
lex.yy.cpp:1146:7: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer == new_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1146:7: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer == new_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:1149:7: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1149:7: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:1157:2: error: 'yy_current_buffer' was not declared in this scope
yy_current_buffer = new_buffer;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1157:2: note: suggested alternative: 'yy_create_buffer'
yy_current_buffer = new_buffer;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'void yyFlexLexer::yy_load_buffer_state()':
lex.yy.cpp:1171:15: error: 'yy_current_buffer' was not declared in this scope
yy_n_chars = yy_current_buffer->yy_n_chars;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1171:15: note: suggested alternative: 'yy_create_buffer'
yy_n_chars = yy_current_buffer->yy_n_chars;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1178:17: error: no declaration matches 'yy_buffer_state* yyFlexLexer: :yy_create_buffer(istream*, int)'
YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
FlexLexer.h:134:20: note: candidates are: 'virtual yy_buffer_state* yyFlexLexer: :yy_create_buffer(std::istream&, int)'
yy_buffer_state* yy_create_buffer( std::istream& s, int size );
^~~~~~~~~~~~~~~~
FlexLexer.h:133:20: note: 'virtual yy_buffer_state* yyFlexLexer: :yy_create_buffer(std::istream*, int)'
yy_buffer_state* yy_create_buffer( std::istream* s, int size );
^~~~~~~~~~~~~~~~
FlexLexer.h:119:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'virtual void yyFlexLexer::yy_delete_buffer(YY_BU FFER_STATE)':
lex.yy.cpp:1208:12: error: 'yy_current_buffer' was not declared in this scope
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1208:12: note: suggested alternative: 'yy_create_buffer'
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1219:6: error: no declaration matches 'void yyFlexLexer::yy_init_buff er(YY_BUFFER_STATE, istream*)'
void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
FlexLexer.h:156:8: note: candidate is: 'void yyFlexLexer::yy_init_buffer(yy_buff er_state*, std::istream&)'
void yy_init_buffer( yy_buffer_state* b, std::istream& s );
^~~~~~~~~~~~~~
FlexLexer.h:119:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'void yyFlexLexer::yy_flush_buffer(YY_BUFFER_STAT E)':
lex.yy.cpp:1250:12: error: 'yy_current_buffer' was not declared in this scope
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1250:12: note: suggested alternative: 'yy_create_buffer'
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'virtual void yyFlexLexer::LexerError(const char* )':
lex.yy.cpp:1321:2: error: 'cerr' was not declared in this scope
cerr << msg << '\n';
^~~~
lex.yy.cpp:1321:2: note: suggested alternative:
In file included from FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86 _64-w64-mingw32/8.1.0/include/c++/iostream:62:18: note: 'std::cerr'
extern ostream cerr; /// Linked to standard error (unbuffered)
^~~~
scanner.l: At global scope:
scanner.l:26:5: error: expected primary-expression before 'return'
return 1;
^~~~~~
scanner.l:26:5: error: expected '}' before 'return'
scanner.l:25:18: note: to match this '{'
int yywrap(void) {
^
scanner.l:27:1: error: expected declaration before '}' token
}
^

Ich habe auch nach der Datei FlexLexer.h gesucht und die Datei wird tatsächlich auch gefunden:
C:\>dir /s FlexLexer.h
Datenträger in Laufwerk C: ist Windows
Volumeseriennummer: 66B1-2AE3

Verzeichnis von C:\Flex Windows

16.06.2014 22:45 6'423 FlexLexer.h
1 Datei(en), 6'423 Bytes

Verzeichnis von C:\Flex Windows\Lex\include

27.07.1997 04:41 5'749 FlexLexer.h
1 Datei(en), 5'749 Bytes

Verzeichnis von C:\Users\black\AppData\Local\Temp\Rar$EXa6296.20248

15.01.2018 10:44 7'113 FlexLexer.h
1 Datei(en), 7'113 Bytes

Verzeichnis von C:\Users\black\Desktop\projects\C++

15.01.2018 10:44 7'113 FlexLexer.h
1 Datei(en), 7'113 Bytes

Verzeichnis von C:\Users\black\Downloads

15.01.2018 10:44 7'113 FlexLexer.h
1 Datei(en), 7'113 Bytes

Verzeichnis von C:\Users\black\Downloads\win_flex_bison-latest

15.01.2018 10:44 7'113 FlexLexer.h
1 Datei(en), 7'113 Bytes

Anzahl der angezeigten Dateien:
6 Datei(en), 40'624 Bytes
0 Verzeichnis(se), 18'568'974'336 Bytes frei
 
Das sollte mal bei allen OpenSource-Quellcodes bedenken, Leerzeichen in Verzeichnisnamen zu vermeiden. Daher habe ich mir schon seit Jahren angewöhnt, zumindest die Leerzeichen hier durch _ zu ersetzen.
 
Danke euch für den Hinweis! Ich habe das Programm nochmals installiert und es befindet sich nun im c://Flex_Windows. In diesem Ordner finde ich zwar die Datei FlexLexer.h, wenn ich den Command gcc scanner.cpp lex.yy.cpp -o scanner ausführe, bekomme ich jedoch nach wie vor die Fehlermeldung, dass FlexLexer.h nicht gefunden werden konnte. Ich habe nun genau das gemacht was @BigNum gesagt hat:
gcc -I/c://Flex_Windows scanner.cpp lex.yy.cpp -o scanner

Dann bekomme ich nicht mehr die Fehlermeldung, dass die Datei nicht existiert aber dafür wie bereits erwähnt ganz viele Fehlermeldungen:
black@LAPTOP-AV68QI6I MINGW64 ~/Desktop/projects/C++
$ gcc -I/c://Flex_Windows scanner.cpp lex.yy.cpp -o scanner
scanner.l:25:16: error: macro "yywrap" passed 1 arguments, but takes just 0
int yywrap(void) {
^
lex.yy.cpp:233:18: error: expected unqualified-id before numeric constant
#define yywrap() 1
^
c:/Flex_Windows/FlexLexer.h:130:14: note: in expansion of macro 'yywrap'
virtual int yywrap();
^~~~~~
lex.yy.cpp: In member function 'virtual int yyFlexLexer::yylex()':
lex.yy.cpp:496:12: error: 'cin' was not declared in this scope
yyin = &cin;
^~~
lex.yy.cpp:496:12: note: suggested alternative:
In file included from c:/Flex_Windows/FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:60:18: note: 'std::cin'
extern istream cin; /// Linked to standard input
^~~
lex.yy.cpp:499:13: error: 'cout' was not declared in this scope
yyout = &cout;
^~~~
lex.yy.cpp:499:13: note: suggested alternative:
In file included from c:/Flex_Windows/FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^~~~
lex.yy.cpp:501:10: error: 'yy_current_buffer' was not declared in this scope
if ( ! yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:501:10: note: suggested alternative: 'yy_create_buffer'
if ( ! yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:628:8: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:628:8: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:651:23: error: 'yy_current_buffer' was not declared in this scope
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:651:23: note: suggested alternative: 'yy_create_buffer'
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:748:46: error: 'ostream' has not been declared
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
^~~~~~~
lex.yy.cpp:748:1: error: no declaration matches 'yyFlexLexer::yyFlexLexer(istream*, int*)'
yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
c:/Flex_Windows/FlexLexer.h:112:7: note: candidates are: 'constexpr yyFlexLexer::yyFlexLexer(const yyFlexLexer&)'
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
c:/Flex_Windows/FlexLexer.h:116:2: note: 'yyFlexLexer::yyFlexLexer(std::istream*, std::ostream*)'
yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
^~~~~~~~~~~
c:/Flex_Windows/FlexLexer.h:112:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In destructor 'virtual yyFlexLexer::~yyFlexLexer()':
lex.yy.cpp:780:20: error: 'yy_current_buffer' was not declared in this scope
yy_delete_buffer( yy_current_buffer );
^~~~~~~~~~~~~~~~~
lex.yy.cpp:780:20: note: suggested alternative: 'yy_create_buffer'
yy_delete_buffer( yy_current_buffer );
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:783:52: error: 'ostream' has not been declared
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
^~~~~~~
lex.yy.cpp:783:6: error: no declaration matches 'void yyFlexLexer::switch_streams(istream*, int*)'
void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
c:/Flex_Windows/FlexLexer.h:129:15: note: candidate is: 'virtual void yyFlexLexer::switch_streams(std::istream*, std::ostream*)'
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
^~~~~~~~~~~~~~
c:/Flex_Windows/FlexLexer.h:112:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'int yyFlexLexer::yy_get_next_buffer()':
lex.yy.cpp:840:24: error: 'yy_current_buffer' was not declared in this scope
register char *dest = yy_current_buffer->yy_ch_buf;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:840:24: note: suggested alternative: 'yy_create_buffer'
register char *dest = yy_current_buffer->yy_ch_buf;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'void yyFlexLexer::yyunput(int, char*)':
lex.yy.cpp:1035:15: error: 'yy_current_buffer' was not declared in this scope
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1035:15: note: suggested alternative: 'yy_create_buffer'
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'int yyFlexLexer::yyinput()':
lex.yy.cpp:1077:22: error: 'yy_current_buffer' was not declared in this scope
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1077:22: note: suggested alternative: 'yy_create_buffer'
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1134:6: error: no declaration matches 'void yyFlexLexer::yyrestart(istream*)'
void yyFlexLexer::yyrestart( istream* input_file )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
c:/Flex_Windows/FlexLexer.h:123:7: note: candidate is: 'virtual void yyFlexLexer::yyrestart(std::istream*)'
void yyrestart( FLEX_STD istream* s );
^~~~~~~~~
c:/Flex_Windows/FlexLexer.h:112:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'virtual void yyFlexLexer::yy_switch_to_buffer(YY_BUFFER_STATE)':
lex.yy.cpp:1146:7: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer == new_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1146:7: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer == new_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:1149:7: error: 'yy_current_buffer' was not declared in this scope
if ( yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1149:7: note: suggested alternative: 'yy_create_buffer'
if ( yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp:1157:2: error: 'yy_current_buffer' was not declared in this scope
yy_current_buffer = new_buffer;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1157:2: note: suggested alternative: 'yy_create_buffer'
yy_current_buffer = new_buffer;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'void yyFlexLexer::yy_load_buffer_state()':
lex.yy.cpp:1171:15: error: 'yy_current_buffer' was not declared in this scope
yy_n_chars = yy_current_buffer->yy_n_chars;
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1171:15: note: suggested alternative: 'yy_create_buffer'
yy_n_chars = yy_current_buffer->yy_n_chars;
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1178:17: error: no declaration matches 'yy_buffer_state* yyFlexLexer::yy_create_buffer(istream*, int)'
YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
c:/Flex_Windows/FlexLexer.h:121:26: note: candidate is: 'virtual yy_buffer_state* yyFlexLexer::yy_create_buffer(std::istream*, int)'
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
^~~~~~~~~~~~~~~~
c:/Flex_Windows/FlexLexer.h:112:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'virtual void yyFlexLexer::yy_delete_buffer(YY_BUFFER_STATE)':
lex.yy.cpp:1208:12: error: 'yy_current_buffer' was not declared in this scope
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1208:12: note: suggested alternative: 'yy_create_buffer'
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: At global scope:
lex.yy.cpp:1219:6: error: no declaration matches 'void yyFlexLexer::yy_init_buffer(YY_BUFFER_STATE, istream*)'
void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
^~~~~~~~~~~
In file included from lex.yy.cpp:239:
c:/Flex_Windows/FlexLexer.h:141:7: note: candidate is: 'void yyFlexLexer::yy_init_buffer(yy_buffer_state*, std::istream*)'
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
^~~~~~~~~~~~~~
c:/Flex_Windows/FlexLexer.h:112:7: note: 'class yyFlexLexer' defined here
class yyFlexLexer : public FlexLexer {
^~~~~~~~~~~
lex.yy.cpp: In member function 'void yyFlexLexer::yy_flush_buffer(YY_BUFFER_STATE)':
lex.yy.cpp:1250:12: error: 'yy_current_buffer' was not declared in this scope
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
lex.yy.cpp:1250:12: note: suggested alternative: 'yy_create_buffer'
if ( b == yy_current_buffer )
^~~~~~~~~~~~~~~~~
yy_create_buffer
lex.yy.cpp: In member function 'virtual void yyFlexLexer::LexerError(const char*)':
lex.yy.cpp:1321:2: error: 'cerr' was not declared in this scope
cerr << msg << '\n';
^~~~
lex.yy.cpp:1321:2: note: suggested alternative:
In file included from c:/Flex_Windows/FlexLexer.h:51,
from lex.yy.cpp:239:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:62:18: note: 'std::cerr'
extern ostream cerr; /// Linked to standard error (unbuffered)
^~~~
scanner.l: At global scope:
scanner.l:26:5: error: expected primary-expression before 'return'
return 1;
^~~~~~
scanner.l:26:5: error: expected '}' before 'return'
scanner.l:25:18: note: to match this '{'
int yywrap(void) {
^
scanner.l:27:1: error: expected declaration before '}' token
}
^

Mein eigener Code ist eigentlich relativ simple und ich kann mir nicht vorstellen, dass es daran liegt:
C++:
#include <stdio.h>
#include "scanner.h"

extern int yylex();
extern int yylineno;
extern char* yytext;

//char *names[] = {NULL, "db_type", "db_name", "db_table_prefix", "db_port"};

int main(void) {
    int ntoken, vtoken;

    ntoken = yylex();
    while (ntoken) {
        printf("%d\n", ntoken);
        ntoken = yylex();
    }
    return 0;
}
 
Zurück
Oben