Simple calculator compiler using Lex and YACC

Mohit Upadhyaya
{"title":"Simple calculator compiler using Lex and YACC","authors":"Mohit Upadhyaya","doi":"10.1109/ICECTECH.2011.5942077","DOIUrl":null,"url":null,"abstract":"This paper contains the details of how one can develop the simple compiler for procedural lanaguage using Lex (Lexical Analyzer Generator) and YACC (Yet Another Compiler-Compiler). Lex tool helps write programs whose control flow is directed by instances of regular expressions in the input stream. It is well suited for editor-scripts type transformations and for segmenting input in preparation for a parsing routine. Lex tool source is the table of regular expressions and corresponding program fragments. The table is translated to a program which reads an input stream, copying it to an output stream and partitioning the input into strings which match the given expressions. On the other hand YACC tool receives input of the user grammar. Starting from this grammar it generates the C source code for the parser. YACC invokes Lex to scan the source code and uses the tokens returned by Lex to build a syntax tree. With the help of YACC and Lex tool one can write their own compiler.","PeriodicalId":184011,"journal":{"name":"2011 3rd International Conference on Electronics Computer Technology","volume":"18 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2011-04-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"5","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2011 3rd International Conference on Electronics Computer Technology","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/ICECTECH.2011.5942077","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 5

Abstract

This paper contains the details of how one can develop the simple compiler for procedural lanaguage using Lex (Lexical Analyzer Generator) and YACC (Yet Another Compiler-Compiler). Lex tool helps write programs whose control flow is directed by instances of regular expressions in the input stream. It is well suited for editor-scripts type transformations and for segmenting input in preparation for a parsing routine. Lex tool source is the table of regular expressions and corresponding program fragments. The table is translated to a program which reads an input stream, copying it to an output stream and partitioning the input into strings which match the given expressions. On the other hand YACC tool receives input of the user grammar. Starting from this grammar it generates the C source code for the parser. YACC invokes Lex to scan the source code and uses the tokens returned by Lex to build a syntax tree. With the help of YACC and Lex tool one can write their own compiler.
简单的计算器编译器,使用Lex和YACC
本文详细介绍了如何使用Lex (Lexical Analyzer Generator)和YACC (Yet Another compiler - compiler)为过程语言开发简单的编译器。Lex工具帮助编写控制流由输入流中的正则表达式实例指导的程序。它非常适合编辑器脚本类型的转换和为解析例程做准备而分割输入。Lex工具源码是正则表达式表和相应的程序片段。表被翻译成一个程序,该程序读取输入流,将其复制到输出流,并将输入划分为与给定表达式匹配的字符串。另一方面,YACC工具接收用户语法的输入。从这个语法开始,它为解析器生成C源代码。YACC调用Lex扫描源代码,并使用Lex返回的令牌构建语法树。在YACC和Lex工具的帮助下,可以编写自己的编译器。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信