Questions tagged [yacc]
The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system.
yacc
1,934
questions
-4
votes
0
answers
59
views
When awk becomes too cumbersome, what is the next classic Unix tool to consider to deal with text transformation? [closed]
Awk is invaluable for many purposes where text filter logic spans multiple lines and you need to maintain state (unlike grep and sed), but as I'm finding lately there may be cases where you need ...
0
votes
0
answers
55
views
When writing my own lex/yacc, my code that was cpmpiled by g++ producted a weird bug
Could you please help me identify where the issue might be in my code, or is there possibly a problem with the compiler itself?"
I was writing my own lex/yacc by cpp. There is some codes for ...
0
votes
0
answers
24
views
Yacc/Bison generic function expression shift/reduce conflict
I am trying to implement a grammar for complex expressions that include comparisons, identifiers, and even generic function invocations.
All of these should be legal expressions:
Simple identifier:
...
-4
votes
1
answer
36
views
Variables Calculator Bison and flex [closed]
How can i Write a LEX and Bison Program to recognize a valid arithmetic expression that uses operators +, -, * and /and It gives priority to parentheses () and Accepts definition of variables and this ...
0
votes
0
answers
16
views
Single variable equations using yacc and lex
I am making a chat using lex and yacc. Now the chat can answer different questions and make simple calculus using +, -, * and / . I want to add a functionality that permits the chat to do some simple ...
1
vote
0
answers
32
views
Unknown type name ‘Node’ in the parser file. (Yacc program)
I've been working on a Yacc program (parser.y) to develop a small compiler that handles arithmetic operations. I'm using Yacc (Bison) and Lex tools to generate the parser and lexical analyzer, ...
0
votes
0
answers
29
views
yacc returns without parsing full sentence
I am currently trying to write a parser in lex and yacc to parse all valid time formats. The relevant .l and .y codes are included below.
^[0-9]{1,2} { printf("HOUR: %s\n", yytext); return ...
2
votes
1
answer
68
views
I'm writing a simple calculator using Flex and Bison, but I keep encountering errors like missing library, unresolved reference
%option noyywrap
%{
#include "calculator.tab.h"
int yyerror(const char *);
%}
%%
[ \t]
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
"+" ...
1
vote
1
answer
96
views
Is it possible to convert a parser made with YACC to a Haskell parser combinator?
I am looking at updating an old project that contained a YACC parser generator for parsing a specific file type. I want to improve the performance of this tool and was considering updating the parser. ...
0
votes
1
answer
30
views
Syntax fragment (include or import) in YACC
Is it possible to include/import yacc fragment files from different files to a main YACC?
Just to exemplify what I'm looking for, I would like to create 3 syntax parsers for 3 different files, but ...
0
votes
1
answer
59
views
How to recover from error in Bison in this LALR grammar?
I am trying to find out how to correctly recover from error in Bison. The thing is, when the input is correct, everything works until the input is incorrect. In that case it determines all next inputs ...
0
votes
1
answer
33
views
weird string literal in goyacc action: is "ab\\\ncd" acceptable but "ab\ncd" NOT?
I came across this code in goyacc program, in cpyact function. When we see string literals that start with " or ', we just copy them. But the handling for "\\" and "\n" seems ...
0
votes
0
answers
62
views
Does a non terminal token need an explicit definition?
I am writing code in bison that parses various assembly instruction. Here is a tidbit:
text
: text NEWLINE Instruction
| Instruction
;
Instruction
: r-type
{
instruction....
0
votes
0
answers
92
views
yacc grammar for parsing simple expressions
help me create a yacc grammar for parsing a simple expression, specifically this expression:
1;1;1;1;1;
It's important to consider some specifics:
Semicolon may be optional after the last '1'
The ...
0
votes
1
answer
48
views
Yacc grammar: Resolving Shift/Reduce and Reduce/Reduce Conflicts
I am developing a parser for a specific DSL language. Below is a working (but incomplete) grammar:
%{
package main
%}
//%type<stmts> stmts
%type<stmt> stmt
//%type<stmt_if> stmt_if
/...