Questions tagged [lex]

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers"). Lex is commonly used with the yacc parser generator. For questions about Amazon Lex, use the tag amazon-lex instead.

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers"). Lex is commonly used with the parser generator.

References:

See also:

Not to be confused with .

1809 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
127
votes
4 answers

error: unknown type name ‘bool’

I downloaded the source code and wanted to compile the file of scanner. It produces this error: [meepo@localhost cs143-pp1]$ gcc -o lex.yy.o lex.yy.c -ll In file included from scanner.l:15:0: scanner.h:59:5: error: unknown type name ‘bool’ In file…
Meepo
  • 1,291
  • 2
  • 8
  • 6
72
votes
1 answer

how to install Lex and Yacc in Ubuntu?

I am doing project in SENSE, for that i have to install Lex and Yacc. If you can help me how to install in Ubuntu. I very new to this area. So can you help me. Any website to study the basic of Lex and Yacc
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
65
votes
8 answers

Resources for lexing, tokenising and parsing in python

Can people point me to resources on lexing, parsing and tokenising with Python? I'm doing a little hacking on an open source project (hotwire) and wanted to do a few changes to the code that lexes, parses and tokenises the commands entered into it. …
Hamish Downer
  • 16,603
  • 16
  • 90
  • 84
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
53
votes
14 answers

Good tools for creating a C/C++ parser/analyzer

What are some good tools for getting a quick start for parsing and analyzing C/C++ code? In particular, I'm looking for open source tools that handle the C/C++ preprocessor and language. Preferably, these tools would use lex/yacc (or flex/bison)…
Matt Ball
  • 1,434
  • 2
  • 17
  • 24
38
votes
4 answers

Is there a good Emacs mode or method for lex/flex/yacc/bison files?

Editing lex or yacc files with Emacs is a nuisance: if I use C mode the indenting goes wrong, and if I don't use C mode I can't use indenting. Does anyone have a trick, a method, or an editing mode to get around it?
user181548
30
votes
4 answers

Lex and Yacc in PHP

Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I…
Rik Heywood
  • 13,816
  • 9
  • 61
  • 81
24
votes
5 answers

Is there a better (more modern) tool than lex/flex for generating a tokenizer for C++?

I recent added source file parsing to an existing tool that generated output files from complex command line arguments. The command line arguments got to be so complex that we started allowing them to be supplied as a file that was parsed as if it…
John Knoeller
  • 33,512
  • 4
  • 61
  • 92
22
votes
3 answers

Choice of Parser Generator

OK, I understand this question may sound quite opinion-based, however since I have several specific criteria of choice, I think it would make a nice fit for SO. So, here I am... I've worked with compiler/interpreter construction in the past quite a…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
19
votes
4 answers

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

What does the "yy" in lex.yy.c stand for?
phillipwei
  • 1,243
  • 2
  • 12
  • 25
18
votes
1 answer

Is it possible to set priorities for rules to avoid the "longest-earliest" matching pattern?

Another simple question : is there any way to tell flex to prefer a rule that matches a short thing over a rule that matches a longer thing ? I can't find any good documentation about that. Here is why I need that : I parse a file for a pseudo…
m09
  • 7,490
  • 3
  • 31
  • 58
18
votes
12 answers

Parsing, where can I learn about it

I've been given a job of 'translating' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to learn more about lexical analysis and parsers?
DaveP
  • 1,079
  • 1
  • 13
  • 13
1
2 3
99 100