My yacc parser creates a symbol table, but I need to take scope into account. How would I do that? I heard something about how when you exit a scope, the symbol table gets destroyed. Still not very clear on how to do this.
...
I have syntax like
%(var)
and
%var
and
(var)
My rules are something like
optExpr:
| '%''('CommaLoop')'
| '%' CommaLoop
CommaLoop:
val | CommaLoop',' val
Expr:
MoreRules
| '(' val ')'
The problem is it doesnt seem to be able to tell if ) belongs to %(CommaLoop) or % (val) but it complains on the ) inst...
I'm interested in learning - at depth - about compiler theory...
parsing
EBNF
LALR?
Are all terms I'm familiar with but don't really understand how to actually implement/use..
I'm looking for links, tutorials, and other resources; all online, preferably all free...
I'm more interested in simple / complete implementations, than comp...
In my yacc file I have the following code:
fun_declaration : type_specifier ID '(' params ')'
{$2->type = "function";
$2->args = params; }
params : param_list | VOID ;
Do you see what I'm trying to do?
args is a string. I'm trying to put the function parameters into this string. How to do that...
On some linux machines when I compile my yacc program it works fine. However, on other machines, I noticed that none of the c statements that are interspersed with the grammar rules are ever executed, even printf. What could be the problem? I noticed that on these machines I have to take out the -ly option because it gives an error if...
I have a situation where there is a rule with a shift/reduce conflict that i understand. I want a rule to never reduce until at the last moment possible (end of line). So I would like to say always shift. How do i do this?
...
I have this in my yacc file.
var_declaration : type_specifier ID ';' {$2->args = ""; $2->value = 0; $2->arraysize = 0; $2->type = "variable";}
Everything above works.
I want to add this to it.
fn($2);
From inside the function, I want to do stuff like this.
fn(struct symtab sp)
{
sp->value = 0;
}
But when I try to c...
I want to pass the actual string of a token. If I have a token called ID, then I want my yacc file to actually know what ID is called. I thing I have to pass a string using yylval to the yacc file from the flex file. How do I do that?
...
What is the purpose of union in the yacc file? Is it directly related to yylval in the flex file? If you don't use yylval, then you don't need to use union?
...
When I redirect input to my yacc program from an input file, after it finishes parsing the file I want the yacc parser to print a summary of what it did. I want it to do the same thing if I am entering input through the keyboard and then I press Ctrl-D. Is there a way to do that?
...
I want my flex/yacc program to do the same thing as what it already does, but I want to modify it a little. If I were to put a main() in my .l file, and have it do the same thing as if I didn't add a main(), then what would the code look like?
...
I'm only able to make functions inside the global scope. Scope nesting means being able make functions within functions, right? I'm not able to do that with this grammar. Is it possible?
/* C-Minus BNF Grammar */
%token ELSE
%token IF
%token INT
%token RETURN
%token VOID
%token WHILE
%token ID
%token NUM
%token LTE
%token GTE
%tok...
At the moment i'm working on using the python implementation of Yacc/Lex to build a formula parser for converting strings of formulae into a set of class defined operands. So far i've been mostly successful but i've come to an empasse in defining the parsing rules due to ambiguity with parentheses and several shift/reduce errors.
The B...
Suppose I want my Lex and Yacc program to parse the command line arguments like:
./a.out show memory
I want lex to parse the string "show memory". How do I accomplish this?
...
i want to parse a string which i give in the main function iin yacc . i know tat this could be done by using yy_scan_string but i don't know how to use it. i even searched net and man pages but it is not clearly given so pls help me
...
i want to parse from a string rather than a file. i know that v can use yy_scan_string fn to do it.but for me it's not working properly so pls help me
...
lex and yacc are supposed to be used together.
Which ones is the scanner and which one is the parser?
Which one creates a scanner and which one creates a parser?
...
In compiler class we made a parser for a made up language that is a simplified version of C. All the parser does is make a symbol table based on the input and exit with an error message if the syntax is incorrect. Now we need to take an input file that is written in this language, and convert it into mips code (actually spim code which ...
i want my yylex to parse a string rather than a file or stdout.how can v do it in solaris
...
I'm using yacc to make a symbol table for a made-up language grammar.
Column 1 will have either "variable" or "function."
Column 2 will have either "int" or "void."
I was thinking of naming one column "type" but then I wouldn't know what to call the other one.
...