Questions tagged [yacc]

The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system.

The name is an acronym for "Yet Another Compiler Compiler." It generates a parser (the part of a compiler that tries to make syntactic sense of the source code) based on an analytic grammar written in a notation similar to BNF. Historically, Yacc has generated the code for the parser in the C programming language.

Yacc used to be available as the default parser generator on most Unix systems. It has since been supplanted as the default by more recent, largely compatible, programs such as Berkeley Yacc, GNU bison, MKS yacc and Abraxas pcyacc. An updated version of the original AT&T version is included as part of Sun's OpenSolaris project. Each offers slight improvements and additional features over the original yacc, but the concept has remained the same. Yacc has also been rewritten for other languages, including Ratfor, ML, Ada, Pascal, Java, Python and Common Lisp.

The parser generated by yacc requires a lexical analyzer. Lexical analyzer generators, such as Lex or Flex are widely available. The IEEE POSIX P1003.2 standard defines the functionality and requirements for both Lex and Yacc.

Some versions of AT&T Yacc have become open source. For example, source code (for different implementations) is available with the standard distributions of Plan 9 and OpenSolaris.

http://en.wikipedia.org/wiki/Yacc

Books

See also:

1902 questions
0
votes
1 answer

Bison - Skipping tokens after a specific token

I'm trying to simulate a comment statement in the language I'm working on. By using the keyword REM, I want to ignore everything that goes after that token until it hits an enter. Example would be like REM randominstruction {;} Where…
Silvestrini
  • 445
  • 4
  • 19
0
votes
1 answer

y.tab.c and y.tab.h files are not generated on win64

I ran the following command in the Windows command prompt: yacc -d calci.y After successful execution it generates 2 files: calci.tab.c and calci.tab.h. But it should have generated y.tab.c and y.tab.h. I am very new to lex and yacc, so I do not…
ankitmittal
  • 61
  • 1
  • 3
  • 7
0
votes
1 answer

BISON - How to enter a complete input?

How can I input a full statement for example x = 2 instead of doing like: input: x *enter* input: = *enter* input: 2 *enter* ? Currently I manage to enter inputs on BISON but separately instead of just one statement. I get outputs from single…
Silvestrini
  • 445
  • 4
  • 19
0
votes
1 answer

BISON and YACC - How to input a complete statement

This is my first time trying out BISON and I'm stuck trying to figure out how to take a complete statement for example astros = 2. Whenever I try to do that, I don't get any output. But if I try each part separately then I get output for each part.…
Silvestrini
  • 445
  • 4
  • 19
0
votes
1 answer

Yacc- Struct as incomplete or unknown type

Here is my top of yacc file.y %code requires { struct Id { char *var; }; struct Commds; struct Commd { struct Id lhs; }; struct Commds { struct Commd commd; struct Commds *next; }; …
Dago
  • 788
  • 2
  • 9
  • 24
0
votes
1 answer

Yacc - Building data structures using %union and linked-list

I am trying to build special data structures in my program while using yacc.Here is part of my grammar: commands : commands command {if($$ == 0){$$ = &$2;} struct Command* ptr = $$; …
Dago
  • 788
  • 2
  • 9
  • 24
0
votes
1 answer

Trouble parsing elif using PLY

I'm continuing my journey into parsing using PLY. I've run into a problem when parsing IF and ELSE IF statements. Here is my code, I've stripped out the irrelevant bits and just left it with the basics (this will run on Python 2.7). from ply import…
Colin Basnett
  • 4,052
  • 2
  • 30
  • 49
0
votes
1 answer

Inject new lexemes in a yacc Rule

I have the following grammar (this a simplified one): S -> EXPR EXPR -> ITEM addop EXPR EXPR -> ITEM ITEM -> num ITEM -> ident having: num: a floating point number ident: a string representing an identifier addop: + I am using PLY library for…
Samfaitmal
  • 80
  • 10
0
votes
2 answers

lex and yacc analyzer

Now here is my lex code %{ #include #include "y.tab.h" extern int yylval; int yywrap(); %} %% [a-zA-Z] {yylval = *yytext; return ALPHABET;} [0-9]+ {yylval = atoi(yytext); return NUMBER;} [0-9]+"."[0-9]* {yylval = atof(yytext);…
s.zen
  • 11
  • 6
0
votes
1 answer

Segmentation fault ( core dumped ) when editing a file?

I'm making a program with bison in ubuntu that edits a ppm file given the user input but I'm having a segmentation fault core dumped error and I cant seem to fix it, heres my code: void ponto(int x, int y, char fname[100]){ int r,g,b; int i,j; …
0
votes
0 answers

How to recognize non reserved keywords in yacc?

I am writing a SQL grammar which is straightforward for the most part, but ran into a snag when writing the rule for the CASE statement. It would be trivial if CASE and WHEN were reserved tokens in the SQL language, but they aren't. Either can be…
0
votes
1 answer

Universal way to transform right recursion to left one

I am recently working with Flex and Bison. I know that generally the latter one does not work well with right recursion due to stack size. On the other hand most of the grammar problems are easily solvable with right recursion. AFAIK there is…
bartop
  • 9,971
  • 1
  • 23
  • 54
0
votes
1 answer

Bison: getting syntax error for no reason

I've written a flex/Bison grammer which works perfectly untill a certain point. But when I add a new non-terminal with a new grammer rule - no matter which one I get the following warning: warning: rule useless in grammar [-Wother] when i move the…
i7ay
  • 3
  • 2
0
votes
5 answers

Parser with LEX and YACC

i'm trying to implement a time parser with LEX & YACC. I'm a complete newbie to those tools and C programming. The program has to print a message (Valid time format 1: input ) when one of those formats is entered: 4pm, 7:38pm, 23:42, 3:16, 3:16am,…
0
votes
1 answer

GNU marks in auto generated source by lex or bison

I want to submit some code that generated by lex and bison. Since there are gnu marks in them, I'm serious if it will become a trouble later to a non open source, commercial project. Thanks for any suggestion.
Hao
  • 418
  • 3
  • 8
1 2 3
99
100