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 and Yacc/Flex and bison Syntax Error

I recently discovered lex and yacc (and flex and bison), and I get an error when trying to tell if a sentence is given to the program. Here is the .lex file: %{ #include #include "1.tab.h" %} %% tweety|sylvester return…
eli0T
  • 81
  • 8
0
votes
0 answers

English language parser in C (FLEX-LEXAR) working on sentence classification

i am working on an english language parser which a sentence as input from the user and does 3 tasks. Check if the sentence contains words from my defined rules in rules section(verbs,nouns,pronuns etc) Tagging individual words as noun,verb,pronoun…
J.Pole
  • 1
  • 3
0
votes
1 answer

Regex for application parameters

So, how the title says it. How do I use regex for extracting application parameters? I tried: --.*, but I would like it not to match unless it has any character (except whitespace) after it. So, this: --version hello would match --version, however…
user7973034
0
votes
1 answer

Unrecognized rule error while using lex

1 %{ 2 #include 3 #include 4 %} 5 %option noyywrap 6 %% 7 [a-z] { putchar(yytext[0]); } 8 9 "/*" 10 { 11 char ch; 12 while((ch = input()) != '*') 13 …
DSC
  • 103
  • 2
0
votes
1 answer

RegEx expression that will match string of a particular format

I have a line with ORDER BY DESC(?year) where ?year can be anything followed by a question mark (?) such as ?name, ?address etc. I have tried ORDER BY DESC\(\?[a-z]+\) to capture the whole string as ORDER BY DESC(?year) but not working. lex…
Abir Chokraborty
  • 1,695
  • 4
  • 15
  • 23
0
votes
0 answers

Trouble parsing c file with flex and bison

I'm currently working on a small c compiler and i'm trying to parse a test file but I'm having a error I cannot resolve. When i run the test file I get a syntax error 0, which i'm assuming is because of the b==0 part but I have yet to figure out a…
sippycup
  • 145
  • 3
  • 12
0
votes
1 answer

Shift Reduce Conflict

I'm having trouble fixing a shift reduce conflict in my grammar. I tried to add -v to read the output of the issue and it guides me towards State 0 and mentions that my INT and FLOAT is reduced to variable_definitions by rule 9. I cannot see the…
sippycup
  • 145
  • 3
  • 12
0
votes
1 answer

BISON + FLEX grammar - why tokens are being concatenated together

I would like to understand why BISON is concatenating two tokens on the following rule stmt: declaration { ... } | assignment { ... } | exp { ... } | ID ';' <-- this rule { ... …
thiagoh
  • 7,098
  • 8
  • 51
  • 77
0
votes
1 answer

passing value from flex to bison

I am trying to print token value in bison sent from flex but for some reason the value printed is garbage in some cases. lex code: \".*\" { std::string* s1 = new std::string(yytext); std::string s2 = *s1; std::string s3 =…
Jeevansai Jinne
  • 147
  • 2
  • 4
  • 12
0
votes
1 answer

How to exclude unwanted patterns from a set of patterns?

I've Just started with lex programmming. The first assignment was to seperate the vowels and consonants from a file. The rule for the vowel which I wrote was- [ aeiouAEIOU ] {return VOWEL}; For consonants, it would be tedious to write the code -…
0
votes
1 answer

char is always changing using flex

I'm trying to learn how to use flex and I'm having some issues: each time when a token is found I want it to be store in a token I created, that part works just fine! the issue begins when it gets to the next token for example, if I've written: "a…
secret
  • 505
  • 4
  • 16
0
votes
1 answer

syntax error: 'constant' while using flex

Well topic speak for himself, here example of a code(lex file before compilation): %{ #include int Upperc=0; int Lowerc=0; %} %% [A-Z] {printf("Upperccase\t");Upperc++;} [a-z]…
user2323232
  • 249
  • 2
  • 11
0
votes
1 answer

Migrating flex 2.5.4a to 2.6 (lexical analyser generator)

I have a file that generates cc code using flex. When I use the version 2.5.4a-10 the codes works as expected. If I use bit more recent version 2.5.37 or even newer like 2.6 the generated code seems not to allocate anything. It uses some pointers…
Gerhard Stein
  • 1,543
  • 13
  • 25
0
votes
2 answers

flex - no entry point

I'm studying compilation theory and how to work with flex and i have several issues. I created a lex file with the following data in it: %% "hello" printf("GOODBYE"); . ; %% This is the simplest one I could think of. If I understand…
Oria Gruber
  • 1,513
  • 2
  • 22
  • 44
0
votes
1 answer

Figuring out Flex (lexer) yy_push_state

What would the Regex equivalent be of the following Flex structure? I'm trying to recreate Rusts grammar for a project but right now I'm stuck on this piece? This is the grammar for an inner/outer documentation comment (Rust has six types of…
Adrian Z.
  • 904
  • 1
  • 12
  • 29