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

lex parser not displaying hex correctly

I'm trying to identify a hex number from a parsed text file and everything is about 99% accurate however I keep having an issue with this certain instance 0xa98h. whenever it finds this line it will output 0xa98 instead of ignoring it altogether…
sippycup
  • 145
  • 3
  • 12
0
votes
1 answer

How to parse input with different sections correctly with Flex, Bison

I am trying to write compiler using Flex, Bison which takes file as input. File contains description of algorithm behavior. File has 2 sections. 1. definition of registers, states 2. description of behavior Example of input file registers = {state,…
M.Puk
  • 762
  • 9
  • 25
0
votes
1 answer

Flex and Bison gives Segmentation fault (core dumped)

I am trying to use flex and bison to create a compiler for a simple language called "FUNC". but it gives me a segmentation fault and after spending hours on it, i still haven't been able to fix it. would really appreciate if you guys could help.…
0
votes
1 answer

Optimizing flex string literal parsing

I am starting writing a lexical analyzer for my programming language. String literals in this language start with a " and end when an unescaped " is encountered. Everything inside (including newlines) is preserved, except escape sequences (the usual…
user6245072
  • 2,051
  • 21
  • 34
0
votes
2 answers

Why am I getting conflicts: 1 shift/reduce

I'm new to bison and I'm getting a "conflicts: 1 shift/reduce" error. Can anyone shed some light on this? Here's the y file. test.y: %{ #include #include #define YYERROR_VERBOSE #define YYDEBUG 1 void yyerror(const char…
haroldcampbell
  • 1,512
  • 1
  • 14
  • 22
0
votes
1 answer

flex and bison how to determine if sentence is a part of grammar

I am new to using flex and bison I have implemented a simple calculator. I am trying to determine if an input is a sentence in the grammar. For example if I enter: a = 2; b = 3; print a+b; It would return: "a = 2; b = 3; print a+b; is a sentence"…
Steven
  • 1
  • 1
0
votes
1 answer

Flex - A fast scanner generator. Why?

I wonder, why is Flex used even till now as far as I know? If it is not used now and was used earlier, then also what is the advantage it provided over writing C code directly? This is what I read about Flex It takes as its input a text file…
prashantitis
  • 1,797
  • 3
  • 23
  • 52
0
votes
1 answer

EOF encountered inside an action LEX program

I have a lex program as follows. I encounter the error EOF encountered inside an action LEX program %{ #include #include #include "y.tab.h" %} %% [ \t]+ ; [0-9]+ {yylval = atoi(yytext); return INTEGER;} [-+*/] {return…
Sahitya Sridhar
  • 119
  • 3
  • 10
0
votes
1 answer

Bison bug when passing functions as arguments to yyparse?

I am in the process of re-writing a parser in order to make it reentrant. In that spirit, I am interested in passing a couple of functions to bison and then have bison pass them to lex also. One of those functions is a callback which I use in my…
viterbi
  • 419
  • 5
  • 11
0
votes
1 answer

Is flex-lexer a performant(fast) converter for simple regex recognition and replacement?

I'm working on a project for my university, requiring to go though decently large files (>50MB), and i used flex to basically rewrite a file composed of line such as 1 1:41 3:54 7:40 13:8 2 4:7 7:8 23:85 into 1 1 3 7 13 2 4 7 23 (basically,…
m.raynal
  • 2,983
  • 2
  • 21
  • 34
0
votes
1 answer

flex bison, tokenizing stops after encountering a token while reading from a file

I am new to flex and bison. I am trying to write a simple grammar accepting the string :a word in lowercase followed by a word in upper case. below are my files- file.l %{ #include #include #include "y.tab.h" int yywrap(void) { …
RaKo
  • 49
  • 1
  • 2
  • 11
0
votes
1 answer

JFLEX Error: Syntax Error @ Symbol: ID (...) Error: Illegal use of reserved word

I have the following .flex file: package mini_c; import java_cup.runtime.*; import static mini_c.sym.*; %% %class Lexer %unicode /* The characters are unicode */ %cup /* Syntax analyser with cup (Parser part)…
J Agustin Barrachina
  • 3,501
  • 1
  • 32
  • 52
0
votes
2 answers

How can I prevent Flex from discarding yyinput characters?

I'm trying to read a known number (at runtime) of characters in a Flex lexer. I know it starts with a CRLF, so I match that, then read literal_length characters using yyinput. "\r\n" { for(int i=0;i
Roderick
  • 1,205
  • 11
  • 24
0
votes
1 answer

Regex for lexing first and second string (separately) in a pair

I'm trying to write a lexer to parse a file like that looks this: one.html /two/ one/two/ /three three/four http://five.com Each line has two strings separated by a space. I need to create two regex patterns: one to match the first string, and…
adrianmcli
  • 1,956
  • 3
  • 21
  • 49
0
votes
1 answer

How can I use regular expressions to match a 'broken' string, or a proper string?

What I mean is that I need a regular expression that can match either something like this... "I am a sentence." or something like this... "I am a sentence. (notice the missing quotation mark at the end of the second one). My attempt at this so…
user3047641
  • 149
  • 1
  • 2
  • 12
1 2 3
99
100