90 likes | 223 Vues
This project explores the integration of Bison and Flex for generating parsers. It covers command-line options for Bison, key concepts of semantic actions, and how to properly handle unquoted strings and nonterminals in productions. The guide includes steps for compiling with GCC, creating the necessary C files, and incorporating Flex-generated patterns. By following this project, you'll learn to seamlessly generate parsers that efficiently manage translation requirements and handle input to Bison through effective sequence management.
E N D
Project Part 2: Parser Bison Bison Command line: bison –d translate.y Command line: flex filename.l gccy.tab.clex.yy.c -lfl
Input to Bison semantic actions (sequence of C statements ) Default semantic action is $$=$1 unquoted strings not declared as tokens are taken as nonterminals $$ attribute value of production head $iattribute value of ith symbol in production body
bison + flex • First use flex to generate yy.lex.c without mainfunction • In input to bison, put #include “yy.lex.c” in the declaration part of the file Or • Compile both c files with gcc