Questions tagged [flex-lexer]

Flex (fast lexical analyzer generator) is a free software that generates lexical analyzers ("scanners" or "lexers").

Flex (fast lexical analyzer generator) is a free software that generates lexical analyzers ("scanners" or "lexers"). It is frequently used with the free Bison parser generator. Unlike Bison, flex is not part of the GNU Project. You can (and should) read the manual which can be found here.

See also:

2072 questions
12
votes
3 answers

How can I use flex & bison in Visual Studio 2010?

I've read http://msdn.microsoft.com/en-us/library/aa730877%28vs.80%29.aspx but this document was for VS 2005. I stuck on the part 'Importing a .rules File in Visual C++' in the document. It seems that VS 2010 does not support .rules file, instead,…
David Johns
  • 1,201
  • 5
  • 15
  • 34
12
votes
3 answers

Unix Flex Regex for Multi-Line Comments

I am making a Lexical Analyzer using Flex on Unix. If you've ever used it before you know that you mainly just define the regex for the tokens of whatever language you are writing the Lexical Analyzer for. I am stuck on the final part. I need the…
LunaCodeGirl
  • 5,432
  • 6
  • 30
  • 36
12
votes
3 answers

Ubuntu: how to install flex to make postgres?

I'm trying to work on postgresql locally with ubuntu 10.04. I get this error after I configure with ./configure --enable-cassert --enable-debug --prefix=$HOME/pgsql when I make && make install I get this error: make -C parser all make[3]: Entering…
James
  • 5,273
  • 10
  • 51
  • 76
12
votes
1 answer

Meaning of yywrap() in flex

What does this instructions mean in flex (lex) : #define yywrap() 1 and this [ \t]+$ i find it in the code below: (%% [ \t]+ putchar('_'); [ \t]+% %% input "hello world" output "hello_world" )
12
votes
1 answer

Configuring Bison and Flex without global or static variable

i am working in a small language/IDE. And I need to know how to configure flex and bison to work together but without using any global or static variable. I need to pass to bison my AST pointer. I also need that bison pass my AST to flex as well.…
Bruno Lebtag
  • 420
  • 4
  • 18
12
votes
9 answers

Flex and Yacc - Cannot find - lfl?

Hi I'm learing Lex and yacc. I created the following lex program. %{ #include %} %% [0123456789]+ printf("NUMBER\n"); [a-zA-Z][a-zA-Z0-9]* printf("WORD\n"); %% I'm trying to run it using the following commands: lex…
sap
  • 1,141
  • 6
  • 41
  • 62
11
votes
2 answers

REPL for interpreter using Flex/Bison

I've written an interpreter for a C-like language, using Flex and Bison for the scanner/parser. It's working fine when executing full program files. Now I'm trying implement a REPL in the interpreter for interactive use. I want it to work like the…
Jay Lieske
  • 4,788
  • 3
  • 30
  • 41
11
votes
5 answers

Installing flex (lexical analyzer) on Mac

Can someone tell me how I can install flex (lexical analyzer) on my Mac? I searched everywhere on google and I can't find it. I have the universal binary and I extracted it to my desktop but I have no idea where to go from here. Any help would be…
user635064
  • 6,219
  • 12
  • 54
  • 100
11
votes
2 answers

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…
Kizaru
  • 2,443
  • 3
  • 24
  • 39
11
votes
1 answer

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

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…
Ani
  • 1,448
  • 1
  • 16
  • 38
11
votes
2 answers

Getting: warning, rule cannot be matched

I am working on building a lexical and syntax analyzer. I am getting the following warning when I try to use flex with my .l file. littleDuck.l:26: warning, rule cannot be matched Rule 26 is the one that starts with {cteI}, my rules section is the…
gabrielbaca
  • 123
  • 1
  • 2
  • 10
11
votes
4 answers

How to use indentation as block delimiters with bison and flex

I wounder how to implement indentation as block delimiters in bison + flex. Just like in python. I'm writing my own programming language ( mostly for fun, but I intend to use it together with a game engine ), I'll try to come up with something…
Frank
  • 2,640
  • 2
  • 21
  • 21
10
votes
1 answer

how to enable the shortest match rule in flex (lexer)?

By default flex uses the longest match rule. Is there any way to override this behavior to make it match the shortest sequence? Thank you
VilleDePommes
  • 119
  • 1
  • 6
10
votes
2 answers

bison/flex: print erroneous line

I am using bison+flex to parse file. On error yyerror() is invoked. How can I get the line number or string that is violating the rules, to print it with the error message?
Jakub M.
  • 32,471
  • 48
  • 110
  • 179
10
votes
3 answers

yylval undefined with flex and bison

I have searched almost every material online. But I am still confused why lexer cannot identify yylval. Here is the case: I have defined a bunch of ADT in node.h and realize them in node.c, my purpose is to generate a AST after these structures are…
chenrui
  • 8,910
  • 3
  • 33
  • 43