Ce 322 (0246Er ©Erc D00HP Compiler Construction Prof. Levy Problem Set 6 Due Monday 08 March Reading Assignm

Total Page:16

File Type:pdf, Size:1020Kb

Ce 322 (0246Er ©Erc D00HP Compiler Construction Prof. Levy Problem Set 6 Due Monday 08 March Reading Assignm ¢¡¤£¦¥¨§ © ¨ ¨ ! #"%$'&)(©*&)('+ ,.-/-1032 46587:9<;>=?A@4B5C*DFEG@IH*JKEL;5C MONQPSRTU%VXWFY Z []\_^a`cb¤d efb g h i*jGV]klPnmpoLqrY sStuklqSNQvxw ?AzO{|;}C*~DGDp;~C<7:?C8E% @LzO~58C¢55¨# y @I;EFEp?CDGDG;}~C<7:?C8E M3qSN>xIi*NqnPnm 8PFPnV )V¡NQv¢¤£>V¦¥A§©¨I¨_ª>«p¬®­ª}¯¬ M3qSN>]Qx°V¡v¡qS±¤±²PSjpN|nNqS³´³uqSNµR¶PnN¸·n¹Sº¤VX)»pNQV£Q£>¢¤Pnmp£¦¢¤m¼k½UO¾ANQV»pNQPFopjpvV¡o6¿1V¡±©PÁÀaÀ¢©Qw6qopop¢©Q¢¤PnmpqS±ÂN>jp±¤V£ R¶PnNqNQ¢©Qwp³´V¢©v*qSmGol¿1P)PS±¤VrqmÃVX)»pNQV£Q£>¢¤Pnmp£ÅÄ ª ¬ «Fá «cä Æ>ÇÈ1ÉËÊ Ì¤ÆXÍÏÎQÆ>ÇÈ1ÉlÐ.ÑSÉXÒÓÍÓÔFÎQÆ>ÇÈ1ɽÐ.ÕXÖÁÖ'Ì×ÎQÆ>ÇÈ1É Ð Æ>ÇÈ1É Ð)ØÚÙÛÐFÜ/ÝÞàß ÐcßOâ/â1ã Ü «æå « ̤ÆXÍÚÎQÆ>ÇÈ1ÉËÊ ã Õ¡ÒÓç1èSÒÓçFé'ê]ØÏÜÆ>ÇÈ1É Ü3Ù ÑSÉ ÒÓͶÔFÎQÆ>ÇÈ1É¨Ê Æ>ÇÈ1ÉËëÆ>ÇÈ1ɽÐ/Æ>ÇÈ1Éuì Æ>ÇÈ1É ä á ÕXÖÁÖ'Ì×ÎQÆ>ÇÈ1É¨Ê Æ>ÇÈ1É ÜÙÆ>ÇÈ1ɽÐ/Æ>ÇÈ1ɸâ Æ>ÇÈ1É Õ¡ÒÓç1èSÒÓçFé'êíÊ Õ¡ÒÓç1èSÒÓçFé¼Ð.Õ¡ÒÓç1èSÒÓçFé.î%Õ¡ÒÓç1èSÒÓçFé'ê ä Õ¡ÒÓç1èSÒÓçFéÃÊ ï ã8ð'ÑSÉuñòÆ>ÇÈ1É À¢ów wpV]jp£QjpqS±Âq£Q£QjG³u»GQ¢¤PnmG£q¿.Pnj)µ»pN>V¡vV¡opVmpv¡V ôõËö ¾1ä ö á÷X¾1qSmpo wpV|R¶Pn±¤±©PÁÀ¢¤mp¨N>V¡njp±¤qSNopVø)ù ë Ü3Ù â mp¢ó¢©Pnmp£¡ ùþ/q'ùÿ¡ ù}þ/q®ùÿrs®ù£¢¤ ¦¥ ØÚÙúÊ ûýü ûýü «Fá s'ù£¢§ ©¨ Ü/ÝÞàß Ê û «Fä åÁá « ¯ä « ßOâ/â1ã Ü¢Ê Ý Ð ã jG»p».PS£QV¨£QPS³uVPnmpV¸³uqSSV£µwGVíR¶Pn±¤±©PÁÀ¢¤mp´£QjpSnV¡£}¢¤PSm/R¶PSNwG¢¤£*£>PnN><PR£Q¢¤³´»p±©V¦»pN>PnnNQqS³u³´¢¤mGu±¤qSmpnjLqnVS¾ ÀV¦v¡qSmqrWSPn¢¤o ÀNQ¢ó¢¤mGuqËop¢©£>¢©mpvYF»1VXùvxwGV¡vxc¢¤mpv¡Pn³´».PSmpV¡mær¾I¿æY ¢¤mGv¡PnN>».PnNQq¢©mp¸YF».V¦¢¤mGR¶PSNQ³uq¢©Pnm ¢¤mæQP QwpVnNQqS³´³qSN<¢ó£>V¡±©RT LPnN|VXGqS³´»p±©VS¾3QP»pN>Pnwp¢¤¿G¢©]³u¢Å)¢¤mp jp»B¿1PFPn±¤V¡qSmp£¦qSmpo6mcjp³í¿.VNQ£¡¾²ÀVvPnjp±©oB³uPÁWSV «cá¸R¶NQPn³QwpV¸° PSR²wGV NQjp±©V]QPuQwpVí° PSR²wGV ¾.qSmpol³uPÁWSV «Fä QPuwGV Ü/ÝÞàß Æ>ÇÈ1É ÑSÉ ÒÓÍÓÔFÎQÆ>ÇÈ1É ßOâ/â1ã Ü ° PSRwpV N>jp±¤VT ÕXÖÁÖ'Ì×ÎQÆ>ÇÈ1É wLq'¸¢¤£]ÀNQPnmG½À¢©Qw6wp¢©£¸qSN>njp³´V¡mæ »1V¡v¢©øLv¡qS±¤±óYn¾ÂÀwLq'¸v¡N>jpv¡¢¤qS±V¡±¤V³uVmæ¸opPFV¡£íQwpV £>Pn±¤jGQ¢¤Pnm¤RÚqS¢©±QP wLqmpop±¤V É çæÖ ÉíÑSçGê¡8ÆXÉê|ÒÓçÍÖƨÖ'çuÈGÑXÈLÆXÉ ! #"%$'&)(*+ #,.-¡/103254§67&)698§:<;81=?>A@% +"§6.,'&)(BDC¡EF81:<;G/§(¡"§BD@¤HJI=?>AIK #"¤6.,'&)(¡BDCEF@¤H/1L14M,FNO*# +P¡&Q,'R1&S6 +TVU1*+&W$9X¡&)$'67 +C¡"§6OLY&£, ,'&W$AZ @L5~@Lz7:7;}C*~DGDG;}~C<7:?C8E ¡wp¢©£qS£>£Q¢©nmp³´V¡mæ½wpqS£lÀP »pjpN>».Pn£>V¡£aô£¢®÷ RÚqS³u¢©±¤¢¤qSNQ¢©ÿ¡¢¤mG¼YnPSjpNQ£>V¡±©R¨À¢ówÛ¿pjp¢¤±©op¢¤mG »pqSNQ£>V¡NQ£½jp£Q¢©mp wGV ¤ ±©VX¦¥¨§ ©MÛqS±óVNQmLqQ¢©WSV¦Pñ©VX¦¥'YnqSv¡v ô n÷N>YF¢©mpÃPnjGµop¢ .V¡N>V¡mæ<£>YF³¸¿1Pn±xqS¿p±©Ví¢©³u»p±©V¡³´V¡mæxq'¢¤PSmp£PãQVV î Àwp¢©vxw½qNQV|³uPS£>V´v¢¤V¡mæ¡T¡P´v¡Pn³´»p±¤VXVµQwpV]qS£Q£>¢¤nmG³uVmc¡¾L».VN>R¶PnN>³QwpV<R¶Pn±¤±©P®À¢©mp¸£}V¡»G£¡ ¢ST©mpÿ¡¢©»ÃwpV<øL±©V FT ¼NQ¢óVq § ©µM¼nNqS³´³uqSNÂv¡qS±¤±©V¡o"!#%$'&¨(*)+-,/.0.¾p¿Lq£QV¡o´Pnm¨wGVSNqS³´³qN¢¤m¨QwpVÀNQ¢©>Vmuq£Q£Q¢©nmp³´V¡mærT 1PSjpNnNq³u³uqSN £>wpPnjp±©o ¢©mpv¡±©jpopV*QwpV|»pNQVv¡V¡oGV¡mpvV¡£*³´V¡m梩PnmpVolq¿.PÁWnVT T§8PS³u»p±©VQV½wpV౩VX)¢¤v¡qS±µN>jp±¤V£ R¶PnNQwpV3¤ ±¤V £>vrqSmpmGV¡N ¢¤m4!#%$*&5(*)+6p·æ¹¨7I¾<jp£>¢¤mpúwGV¤qS»p»pN>Pn»pNQ¢¤qV 2 8&9;:<F·´³´VQwpPFop£ R¶PnN wGV]N>VQjpNQm WSq±¤jpV£]ôÏqS±©±.wGNQV¡V]vrqmlwLqrWSV]wGPn±¤±©P®ÀÛ³´VwGP)op£ QPË£>xqN> ÷ TD LPn±©±¤PÁÀ¢¤mG¦wGV?>¨&9;:<F·8!'@A:I·æ¹Ã¢¤mæQV¡N>RÚqv¡VS¾L¢©³u»G±¤V¡³´V¡mæwpN>V¡V]op¢ .V¡N>V¡mæWnVNQ£Q¢©Pnmp£PSRÂqË£}YF³¸¿.PS±/xqS¿p±©VS = ôÚqæ÷B)#%$p¹0@¨C'>¨&9;:<F·8!'@A:I·æ¹p¾Àwp¢©vxw jG£QV¡£´qà£Q¢©³u»G±¤V±©¢¤£} ô ¾D0@E'@ .Fº#n·FGG¹',®ºH<C)÷´QPà£>QPnNQVÃwGV Æ ×é £>YF³¸¿1Pn±/xqS¿G±¤V<V¡mæQNQ¢¤V£¡T ô¶¿I÷JI#KL;M'@'/Np¹¨O*>¨&¨9;:<c·8!¦@A:I·n¹p¾Àwp¢©vxw6jp£>V¡£¸q wLqS£>wæxqS¿p±©Vu¿pqS£QVo6Pnm¤wpVuM¤¤ wLqS£>w)ùR¶jpmGv¢©Pnm¼qS±óù nPnNQ¢ówp³ ¢©m 3¢¤pTQPFT Pnm »LqSnV TS T¼PSRwpV½i*NqSSPnm ¿1PFPnITVU jp£>V ·0</$*W ¢©mp£>QVrqSo PSR = 25R ÒÓçLÍ .;$#;/W¨$L¹¨O¼ô¶ÀwG¢¤vxwX¤nqÁWqËopPFV¡£QmZY wLqrWnVr÷X¾LP´qrWnPS¢¤o mFjG³uVNQ¢¤v¡qS±/PÁWnVN\[LPÁÀ|T ô¶vÁ÷]>.0$;M'@'/Np¹¨O*>¨&¨9;:<c·8!¦@A:I·n¹p¾3Àwp¢©vxwjp£QV£ jpmZY £^D;@E'@_.)º#n·F M¦@'NFº'@:I·n¹¢ôÚPnmGVXù±©¢¤mpVN`Y £R¶PnNV¡qSvxw ³uVXwpPFoÃYnPnjl¢¤³´»p±¤V³uVmcx÷XT T©£QV<wGV W)¹A$FºG¹¦®º »pN>PnnNq³ »pN>P®WF¢©opV¡o PËnVmpV¡NQqV]£qS³´»p±©V*¢¤mp»GjG£R¶PnN YSPnjpN»LqSN>£QV¡NT8°jpmpmG¢¤mp¨wGV R vPn³´³qSmGo a D;@E'@bW)¹A$FºG¹¦®º]c ö Ö ÍedÌ¤Æ À¢©±¤±»pjG q6±¤¢óQQ±¤Vlk½U »pNQPSnNqS³ À¢ówfc NQqSmpopPS³u±óYcùmLqS³´V¡o¢WqSNQ¢¤qS¿p±¤V opVv¡±¤qSNqQ¢¤PnmG£u¢©mcQP6wGVløL±©V To1Pnj vrqm QwpV¡m V£>YnPnjGN»pqSNQ£>V¡NPnmÃwp¢©£ øL±¤V<¿æY NQjGmpmp¢¤mGËQwpV|v¡Pn³´³uqSmpo g/hHi\jklnm a D0@¨E'@b!#%$*&¨(') Tq§8Pn³´»LqSNQV QwpV⩳uVqSSVm ¿æYBQwpVÃwpN>V¡V £>YF³¸¿1Pn±8qS¿p±©V⤳´»p±¤V³uVmcq'ù Ö ÍpdÌ¤Æ Q¢¤PnmG£¡¾pjp£>¢¤mpËVmpPnjpnw op¢r KVNQV¡mæWqS±¤jGV¡£PSRFc¼T T)Ts¡jpN>ml¢©m QwpV<R¶Pn±¤±©PÁÀ¢¤mp¸¢óV³u£ ôÚqæ÷J!%$*&¨(*)t-,.0 ô¶¿I÷J!%$*&¨(*)t6p·n¹¨7 ô¶vÁ÷u)#%$p¹0@¨C'>¨&9;:<F·8!'@A:I·æ¹£D0@E¦@ ô¶oI÷JI#KL;M'@'/Np¹¨O*>¨&¨9;:<c·8!¦@A:I·n¹vD0@¨E'@ ô¶VÁ÷]>.0$;M'@'/Np¹¨O*>¨&¨9;:<c·8!¦@A:I·n¹vD0@¨E'@ ô¶R÷uw¢ówpVNPnm »LqS»1V¡NPnN¢¤m q¸øL±©VS¾Iq¨nNq»pw PnNxqS¿p±©V*£QwGP®À¢©mpËYnPnjpNN>V¡£QjG±©£R¶N>Pn³ wGV]±¤qS£> £>V»/T.
Recommended publications
  • Why Is C. Diff So Hard to Culture and Kill?
    Why is C. diff so hard to culture and kill? Clostridium difficile, commonly referred to as C. diff, is the #1 nosocomial infection in hospitals (it actually kicked staph infections out of the top spot). At Assurance, we test for this organism as part of our Gastrointestinal (GI) panel. C. diff is a gram-positive anaerobe, meaning it does not like oxygen. Its defensive mechanism is sporulation – where it essentially surrounds itself with a tough outer layer of keratin and can live in water, soil, etc. for over a decade. For reference, anthrax is another organism that sporulates. Once C. diff sporulates, it is very hard to kill and in fact, bleach is one of the only disinfectants that work. Unfortunately, it can spread quickly throughout hospitals. Spores of C. diff are found all over hospital surfaces and even in some hospital water systems. It’s the most threatening for those who are immunocompromised or the elderly, who are the most likely to end up with C. diff infections. With our PCR testing, we’re looking for the C. diff organism itself but we’re also looking at the production of toxin. Unless it produces toxins A AND B together OR toxin B, C. diff doesn’t cause severe disease. Many babies are exposed to it during birth or in the hospitals and may test positive on our GI panel. Unless they are expressing those toxins (both toxin A&B or just toxin B) it is not considered a clinical infection. Studies show that toxins A&B together causes infection, as well as toxin B.
    [Show full text]
  • Chapter # 9 LEX and YACC
    Chapter # 9 LEX and YACC Dr. Shaukat Ali Department of Computer Science University of Peshawar Lex and Yacc Lex and yacc are a matched pair of tools. Lex breaks down files into sets of "tokens," roughly analogous to words. Yacc takes sets of tokens and assembles them into higher-level constructs, analogous to sentences. Lex's output is mostly designed to be fed into some kind of parser. Yacc is designed to work with the output of Lex. 2 Lex and Yacc Lex and yacc are tools for building programs. Their output is itself code – Which needs to be fed into a compiler – May be additional user code is added to use the code generated by lex and yacc 3 Lex : A lexical analyzer generator Lex is a program designed to generate scanners, also known as tokenizers, which recognize lexical patterns in text Lex is an acronym that stands for "lexical analyzer generator.“ The main purpose is to facilitate lexical analysis The processing of character sequences in source code to produce tokens for use as input to other programs such as parsers Another tool for lexical analyzer generation is Flex 4 Lex : A lexical analyzer generator lex.lex is an a input file written in a language which describes the generation of lexical analyzer. The lex compiler transforms lex.l to a C program known as lex.yy.c. lex.yy.c is compiled by the C compiler to a file called a.out. The output of C compiler is the working lexical analyzer which takes stream of input characters and produces a stream of tokens.
    [Show full text]
  • Project1: Build a Small Scanner/Parser
    Project1: Build A Small Scanner/Parser Introducing Lex, Yacc, and POET cs5363 1 Project1: Building A Scanner/Parser Parse a subset of the C language Support two types of atomic values: int float Support one type of compound values: arrays Support a basic set of language concepts Variable declarations (int, float, and array variables) Expressions (arithmetic and boolean operations) Statements (assignments, conditionals, and loops) You can choose a different but equivalent language Need to make your own test cases Options of implementation (links available at class web site) Manual in C/C++/Java (or whatever other lang.) Lex and Yacc (together with C/C++) POET: a scripting compiler writing language Or any other approach you choose --- must document how to download/use any tools involved cs5363 2 This is just starting… There will be two other sub-projects Type checking Check the types of expressions in the input program Optimization/analysis/translation Do something with the input code, output the result The starting project is important because it determines which language you can use for the other projects Lex+Yacc ===> can work only with C/C++ POET ==> work with POET Manual ==> stick to whatever language you pick This class: introduce Lex/Yacc/POET to you cs5363 3 Using Lex to build scanners lex.yy.c MyLex.l lex/flex lex.yy.c a.out gcc/cc Input stream a.out tokens Write a lex specification Save it in a file (MyLex.l) Compile the lex specification file by invoking lex/flex lex MyLex.l A lex.yy.c file is generated
    [Show full text]
  • User Manual for Ox: an Attribute-Grammar Compiling System Based on Yacc, Lex, and C Kurt M
    Computer Science Technical Reports Computer Science 12-1992 User Manual for Ox: An Attribute-Grammar Compiling System based on Yacc, Lex, and C Kurt M. Bischoff Iowa State University Follow this and additional works at: http://lib.dr.iastate.edu/cs_techreports Part of the Programming Languages and Compilers Commons Recommended Citation Bischoff, Kurt M., "User Manual for Ox: An Attribute-Grammar Compiling System based on Yacc, Lex, and C" (1992). Computer Science Technical Reports. 21. http://lib.dr.iastate.edu/cs_techreports/21 This Article is brought to you for free and open access by the Computer Science at Iowa State University Digital Repository. It has been accepted for inclusion in Computer Science Technical Reports by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. User Manual for Ox: An Attribute-Grammar Compiling System based on Yacc, Lex, and C Abstract Ox generalizes the function of Yacc in the way that attribute grammars generalize context-free grammars. Ordinary Yacc and Lex specifications may be augmented with definitions of synthesized and inherited attributes written in C syntax. From these specifications, Ox generates a program that builds and decorates attributed parse trees. Ox accepts a most general class of attribute grammars. The user may specify postdecoration traversals for easy ordering of side effects such as code generation. Ox handles the tedious and error-prone details of writing code for parse-tree management, so its use eases problems of security and maintainability associated with that aspect of translator development. The translators generated by Ox use internal memory management that is often much faster than the common technique of calling malloc once for each parse-tree node.
    [Show full text]
  • Tracking Computer Use with the Windows® Registry Dataset Doug
    Tracking Computer Use with the Windows® Registry Dataset Doug White Disclaimer Trade names and company products are mentioned in the text or identified. In no case does such identification imply recommendation or endorsement by the National Institute of Standards and Technology, nor does it imply that the products are necessarily the best available for the purpose. Statement of Disclosure This research was funded by the National Institute of Standards and Technology Office of Law Enforcement Standards, the Department of Justice National Institute of Justice, the Federal Bureau of Investigation and the National Archives and Records Administration. National Software Reference Library & Reference Data Set The NSRL is conceptually three objects: • A physical collection of software • A database of meta-information • A subset of the database, the Reference Data Set The NSRL is designed to collect software from various sources and incorporate file profiles computed from this software into a Reference Data Set of information. Windows® Registry Data Set It is possible to compile a historical list of applications based on RDS metadata and residue files. Many methods can be used to remove application files, but these may not purge the Registry. Examining the Registry for residue can augment a historical list of applications or provide additional context about system use. Windows® Registry Data Set (WiReD) The WiReD contains changes to the Registry caused by application installation, de-installation, execution or other modifying operations. The applications are chosen from the NSRL collection, to be of interest to computer forensic examiners. WiReD is currently an experimental prototype. NIST is soliciting feedback from the computer forensics community to improve and extend its usefulness.
    [Show full text]
  • Yacc a Tool for Syntactic Analysis
    1 Yacc a tool for Syntactic Analysis CS 315 – Programming Languages Pinar Duygulu Bilkent University CS315 Programming Languages © Pinar Duygulu Lex and Yacc 2 1) Lexical Analysis: Lexical analyzer: scans the input stream and converts sequences of characters into tokens. Lex is a tool for writing lexical analyzers. 2) Syntactic Analysis (Parsing): Parser: reads tokens and assembles them into language constructs using the grammar rules of the language. Yacc is a tool for constructing parsers. Yet Another Compiler to Compiler Reads a specification file that codifies the grammar of a language and generates a parsing routine CS315 Programming Languages © Pinar Duygulu 3 Yacc • Yacc specification describes a Context Free Grammar (CFG), that can be used to generate a parser. Elements of a CFG: 1. Terminals: tokens and literal characters, 2. Variables (nonterminals): syntactical elements, 3. Production rules, and 4. Start rule. CS315 Programming Languages © Pinar Duygulu 4 Yacc Format of a production rule: symbol: definition {action} ; Example: A → Bc is written in yacc as a: b 'c'; CS315 Programming Languages © Pinar Duygulu 5 Yacc Format of a yacc specification file: declarations %% grammar rules and associated actions %% C programs CS315 Programming Languages © Pinar Duygulu 6 Declarations To define tokens and their characteristics %token: declare names of tokens %left: define left-associative operators %right: define right-associative operators %nonassoc: define operators that may not associate with themselves %type: declare the type of variables %union: declare multiple data types for semantic values %start: declare the start symbol (default is the first variable in rules) %prec: assign precedence to a rule %{ C declarations directly copied to the resulting C program %} (E.g., variables, types, macros…) CS315 Programming Languages © Pinar Duygulu 7 A simple yacc specification to accept L={ anbn | n>1}.
    [Show full text]
  • Binpac: a Yacc for Writing Application Protocol Parsers
    binpac: A yacc for Writing Application Protocol Parsers Ruoming Pang∗ Vern Paxson Google, Inc. International Computer Science Institute and New York, NY, USA Lawrence Berkeley National Laboratory [email protected] Berkeley, CA, USA [email protected] Robin Sommer Larry Peterson International Computer Science Institute Princeton University Berkeley, CA, USA Princeton, NJ, USA [email protected] [email protected] ABSTRACT Similarly, studies of Email traffic [21, 46], peer-to-peer applica- A key step in the semantic analysis of network traffic is to parse the tions [37], online gaming, and Internet attacks [29] require under- traffic stream according to the high-level protocols it contains. This standing application-level traffic semantics. However, it is tedious, process transforms raw bytes into structured, typed, and semanti- error-prone, and sometimes prohibitively time-consuming to build cally meaningful data fields that provide a high-level representation application-level analysis tools from scratch, due to the complexity of the traffic. However, constructing protocol parsers by hand is a of dealing with low-level traffic data. tedious and error-prone affair due to the complexity and sheer num- We can significantly simplify the process if we can leverage a ber of application protocols. common platform for various kinds of application-level traffic anal- This paper presents binpac, a declarative language and com- ysis. A key element of such a platform is application-protocol piler designed to simplify the task of constructing robust and effi- parsers that translate packet streams into high-level representations cient semantic analyzers for complex network protocols. We dis- of the traffic, on top of which we can then use measurement scripts cuss the design of the binpac language and a range of issues that manipulate semantically meaningful data elements such as in generating efficient parsers from high-level specifications.
    [Show full text]
  • An Attribute- Grammar Compiling System Based on Yacc, Lex, and C Kurt M
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Digital Repository @ Iowa State University Computer Science Technical Reports Computer Science 12-1992 Design, Implementation, Use, and Evaluation of Ox: An Attribute- Grammar Compiling System based on Yacc, Lex, and C Kurt M. Bischoff Iowa State University Follow this and additional works at: http://lib.dr.iastate.edu/cs_techreports Part of the Programming Languages and Compilers Commons Recommended Citation Bischoff, Kurt M., "Design, Implementation, Use, and Evaluation of Ox: An Attribute- Grammar Compiling System based on Yacc, Lex, and C" (1992). Computer Science Technical Reports. 23. http://lib.dr.iastate.edu/cs_techreports/23 This Article is brought to you for free and open access by the Computer Science at Iowa State University Digital Repository. It has been accepted for inclusion in Computer Science Technical Reports by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. Design, Implementation, Use, and Evaluation of Ox: An Attribute- Grammar Compiling System based on Yacc, Lex, and C Abstract Ox generalizes the function of Yacc in the way that attribute grammars generalize context-free grammars. Ordinary Yacc and Lex specifications may be augmented with definitions of synthesized and inherited attributes written in C syntax. From these specifications, Ox generates a program that builds and decorates attributed parse trees. Ox accepts a most general class of attribute grammars. The user may specify postdecoration traversals for easy ordering of side effects such as code generation. Ox handles the tedious and error-prone details of writing code for parse-tree management, so its use eases problems of security and maintainability associated with that aspect of translator development.
    [Show full text]
  • Lex and Yacc
    Lex and Yacc A Quick Tour HW8–Use Lex/Yacc to Turn this: Into this: <P> Here's a list: Here's a list: * This is item one of a list <UL> * This is item two. Lists should be <LI> This is item one of a list indented four spaces, with each item <LI>This is item two. Lists should be marked by a "*" two spaces left of indented four spaces, with each item four-space margin. Lists may contain marked by a "*" two spaces left of four- nested lists, like this: space margin. Lists may contain * Hi, I'm item one of an inner list. nested lists, like this:<UL><LI> Hi, I'm * Me two. item one of an inner list. <LI>Me two. * Item 3, inner. <LI> Item 3, inner. </UL><LI> Item 3, * Item 3, outer list. outer list.</UL> This is outside both lists; should be back This is outside both lists; should be to no indent. back to no indent. <P><P> Final suggestions: Final suggestions 2 if myVar == 6.02e23**2 then f( .. ! char stream LEX token stream if myVar == 6.02e23**2 then f( ! tokenstream YACC parse tree if-stmt == fun call var ** Arg 1 Arg 2 float-lit int-lit . ! 3 Lex / Yacc History Origin – early 1970’s at Bell Labs Many versions & many similar tools Lex, flex, jflex, posix, … Yacc, bison, byacc, CUP, posix, … Targets C, C++, C#, Python, Ruby, ML, … We’ll use jflex & byacc/j, targeting java (but for simplicity, I usually just say lex/yacc) 4 Uses “Front end” of many real compilers E.g., gcc “Little languages”: Many special purpose utilities evolve some clumsy, ad hoc, syntax Often easier, simpler, cleaner and more flexible to use lex/yacc or similar tools from the start 5 Lex: A Lexical Analyzer Generator Input: Regular exprs defining "tokens" my.flex Fragments of declarations & code Output: jflex A java program “yylex.java” Use: yylex.java Compile & link with your main() Calls to yylex() read chars & return successive tokens.
    [Show full text]
  • Time-Sharing System
    UNIXTM TIME-SHARING SYSTEM: UNIX PROGRAMMER'S MANUAL Seventh Edition, Volume 2B January, 1979 Bell Telephone Laboratories, Incorporated Murray Hill, New Jersey Yacc: Yet Another Compiler-Compiler Stephen C. Johnson Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT Computer program input generally has some structure; in fact, every computer program that does input can be thought of as de®ning an ``input language'' which it accepts. An input language may be as complex as a programming language, or as sim- ple as a sequence of numbers. Unfortunately, usual input facilities are limited, dif®cult to use, and often are lax about checking their inputs for validity. Yacc provides a general tool for describing the input to a computer program. The Yacc user speci®es the structures of his input, together with code to be invoked as each such structure is recognized. Yacc turns such a speci®cation into a subroutine that handles the input process; frequently, it is convenient and appropriate to have most of the ¯ow of control in the user's application handled by this subroutine. The input subroutine produced by Yacc calls a user-supplied routine to return the next basic input item. Thus, the user can specify his input in terms of individual input characters, or in terms of higher level constructs such as names and numbers. The user-supplied routine may also handle idiomatic features such as comment and con- tinuation conventions, which typically defy easy grammatical speci®cation. Yacc is written in portable C. The class of speci®cations accepted is a very gen- eral one: LALR(1) grammars with disambiguating rules.
    [Show full text]
  • Unix Programmer's Manual
    There is no warranty of merchantability nor any warranty of fitness for a particu!ar purpose nor any other warranty, either expressed or imp!ied, a’s to the accuracy of the enclosed m~=:crials or a~ Io ~helr ,~.ui~::~::.j!it’/ for ~ny p~rficu~ar pur~.~o~e. ~".-~--, ....-.re: " n~ I T~ ~hone Laaorator es 8ssumg$ no rO, p::::nS,-,,.:~:y ~or their use by the recipient. Furln=,, [: ’ La:::.c:,:e?o:,os ~:’urnes no ob~ja~tjon ~o furnish 6ny a~o,~,,..n~e at ~ny k:nd v,,hetsoever, or to furnish any additional jnformstjcn or documenta’tjon. UNIX PROGRAMMER’S MANUAL F~ifth ~ K. Thompson D. M. Ritchie June, 1974 Copyright:.©d972, 1973, 1974 Bell Telephone:Laboratories, Incorporated Copyright © 1972, 1973, 1974 Bell Telephone Laboratories, Incorporated This manual was set by a Graphic Systems photo- typesetter driven by the troff formatting program operating under the UNIX system. The text of the manual was prepared using the ed text editor. PREFACE to the Fifth Edition . The number of UNIX installations is now above 50, and many more are expected. None of these has exactly the same complement of hardware or software. Therefore, at any particular installa- tion, it is quite possible that this manual will give inappropriate information. The authors are grateful to L. L. Cherry, L. A. Dimino, R. C. Haight, S. C. Johnson, B. W. Ker- nighan, M. E. Lesk, and E. N. Pinson for their contributions to the system software, and to L. E. McMahon for software and for his contributions to this manual.
    [Show full text]
  • Fine-Grained and Accurate Source Code Differencing Jean-Rémy Falleri, Floréal Morandat, Xavier Blanc, Matias Martinez, Martin Monperrus
    Fine-grained and Accurate Source Code Differencing Jean-Rémy Falleri, Floréal Morandat, Xavier Blanc, Matias Martinez, Martin Monperrus To cite this version: Jean-Rémy Falleri, Floréal Morandat, Xavier Blanc, Matias Martinez, Martin Monperrus. Fine- grained and Accurate Source Code Differencing. Proceedings of the International Conference on Automated Software Engineering, 2014, Västeras, Sweden. pp.313-324, 10.1145/2642937.2642982. hal-01054552 HAL Id: hal-01054552 https://hal.archives-ouvertes.fr/hal-01054552 Submitted on 12 Sep 2014 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Fine-grained and Accurate Source Code Differencing Jean-Rémy Falleri Floréal Morandat Xavier Blanc Univ. Bordeaux, Univ. Bordeaux, Univ. Bordeaux, LaBRI, UMR 5800 LaBRI, UMR 5800 LaBRI, UMR 5800 F-33400, Talence, France F-33400, Talence, France F-33400, Talence, France [email protected] [email protected] [email protected] Matias Martinez Martin Monperrus INRIA and University of Lille, INRIA and University of Lille, France France [email protected] [email protected] ABSTRACT are computed between two versions of a same file. The goal At the heart of software evolution is a sequence of edit actions, of an edit script is to accurately reflect the actual change called an edit script, made to a source code file.
    [Show full text]