All Questions
5 questions
1
vote
1
answer
9k
views
Lex program to recognise valid arithmetic expression and also to recognise valid identifies and operators
the below program checks the arithmatic expression like a+b a-b it gives the output valid or invalid;
%{
#include<stdio.h>
#include<stdlib.h>
int c,d,bo=0,bc=0;
%}
operand [a-zA-Z0-9]+
...
1
vote
3
answers
8k
views
lex program on counting no of comment lines
here the program counts the no of comment lines, single line comments and multi line comments and gives a total comments output with a file.txt as input
file.txt
//hellow world
/*hello world1*/
/*...
0
votes
1
answer
306
views
In a Flex Lexer, why are last chars moved to the beginning of a buffer before loading new input?
I'm trying to understand a Lexer (source) I'm porting to JavaScript and am stuck understanding how data from an input is read into a buffer. It's a standard Lexer so I'm hoping someone can give me ...
1
vote
1
answer
3k
views
Clear buffers before calling YYACCEPT in yacc/lex
Is there any way to clear parser buffers before calling YYACCEPT in yacc.
If i do not clear buffer it causes some problems when i call yyparse for the second time.
Also note that I am using some ...
2
votes
1
answer
743
views
How to write own parser for (f)lex?
I generated with flex a lexer.
[ \t\n\r\v] /* skip whitespace */
[_a-zA-Z]([_a-zA-Z]|[0-9])* printf("IDENT\n");
[0-9]+ printf("INTEGER\n");
[0-9]+\. printf("DOUBLE\n");
Now i ...