文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > Yacc Yet Another Compiler-Compiler
侵权投诉

Yacc Yet Another Compiler-Compiler

Yacc Yet Another Compiler-Compiler

Yacc:YetAnotherCompiler-Compiler

StephenC.Johnson

ABSTRACT

Computerprograminputgenerallyhassomestructure;infact,everycomputerpro-gramthatdoesinputcanbethoughtofasde ningan‘‘inputlanguage’’whichitaccepts.Aninputlanguagemaybeascomplexasaprogramminglanguage,orassimpleasasequenceofnumbers.Unfortunately,usualinputfacilitiesarelimited,dif culttouse,andoftenarelaxaboutcheckingtheirinputsforvalidity.

Yaccprovidesageneraltoolfordescribingtheinputtoacomputerprogram.TheYaccuserspeci esthestructuresofhisinput,togetherwithcodetobeinvokedaseachsuchstructureisrecognized.Yaccturnssuchaspeci cationintoasubroutinethathan-dlestheinputprocess;frequently,itisconvenientandappropriatetohavemostofthe owofcontrolintheuser’sapplicationhandledbythissubroutine.

TheinputsubroutineproducedbyYacccallsauser-suppliedroutinetoreturnthenextbasicinputitem.Thus,theusercanspecifyhisinputintermsofindividualinputcharacters,orintermsofhigherlevelconstructssuchasnamesandnumbers.Theuser-suppliedroutinemayalsohandleidiomaticfeaturessuchascommentandcontinuationconventions,whichtypicallydefyeasygrammaticalspeci cation.

YacciswritteninportableC.Theclassofspeci cationsacceptedisaverygeneralone:LALR(1)grammarswithdisambiguatingrules.

InadditiontocompilersforC,APL,Pascal,RATFOR,etc.,Yacchasalsobeenusedforlessconventionallanguages,includingaphototypesetterlanguage,severaldeskcalculatorlanguages,adocumentretrievalsystem,andaFortrandebuggingsystem.

0:Introduction

Yaccprovidesageneraltoolforimposingstructureontheinputtoacomputerprogram.TheYaccuserpreparesaspeci cationoftheinputprocess;thisincludesrulesdescribingtheinputstructure,codetobeinvokedwhentheserulesarerecognized,andalow-levelroutinetodothebasicinput.Yaccthengen-eratesafunctiontocontroltheinputprocess.Thisfunction,calledaparser,callstheuser-suppliedlow-levelinputroutine(thelexicalanalyzer)topickupthebasicitems(calledtokens)fromtheinputstream.Thesetokensareorganizedaccordingtotheinputstructurerules,calledgrammarrules;whenoneoftheseruleshasbeenrecognized,thenusercodesuppliedforthisrule,anaction,isinvoked;actionshavetheabilitytoreturnvaluesandmakeuseofthevaluesofotheractions.

YacciswritteninaportabledialectofC1andtheactions,andoutputsubroutine,areinCaswell.Moreover,manyofthesyntacticconventionsofYaccfollowC.

Theheartoftheinputspeci cationisacollectionofgrammarrules.Eachruledescribesanallow-ablestructureandgivesitaname.Forexample,onegrammarrulemightbe

date:month nameday´,´year;

Here,date,month name,day,andyearrepresentstructuresofinterestintheinputprocess;presumably,month name,day,andyeararede nedelsewhere.Thecomma‘‘,’’isenclosedinsinglequotes;thisimpliesthatthecommaistoappearliterallyintheinput.Thecolonandsemicolonmerelyserveaspunc-tuationintherule,andhavenosigni canceincontrollingtheinput.Thus,withproperde nitions,the

第1页

你可能喜欢

热门文档

相关文档

  • 3--CH04--语法分析-YACC

    YACC 使用方式 YACC(Yet Another Compiler-Compiler) YACC使用方式: YACC说明文件 translate.y YACC编译器 Y.tab.c %yacc Y.tab.c translate.y a.out C语言...

  • yacc中的冲突错误

    而 Yacc( yet another compiler-compiler)能帮助完成步骤<2>。 本文给出了一个构建 lex/yacc 解析器的简单例子,并主要讨论了 yacc 中的冲 突错误。 2. lex/...

  • Yacc 另一个编译器的编译器

    Yacc 另一个编译器的编译器_IT/计算机_专业资料。使用Yacc可以创建一个编译器,文章主要讲述Yacc使用方法。Yacc: Yet Another Compiler-Compiler Yacc: 另一个编译...

  • Yacc 与 Lex 快速入门

    Yacc 代表 Yet Another Compiler Compiler Compiler。 让 我们从 Lex 开始吧。 Lex Lex 是一种生成扫描器的工具 扫描器是一种识别文本中的词汇模式的程序。这 ...

  • Yacc使用指南

    Yacc使用指南_IT/计算机_专业资料。编译原理YACC(BISON)使用指南 YACC(Yet Another Compile-Compiler)是语法分析器生成工具,它生成的是 LALR 分 析器。Yacc 于上...

  • Win7下lex 与 yacc的安装配置

    yacc Yacc 代表 Yet Another Compiler Compiler。 Yacc 的 GNU 版叫做 Bison。它是一种工 具,将任何一种编程语言的所有语法翻译成针对此种语言的 Yacc 语 法...

  • Yacc 与 Lex 快速入门

    Lex 代表 Lexical Analyzar.Yacc 代表 Yet Another Compiler Compiler. 让我们从 Lex 开始吧. Lex Lex 是一种生成扫描器的工具.扫描器是一种识别文本中的词汇...

  • ACCENT生成的语法分析器中多个语法错误检查的实现

    金成植 编译程序构造原理和实现技术 2000 5.Johnson S C Yacc:Yet Another Compiler-Compiler 1978 6.Schroer F W The ACCENT Compiler Compiler,Introduction and...

  • 用于消除语法分析冲突的YACC文法变换模式

    关键词: 关键词: YACC 语法分析 冲突文法变换 模式 引言 YACC(Yet Another Compiler Compiler)是美国贝尔实验室著名的编译程 序生成系统, 用于开发以字符流输入的...

  • Yacc+与+Lex+快速入门

    下面我们来讨论 Yacc... Yacc Yacc 代表 Yet Another Compiler Compiler。 Yacc 的 GNU 版叫做 Bison。它 是一种工具,将任何一种编程语言的所有语法翻译成针对...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email