gnu-flex

GNU Flex, multiline rule

Hi there i have a flex rule inside my lexer definition : operators "[]"|"[]="|"[]<"|".."|"."|".="|"+"|"+="|"-"|"-="|"/"|"/="|"*"|"*="|"%"|"%="|"++"|"--"|"^"|"^="|"~"|"&"|"&="|"|"|"|="|"<<"|"<<="|">>"|"!"|"<"|">"|">="|"<="|"=="|"!="|"&&"|"||"|"~=" Is there any way to split this ruole on more lines to keep it clearer? I tried with \ ju...

unistd.h related problem when compiling bison & flex program under vc++

I'm using bison & flex (downloaded via cygwin) with vc++. When I compile the program I got an error: ...: fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory The corresponding code in the flex-generated file is: #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it w...

Implementing eval and load functions inside a scripting engine with Flex and Bison.

Hy guys, i'm developing a scripting engine with flex and bison and now i'm implementing the eval and load functions for this language. Just to give you an example, the syntax is like : import std.*; load( "some_script.hy" ); eval( "foo = 123;" ); println( foo ); So, in my lexer i've implemented the function : void hyb_parse_string...

showTrackHighlight for multiple thum in flex

http://blog.flexexamples.com/2007/08/21/highlighting-a-slider-controls-track-using-the-showtrackhighlight-style/ in this above link have two thumb.In that one first thumb have the showTrackHighlight=true,ist posssible to use three thunb with showTrackHighlight.if so plz help mee ...

Creating simple calculator with bison & flex in C++ (not C)

Hey, I would like to create simple C++ calculator using bison and flex. Please note I'm new to the creating parsers. I already found few examples in bison/flex but they were all written in C. My goal is to create C++ code, where classes would contain nodes of values, operations, funcs - to create AST (evaluation would be done just afte...

generating program structure (nodes) using bison and flex

I would like to write myself a pretty printer for java using bison and flex. I have written a pretty printer for a script language, but I was only writing visitors, which made the printing. How can I turn a program using my formal grammar into a tree of nodes (made using C++ classes), that afterwards I could visit using my visitor? Maybe...

MinGW gcc error: "undefined reference to `yylloc'"

Where can I find yylloc? I have included libfl.a (-lfl) in gcc command line, added GnuWin32/bin and GnuWin32/lib directories to system variable LIB, searched through all files in GnuWin32 - neither I nor gcc can find it. ...

Simple XML parser in bison/flex

I would like to create simple xml parser using bison/flex. I don't need validation, comments, arguments, only <tag>value</tag>, where value can be number, string or other <tag>value</tag>. So for example: <div> <mul> <num>20</num> <add> <num>1</num> <num>5</num> </add> </mul> <id>test</id> </div> If it h...

Is there a way to localize error messages from bison/flex?

Do bison and flex allow user to natively localize error messages? For example, I would like to translate following message: syntax error, unexpected NUMBER, expecting $end to other language and replace NUMBER/$end with something more human-readable. ...

Building Lisp/Scheme-like parse tree with flex/bison

Hello, I was trying to parse simple Lisp/scheme-like code E.g. (func a (b c d) ) and build a tree from it, I could do the parsing in C without using bison (i.e, using only flex to return tokens and building the tree with recursion). But, with bison grammar, I am not sure where to add the code to build the list (i.e, which rule to...

Suggest regular expression.

Can some one suggest regular expression for below text Signature text text some more text text ... text ) I tried Signature\n.*\) but this only works for Signature text ) Basically an expression which starts with a given text, allows multiple new lines, and ends with ). Thanks ...

Why does Flex say this is an "unrecognized rule"?

In the following: space ([ \t\f\r])+ opt_space ([ \t\f\r])* cpp ^{opt_space}#{opt_space} word [A-Za-z_][A-Za-z_0-9]* arg_macro {cpp}define{space}{word} /*arg_macro ^{opt_space}#{opt_space}define{space}{word}*/ %% {arg_macro} ; %% I get an error message test.l...

Compilation error with flex file

Hello, I'm trying to build a simple lexical analyzer to go along with a simple input output library for (scientific) C programs. When compiling with autotools, including automake, libtool, and autoconf, I get the following error: simpleio_lex.l:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘of’ This usually mean...

flex/bison fixing memory leaks with unexpected tokens

I have a flex bison application. For a few of my tokens, I copy out the yytext from flex using strdup. This works great except when there is an error of an unexpected token. simple example flex.l: ... [a-zA-Z0-9]+ { lval.string = strdup(yytext); return IDENT }; [\{\}] { return yytext[0] }; ... and parse.y ... %destructor { ...

Undefined reference to yyparse (flex & bison)

I'm attempting to learn some flex/bison, and I'm reading Flex & Bison by John Levine (O'Reilly). There is an example that I need to get running, however I can't get it to run as I get the following error: /tmp/ccKZcRYB.o: In function `yylex': fb3-1.lex.c:(.text+0x2bd): undefined reference to `yylval' /tmp/cclBqnOk.o: In function `main'...

How can I use GNU Flex in Visual C++?

Hello :) I'm trying to use Flex with Visual C++. However, the generated lexer (which is empty and has no rules) throws these errors while building: configurationlexer.cpp(967): error C3861: 'read' identifier not found configurationlexer.cpp(967): fatal error C1903: unable to recover from previous error(s); stopping compilation The so...

When is it practical to use a parser generator?

I'm writing a simple text-template language for a web application I'm writing (think google's ctemplate). When finished, it'll feature only a small number of possible actions, simple stuff like "evaluate and execute", "evaluate and print", "evaluate and escape html", "comment". I was thinking of hand writing the whole parser from scratch...

Syntax error, unexpected TRUE, expecting '{'

I'm writing a parser in Bison for a basic compiler (and then expand it to contain subroutines and dynamic memory allocation). The grammar is defined in Appendix A of the dragon book. My Flex scanner works--I ran my test files through it and it printed out all the correct tokens it found. Sorry about the strange formatting below. My bison...

Print PDF from FLEX

Hello Is there the way to print pdf document from flex? Thanks Vladimir ...

GCC says "syntax error before numeric constant" in generated header file from bison.

When I compile my .y file with bison parser.y -d -t and then include the parser.tab.h file in my flex file, gcc says "error: syntax error before numeric constant." It's referencing line 32, which is the first line in the enum of yytokentype. enum yytokentype { BREAK = 258, ... } The error is about the line "BREAK = 258." I hone...