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
0
votes
1 answer

Bison Yacc If Statement always executing

I am trying to implement a simple if statement in Flex and Bison in the following form: (expression)?(expression) If the left expression is a non zero value, then the right expression will be executed. Using Bison grammar rules, can anyone show me…
Salvo
  • 541
  • 6
  • 19
0
votes
1 answer

Flex & Bison Simple BNF calculator constant output of zero

I am working through the O'Reilly Flex & Bison book by John Levine and I have encountered the following problem while attempting to compile and run the example for a simple BNF calculator > ./fb1-5 2 + 3 * 4 = 0 2 * 3 + 4 = 0 c Mystery Character…
0
votes
1 answer

lex - how to match escape characters for / and \

i'm looking for a way to way to match / and \ for example: if i get the string "hello\sir/!" i'd like to get hello\sir/!
MOses
  • 71
  • 9
0
votes
0 answers

yacc/lex parser not catching certain terminals

I built a scanner->parser meant to catch modified Java. When testing it, I noticed that codeBlock never triggers but varDecls triggers. I'm not entirely sure why this happens. Here is my parser %{ #include extern int yylex(void); void…
0
votes
1 answer

Undefined symbols for architecture x86_64 flex/bison

I am trying to make a simple toy (LET) language as practice using flex/bison. However, I keep getting the following error when I run the command g++ -Wall -std=c++11 repl.cpp -v -o LET: Undefined symbols for architecture x86_64: …
M. Barbieri
  • 512
  • 2
  • 13
  • 27
0
votes
2 answers

Using only string with Flex/Bison

I am new in Flex/Bison. I want to use only strings for values (is a language translator). I have this for test: example.l: %option noyywrap nodefault %{ #include #include "example.tab.h" %} %% [ \t\n] {;} "<=" {return LEFT;} "=>" …
RAM
  • 65
  • 4
  • 11
0
votes
0 answers

Multi typed calculator using bison/flex

I'm trying to implement a multi typed calculator using both flex and bison. My problem is how to write a grammar that respect my goal. fox example : 5 + 3.4, the result should be a float number. 5 + 5, an integer result. …
0
votes
1 answer

Lex Yacc syntax error after adding semantic actions

I'm making a parser with Lex&Yacc for a school project, and I have some unexplained issues with my syntax analysis. First of all, this is my yacc file that doesn't work. %{ #include #include #include extern FILE…
valkorai
  • 40
  • 6
0
votes
1 answer

Accept both integers and floats in a bison grammar

This question is attached to this post https://stackoverflow.com/questions/42848197/bison-flex-cannot-print-out-result?noredirect=1#comment72805876_42848197 this time I try to make my calculator program accepts both integers and floats…
0
votes
2 answers

Flex identifying end of line

we are trying to correct a mistake in our lexical analysis parser.We are using flex and we have to support multi line strings.The problem is when the end of string is not on the same line with the opening " we do not count the new line.We have two…
0
votes
0 answers

BISON unrecognized: %define api.value.type {double}

I am totally new to bison an I am confused on many parts but when I tried compiling my code it gave me the error bison -d Compiler/grammar.y ("Compiler/grammar.y", line 9) error: unrecognized: %define ("Compiler/grammar.y", line 9) error: …
0
votes
1 answer

mutual recursive function definitions in a flex bison compiler

I'm coding a compiler for an non-existing language ( it's an example language for a university project). In the section reserved for function definitions, the compiler should be able to correctly compile such definitions: function a() { //some…
0
votes
1 answer

Invalid pointer while building an AST with Bison

I'm trying to build an AST for a simple programming language (homework). However I can't make it to work : it seems that intermediate values ($1, $2, ...) are invalid and doesn't correspond to what I return in "sub-expressions". Here is the Bison…
0
votes
1 answer

Lex parsing to determine

This is an extension to a previous question. I'm trying to parse a .txt file and determine if each line is valid or invalid depending on my rules. the text files will contain an assortment of random strings, hex, integers and decimals seperated by a…
sippycup
  • 145
  • 3
  • 12
0
votes
1 answer

Determining a hex value from a lex parser

I'm currently trying to parse a text file and find any hexadecimal numbers within it. If the hexadecimal number is incorrect I have it display as not number. input: -0xA98F 0XA98H 0x123 0xabc expected output: -0xA98F valid 0x123 valid …
sippycup
  • 145
  • 3
  • 12