flex-lexer Questions

1

Solved

I have the following flex rules in place. "#"{name} {printf(" HASH | %s\n", yytext);} . {} It works great for my purposes and outputs upon a match to the first rule; HASH | some matched string...
Limb asked 26/10, 2013 at 10:32

3

Solved

I'm currently trying to write a small compiler using Flex+Bison but I'm kinda of lost in terms of what to do with error handlling, specially how to make everything fit together. To motivate the dis...
Passifloraceous asked 16/9, 2013 at 21:44

2

we are just getting started using flex to build a lexer for a project, but we cant figure out how to get it to work. I copy the example code given in tutorials and try to run flex++ with the tut fi...
Machmeter asked 6/11, 2011 at 0:8

1

Solved

I'm trying to make a compiler for a mini Pascal-like language. I'm using Flex and Bison for this and I came up with this error. My Flex file: %{ #include "y.tab.h" #include <stdlib.h> #incl...
Morton asked 15/6, 2013 at 20:10

1

I have created a context free grammar in bison and a scanner in flex. Now i also want to make a semantic check, for example, suppose the input is something like this: int m=5; c=c+5; This input ...

1

I am trying to use flex on a project and I am trying to use CMake to link flex with my project. I found a FindFLEX.cmake online which I am using for this. You can find it here. This was supposed to...
Grania asked 22/5, 2013 at 16:58

7

Solved

Which lexer/parser generator is the best (easiest to use, fastest) for C or C++? I'm using flex and bison right now, but bison only handles LALR(1) grammars. The language I'm parsing doesn't ...
Irreplaceable asked 30/3, 2009 at 14:24

2

Solved

I'm trying to parse a legacy language (which is similar to 'C') using FLEX and BISON. Everything is working nicely except for matching strings. This rather odd legacy language doesn't support quot...
Hilbert asked 12/11, 2010 at 15:33

2

Solved

In the flex manual it mentions a "trailing context" pattern (r/s), which means r, but only if followed by s. However the following code doesn't compile (instead it gives an error of "unrecognized r...
Falsetto asked 21/3, 2013 at 21:37

4

Solved

I'm trying to parse C-style multi-line comments in my flex (.l) file: %s ML_COMMENT %% ... <INITIAL>"/*" BEGIN(ML_COMMENT); <ML_COMMENT>"*/" BEGIN(INITIAL); <ML_COMMENT>[.\n]+...
Lastly asked 10/11, 2010 at 14:29

1

Solved

I'm writing a simple parser for tcpdump logs, could you please tell me why I can't get proper line number? %{ char str[80]; %} %option yylineno ... %% ^{HOURS}:{MINUTES}:{MINUTES} if(input()=='....
Houlihan asked 9/11, 2012 at 23:41

2

Solved

I am having a big problem to write a regexp that will trim all the whitespace in my input. I have tried \s+ and [ \t\t\r]+ but that don't work. I need this because I am writing a scanner using fl...

2

I'm writing a program that handles comments as well as a few other things. If a comment is in a specific place, then my program does something. Flex passes a token upon finding a comment, and Bis...
Quaquaversal asked 22/7, 2011 at 23:41

2

I'm working on a parser that parses json string and I want to make it a library. The problem is that when I use ld to link the library I wrote, there's a error message: main.o: In function `main'...
Superiority asked 13/1, 2011 at 13:9

2

Solved

I want to develop my own C compiler to get deeper into flex and bison for my compiler lessons at University, but I can't find flex and bison, which I've seen described in some other posts. Do I nee...
Freestone asked 29/4, 2012 at 9:50

3

Solved

I want my language to have two features that make Python such a nicely formatted language: One statement per line Blocks begin with another indentation level and go on until that's ended Can an...
Schonfield asked 12/5, 2011 at 7:42

3

In flex, I want to return multiple tokens for one match of a regular expression. Is there a way to do this?
Chorea asked 22/2, 2009 at 9:11

2

Solved

I was playing with flex and bison today, and something kind of eerie came to my attention. localhost:c math4tots$ lex c.l localhost:c math4tots$ yacc -d c.y localhost:c math4tots$ rm c.l c.y local...
Dwain asked 19/1, 2012 at 8:8

1

Solved

I have this token in my .lex file: [a-zA-Z0-9]+ { yylval = yytext; return ALPHANUM; } and this code in my .y file: Sentence: "Sphere(" ALPHANUM ")." { FILE* file = fopen("C:/test.txt", "a+"); c...
Tad asked 26/12, 2011 at 1:55

1

Solved

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 i...
Stylistic asked 4/12, 2011 at 23:2

1

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
Cyanic asked 30/11, 2011 at 20:23

2

Solved

I have the following code and it gives an error" "hello.l",line 31: premature EOF" when I run the following command flex hello.l %{ #include <stdlib.h> #include "y.tab.h" %} %% ("hi"|...
Outwash asked 22/11, 2011 at 12:41

1

I have the following makefile that gcc doesn't like: blah.exe:lex.yy.o gcc –o blah.exe lex.yy.o lex.yy.o:lex.yy.c gcc –c lex.yy.c lex.yy.c:blah.lex flex blah.lex If I delete everything except...
Kamerun asked 14/10, 2011 at 22:15

2

Solved

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 interpre...
Kiernan asked 9/7, 2011 at 18:56

1

Solved

My apologies if the title of this thread is a little confusing. What I'm asking about is how does Flex (the lexical analyzer) handle issues of precedence? For example, let's say I have two tokens...
Earache asked 18/7, 2011 at 17:11

© 2022 - 2024 — McMap. All rights reserved.