gnu-flex

How do I implement a two-pass scanner using GNU Flex?

As a pet-project, I'd like to attempt to implement a basic language of my own design that can be used as a web-scripting language. It's trivial to run a C++ program as an Apache CGI, so the real work lies in how to parse an input file containing non-code (HTML/CSS markup) and server-side code. In my undergrad compiler course, we used Fl...

flex tutorials or books

Hi Can anyone recommend any good sites or good books for learning flex? Thanks Damien ...

flex (lexical analyzer) regular expressions - Reusing definitions

Hi, I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions DIGIT [0-9] VALID [a-zA-Z] How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions? I don't know how to do the "second" match, I'm stuck here: IDENTI...

Clearing parser state of a bison generated parser

I am using a C lexer that is Flex-generated, and a C++ parser that is Bison-generated. I have modified the parser to acccept only string input. I am calling the parser function yyparse() in a loop, and reading line by line of user input. I stop the loop if the input is "quit". The problem I am facing is that when input doesn't match an...

How do you compile gnu flex in Visual Studio 2005/2008?

I can't figure this one out. I can download a win32 binary of flex 2.5.4a from gnuwin32, but I'd like to build the latest version (2.5.35) using Visual Studio 2005. I suppose I could build in in cygwin, but where is the fun in that? http://flex.sourceforge.net/ ...

Developing a simple parser

My day job includes working to develop a Pascal-like compiler. I've been working all along on optimizations and code generation. I would also like to start learning to build a simple parser for the same language. I'm however, not really sure how to go about this. Flex and Bison seem to be the choice. But, isn't it possible to write a p...

C++: Big Integers

I am a writing a lexer as part of a compiler project and I need to detect if an integer is larger than what can fit in a int so I can print an error. Is there a C++ standard library for big integers that could fit this purpose? ...

FLEX: Is there a way to return mutiple tokens at once.

In flex, I want to return multiple tokens for one match of a regular expression. Is there a way to do this? ...

Using Lex tokenizers in an embedded system

I'm trying to write a config-file parser for use in a non-standard C environment. Specifically, I can't rely on the utilities provided by <stdio.h>. I'm looking to use Flex, but I need to use my own input structures rather than <stdio.h>'s FILE pointers. ...

What is the difference between Flex/Lex and Yacc/Bison ?

What is the difference between Flex & Lex and Yacc & Bison. I searched the Internet wildly and I didn't find any solid answer. Can I install pure Lex and Yacc on Ubuntu, or I can install only flex and bison. I am confused. Is Lex or Yacc still being maintained by someone ? Are all of them free ? If Lex is not free why do I have it in...

Resources for setting up Flex projects with Hudson

I'm looking into setting up a CI environment for our flex projects. I have very little experience in setting up an environment like this, but have read a lot about it and think we could benefit a lot from this in our projects. I do have experience with ANT and we're currently using it for our building. I've been looking at Hudson for a w...

How does flex support bison-location exactly?

Hi, I'm trying to use flex and bison to create a filter, because I want get certain grammar elements from a complex language. My plan is to use flex + bison to recognize the grammar, and dump out the location of elements of interest. (Then use a script to grab text according the locations dumped.) I found flex can support a bison feat...

Lexer/parser tools

Which lexer/parser generator is the best (easiest to use, fastest) for C or C++? I'm using flex and bison right now, but bison only handles LALR(1) grammars. The language I'm parsing doesn't really need unlimited lookahead, but unlimited lookahead would make parsing a lot easier. Should I try Antlr? Coco/R? Elkhound? Something else? ...

Bison does not appear to recognize C string literals appropriately

Hi Folks, My problem is that I am trying to run a problem that I coded using a flex-bison scanner-parser. What my program is supposed to do is take user input (in my case, queries for a database system I'm designing), lex and parse, and then execute the corresponding actions. What actually happens is that my parser code is not correctly...

using unput wrong

I created test.l, input to flex, which ends with the main function. When the main function is implemented as: int main(void) { yylex(); return 0; } I have no problem. I want to trick the parser into believing that the first character is always a semi-colon, so I implemented main as int main(void) { unput(';'); yylex(...

Using yyparse() to make a two pass assembler?

I'm writing an assembler for a custom micro controller I'm working on. I've got the assembler to a point where it will assemble instructions down to binary. However, I'm now having problems with getting labels to work. Currently, when my assembler encounters a new label, it stores the name of the label and the memory location its referr...

Is it possible to have two or more Lex/Yacc parsers in the same application

I have an application where I already have a parser for one sort of grammar and I need to add a second different grammar for another purpose. Is it possible to have more than one? And if so how do you get another entry point? Thanks david allan finch ...

Lex/Yacc: Print message before input

Hi, I'm trying to figure out how I can display a message/prompt when using lex/yacc (flex/bison). For instance, main looks like so: int main(int argc, char *argv[]) { yyparse(); } Which calls yacc, which calls yylex(). This yields a blank line waiting on STDIN. How can i display a message like... message $ _ instead of _ Whe...

How do I use C++ in flex and bison?

I have a project for school where we need to use flex and bison. I want to use C++ so that I have access to STL and my own classes that I wrote. We were provided with the following Makefile: CC = gcc CFLAGS = -g OBJs = parse.tab.o symtab.o attr.o lex.yy.o default: parser parser: ${OBJs} ${CC} ${CFLAGS} ${OBJs} -o parser -lfl ...

String input to flex lexer

I want to create a read-eval-print loop using flex/bison parser. Trouble is, the flex generated lexer wants input of type FILE* and i would like it to be char*. Is there anyway to do this? One suggestion has been to create a pipe, feed it the string and open the file descriptor and send to the lexer. This is fairly simple but it feels ...