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
141
votes
5 answers

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…
Dumb Questioner
  • 2,147
  • 4
  • 20
  • 21
98
votes
5 answers

Undefined Reference To yywrap

I have a simple "language" that I'm using Flex(Lexical Analyzer), it's like this: /* Just like UNIX wc */ %{ int chars = 0; int words = 0; int lines = 0; %} %% [a-zA-Z]+ { words++; chars += strlen(yytext); } \n { chars++; lines++; } . …
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
90
votes
4 answers

Writing a parser like Flex/Bison that is usable on 8-bit embedded systems

I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. If I were writing this to run on my Linux box, I could use flex/bison. Now that I restricted myself to an…
Johan
  • 3,072
  • 3
  • 27
  • 27
70
votes
2 answers

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…
Zifre
  • 26,504
  • 11
  • 85
  • 105
66
votes
9 answers

How to compile LEX/YACC files on Windows?

I'm having Lex and YACC files to parse my files (.l file and .y file). How to compile those files and how to make equivalent .c file for them in windows platform?
Thorin Oakenshield
  • 14,232
  • 33
  • 106
  • 146
61
votes
8 answers

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…
bjorns
  • 606
  • 1
  • 5
  • 8
59
votes
6 answers

Regular expression for a string literal in flex/lex

I'm experimenting to learn flex and would like to match string literals. My code currently looks like: "\""([^\n\"\\]*(\\[.\n])*)*"\"" {/*matches string-literal*/;} I've been struggling with variations for an hour or so and can't get it…
Thomas
  • 929
  • 2
  • 9
  • 10
46
votes
7 answers

Use regular expression to match ANY Chinese character in utf-8 encoding

For example, I want to match a string consisting of m to n Chinese characters, then I can use: [single Chinese character regular expression]{m,n} Is there some regular expression of a single Chinese character, which could be any Chinese characters…
xiaohan2012
  • 9,870
  • 23
  • 67
  • 101
32
votes
1 answer

Doxygen - Could NOT find FLEX (missing: FLEX_EXECUTABLE)

I know there are very similar worded questions on here, but I could not find an answer to my question there, so here we go: I'm trying to see which of my C++ methods are called by others so I found Doxygen after googling. On their page the…
Cold_Class
  • 3,214
  • 4
  • 39
  • 82
31
votes
9 answers

difficulty getting c-style comments in flex/lex

I want to make a rule in flex to consume a c-style comment like /* */ i have the following c_comment "/*"[\n.]*"*/" But it doesn't ever get matched. Any idea why? if you need more of my code please let me know and I'll submit the whole thing. …
adhanlon
  • 6,407
  • 13
  • 43
  • 41
29
votes
3 answers

Flex(lexer) support for unicode

I am wondering if the newest version of flex supports unicode? If so, how can use patterns to match Chinese characters? More: Use regular expression to match ANY Chinese character in utf-8 encoding
xiaohan2012
  • 9,870
  • 23
  • 67
  • 101
27
votes
9 answers

unistd.h related difficulty 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…
Haiyang
  • 1,489
  • 4
  • 15
  • 19
24
votes
4 answers

android 7.1.2 + ARMv7

I met this problem when I was compiling the Android 7.1.2 source code after I updated my debian. I do not know what is the real problem . It seems problem from the flex. However, how can i solve it? FAILED: /bin/bash -c…
Peng
  • 241
  • 1
  • 2
  • 6
24
votes
8 answers

Writing compilers ... what's right and what's wrong?

Okay, in my quest to figure out the necessary stuff to write a compiler, I've reached a bit of a roadblock. It seems that every technology or tool that I find has some opposition somewhere. I use Bison and Flex right now but I'm getting the feeling…
user204416
23
votes
8 answers

How does flex support bison-location exactly?

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 recognise the grammar, and dump out the location of elements of interest. (Then use a script…
Kevin Yu
  • 1,423
  • 4
  • 15
  • 19
1
2 3
99 100