During parsing, if I encounter a include token I want to instruct YACC to open the file specified as input and to begin parsing this. Once this parsing is finished, I want to instruct YACC to return to the file and continue parsing directly after the include expression. I will restrict the include depth level to one.
...
%code top command doesn't include its contents in parser.tab.h file (It should do so, right?). Bison version is 2.4.1. What is the problem with this (simplified) code?
%{
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <io.h>
#define YYDEBUG 0
int errors;
%}
%code top {
struct DICT
{
char *Nam...
Inconvenience in specifying grammars - we cannot factor out bin_op in following example (Bison):
expr : expr bin_op expr ;
bin_op : Add
| Mul
;
because of shift/reduce conflicts. Is there parsing technique or parser generator which allows such thing?
...
I am using bison and its difficult to figure out the conflicts by looking at y.output. Is there a tool to make or filter y.output so its more useful? i would love to see the full path to the state with the conflict but anything helpful is what i would like.
...
I want to make a 3 ^ 2 = pow(3, 2) but it's giving me a "undefined reference to 'pow'". I've already added math to the headers too.
Do I have to define the operation myself?
...
Hi, i have a lex and yacc file which compiles fine on linux.
When i try to compile it on windows using Visual c++ using the lex.yy.c & y.tab.c files i get the following error:
program1.y(184) : error C2059: syntax error : '<'
line 184 is
#define YYLAST 95
...
I'm supposed to write a program that does 2 + 2 = 4 and 2.2 + 2 = 4.2.
I've already done it so that it treats everything as a floating point, but that's "wrong". I have to distinguish them. Here's what I have so far:
%{
#include <stdio.h>
#include <ctype.h>
%}
%token <dval> FLOAT
%token <ival> INTEGER
%union
{
float dval;
int i...
Most of the posts that I read pertaining to these utilities usually suggest using some other method to obtain the same effect. For example, questions mentioning these tools usual have at least one answer containing some of the following:
Use the boost library (insert appropriate boost library here)
Don't create a DSL use (insert favor...
I have a YACC (Bison) grammar, a Lex (Flex) tokenizer, and a C program among which I need to share a struct (or really any variable). Currently, I declare the actual object in the grammar file and extern it wherever I need it (which is to say, my C source file), usually using a pointer to manipulate it. I have a shared header (and implem...
Is it possible to accept a bison-rule from the action in combination with the %glr-parser directive active?
Something like the following:
aRule : 'a' 'b' 'c' { /* Do some calculations and depending on those you allow/disallow this rule and continue the parsing without returning from the yyparse function. */ } ;
...
Does anyone know an online repository for lex/yacc format grammars? I'm looking for a Java grammar to make a quicky sourcecode converter.
Thank you!
edit: I'm preferably looking for lex/yacc because I want to use fslex/fsyacc with as little grammar rewriting as possible.
...
Hi,
I want to generate two separate parsing functions from lex/yacc. Normally yacc gives you a function yyparse() that you can call when you need to do some parsing, but I need to have several different yyparses each associated with different lexers and grammars. The man page seems to suggest the -p (prefix) flag, but this didn't work f...
I am wondering how to correctly compile a program with a Makefile that has calls to yyparse in it?
This is what I do:
I have a Makefile that compiles all my regular files and they have no connections to y.tab.c or lex.yy.c (Am I supposed to have them?)
I do this on top of my code:
#include "y.tab.c"
#include "lex.yy.c"
#include "y.ta...
I have some bison grammar:
input: /* empty */
| input command
;
command:
builtin
| external
;
builtin:
CD { printf("Changing to home directory...\n"); }
| CD WORD { printf("Changing to directory %s\n", $2); }
;
I'm wondering how I get Bison to not accept (YYACCEPT?) something as a command until...
how to parse from command line arguements in yacc ?
of course i undefined input in both lex & yacc and then wrote
int input(void)
{
printf("in input\n:");
char c;
if(target > limit)
return 0;
if((c = target[0][offset++]) != '\0')
return (c);
target++;
offset =0;
return (' ');
}
where target contains the command line arguements. But ...
Hallo Rudi,
I dont get the error, please can you help me out, here is the .l and .y file.thanks.
%{
#include "ifanw.tab.h"
extern int yylval;
%}
%%
"=" { return EQ; }
"!=" { return NE; }
"<" { return LT; }
"<=" { return LE; }
">" { return GT; }
">=" { return GE; }
"+" { return PLUS; }
"-" { return MI...
hallo,
i have a problem, the followed program gives back an error, error:: Undeclared(first use in function), why this error appears all tokens are declared, but this error comes, can anyone help me, here are the lex and yac files.thanks
lex:
%{
int yylinenu= 1;
int yycolno= 1;
%}
%x STR
DIGIT [0-9]
ALPHA ...
Is there a way to force bison and/or flex to restart scanning after I replace some token with something else?
My particular example would be with replacement for a specific word/string. If I want a word of hello to be replaced by echo hello, how can I get flex or bison to replace hello and then start parsing again (to pick up 2 words i...
I am experimenting with lex and yacc and have run into a strange issue, but I think it would be best to show you my code before detailing the issue. This is my lexer:
%{
#include <stdlib.h>
#include <string.h>
#include "y.tab.h"
void yyerror(char *);
%}
%%
[a-zA-Z]+ {
yylval.strV = yytext;
return ID;
}
[0-9]+ {
yylval.intV...
i want to parse a command line using a yacc but i want to call it from a c file. how it is possible ?
...