gnu-flex

Most effective way to parse C-like definition strings?

Hello all. I've got a set of function definitions written in a C-like language with some additional keywords that can be put before some arguments(the same way as "unsigned" or "register", for example) and I need to analyze these lines as well as some function stubs and generate actual C code from them. Is that correct that Flex/Yacc ...

how to select inner matches in lex

Hello, am new to lex and I wanna take all the matches specific to a regular expression for example in the following text : /* text text text text text */ text text /* text text text text text text text text */ i wanna choose the two matches between /* and */ but lex matches the whole outer match and doen't return the two! I u...

How to make a flex (lexical scanner) to read UTF-8 characters input?

It seems that flex doesn't support UTF-8 input. Whenever the scanner encounter a non-ASCII char, it stops scanning as if it was an EOF. Is there a way to force flex to eat my UTF-8 chars? I don't want it to actually match UTF-8 chars, just eat them when using the '.' pattern. Any suggestion? EDIT The most simple solution would be: ...

Is it possible to get gcc to read from a pipe?

I'm looking for an option to gcc that will make it read a source file from the standard input, mainly so I could do something like this to generate an object file from a tool like flex that generates C code (flex's -t option writes the generated C to the standard output): flex -t lexer.l | gcc -o lexer.o -magic-option-here because I d...

Flex/Bison-like functionality within PHP

I'm looking for a way to get Flex/Bison (or Lex/Yacc, et. al.) support in PHP. Specifically, I'm implementing a boolean query parser in a web UI and would rather keep all operations inside of PHP (as opposed to calling a C parser, or passing things off to Python, etc.). ...

Bison (and flex) coding conventions

Hi, What are coding conventions and guidelines you suggest for writing Bison (.y) and flex (.lex) files? Please address the length of the code sections and their style. Thanks, Asaf P.S., There's an old thread about it here, but I'm looking for a more detailed answer (and to have it on SO!). ...

Flex and Bison Associativity Problem

Using Flex and Bison, I have a grammar specification for a boolean query language, which supports logical "and", "or", and "not" operations, as well as nested subexpressions using "()". All was well until I noticed that queries like "A and B or C and D" which I'd like parsed as "(A & B) | (C & D)" was actually being interpreted as "A & ...

Problem installing flex-2.5.33.tar.gz on linux (debian); 'make' fails

Hello, I'm trying to install 'flex'. I don't have a previous version of flex installed. I'm running a stripped down version of linux, so I don't have apt-get or yum. To install I untarred the flex package (flex-2.5.33.tar.gz) and ran ./configure (which works). However, then I ran make and it failed. I've attached the output of ./configur...

yyparse is printing a leading tab

In my bison/flex program, right after yyparse() is called, a leading tab is printed, but I don't know why. Can you see what's wrong? This calls the bison code, and right after yyparse() returns, a tab is printed. void parseArguments(int argc, char** argv) 130 { 131 int i; 132 133 int sum = 0; 134 // calculate the length of...

can Flex return a string match to bison

I'm writing a Bison/Flex program to convert LaTeX into MathML. At the moment, dealing with functions (i.e. \sqrt, \frac, etc) works like this, with a token for every function \\frac {return FUNC_FRAC;} and passes the token FUNC_FRAC back to bison, which plays its part in the description of this subtree: function: FUNC_FRAC L...

How can I use flex on windows?

I'm trying to compile a project on windows and it uses flex/bison. Compiling the flex and bison files went fine after I installed MinGW, but when I get to the final step of the build of: g++ -o hexciting CommandParser.tab.o CommandParser.yy.o Command.o -lfl It says the library can't be found. After some time on google, I tried chang...

Start states in Lex / Flex

I'm using Flex and Bison for a parser generator, but having problems with the start states in my scanner. I'm using exclusive rules to deal with commenting, but this grammar doesn't seem to match quoted tokens: %x COMMENT // { BEGIN(COMMENT); } <COMMENT>[^\n] ; <COMMENT>\n { BEGIN(INITIAL); } "==" ...

When will a newer version of flex for windows be available?

I'm using flex (lexical analyzer, not Adobe Flex) on a project. However, I want to be able to compile on Windows platforms as well, but the Windows version's newest version is only 2.5.4a, so it won't compile my file for version 2.5.35. And no, I can't downgrade to the highest supported Windows version. Anyone know about plans to upgrad...

Flex/Bison IDE?

I'm looking for a good development environment in which to work on flex or bison or both. Are there any IDE's that have these capabilities and/or are suitable for this? (If not the next most general question is are there lexer/parser generators with IDE's?) Thanks ~Alex ...

Best way to add generated files to distribution?

I have a quite complex (C++) project using autoconf / automake, which includes some "generated" files (foo.yy -> foo.cc). Actual builds are done using a "control script" (Gentoo .ebuild for those familiar with the concept), on various platforms. Now, one of the target platforms does not properly support the foo.yy -> foo.cc step, and ha...

what is the use of tokens.h when I am programming a lexer?

I am programming a lexer in C and I read somewhere about the header file tokens.h. Is it there? If so, what is its use? ...

Use bison and flex with vc6

When i use bison & flex with vc6, i got got below errors lex.yy.c(395) : error C2146: syntax error : missing ';' before identifier 'YY_PROTO' lex.yy.c(395) : fatal error C1004: unexpected end of file found what would be the cause for this?? please help. Copied from Comment: #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" in...

How to initialize Bison's %union value?

In Bison I have a union %union { std::string* sval; } And I want to use it like this In Lex: *(yylval->sval) = "ABCD"; Rather than yylval->sval = new std::string("ABCD"); To prevent memory leaks easily However I need some way to allocated a std::string to sval to begin with. How can I do that? ...

Handling error conditions in Lex rather than Yacc?

Suppose I have a lex regular expression like [aA][0-9]{2,2}[pP][sS][nN]? { return TOKEN; } If a user enters A75PsN A75PS It will match But if a user says something like A75PKN I would like it to error and say "Character K not recognized, expecting S" What I am doing right now is just writing it like let [a-zA-Z] num [0-9] {l...

What does the "yy" in lex.yy.c stand for?

What does the "yy" in lex.yy.c stand for? ...