Supplementary Materials

Total Page:16

File Type:pdf, Size:1020Kb

Supplementary Materials Contents 2 Programming Language Syntax C 1 2.3.5 Syntax Errors C 1 2.4 Theoretical Foundations C 13 2.4.1 Finite Automata C 13 2.4.2 Push-Down Automata C 18 2.4.3 Grammar and Language Classes C 19 2.6 Exercises C 24 2.7 Explorations C 25 3 Names, Scopes, and Bindings C 26 3.4 Implementing Scope C 26 3.4.1 Symbol Tables C 26 3.4.2 Association Lists and Central Reference Tables C 31 3.8 Separate Compilation C 36 3.8.1 Separate Compilation in C C 37 3.8.2 Packages and Automatic Header Inference C 40 3.8.3 Module Hierarchies C 41 3.10 Exercises C 42 3.11 Explorations C 44 4SemanticAnalysis C 45 4.5 Space Management for Attributes C 45 4.5.1 Bottom-Up Evaluation C 45 4.5.2 Top-Down Evaluation C 50 C ii Contents 4.8 Exercises C 57 4.9 Explorations C 59 5 Target Machine Architecture C 60 5.1 The Memory Hierarchy C 61 5.2 Data Representation C 63 5.2.1 Integer Arithmetic C 65 5.2.2 Floating-Point Arithmetic C 67 5.3 Instruction Set Architecture (ISA) C 70 5.3.1 Addressing Modes C 71 5.3.2 Conditions and Branches C 72 5.4 Architecture and Implementation C 75 5.4.1 Microprogramming C 76 5.4.2 Microprocessors C 77 5.4.3 RISC C 77 5.4.4 Multithreading and Multicore C 78 5.4.5 Two Example Architectures: The x86 and ARM C 80 5.5 Compiling for Modern Processors C 88 5.5.1 Keeping the Pipeline Full C 89 5.5.2 Register Allocation C 93 5.6 Summary and Concluding Remarks C 98 5.7 Exercises C 100 5.8 Explorations C 104 5.9 Bibliographic Notes C 105 6 Control Flow C 107 6.5.4 Generators in Icon C 107 6.7 Nondeterminacy C 110 6.9 Exercises C 116 6.10 Explorations C 118 7 Type Systems C 119 7.3.2 Generics in C++, Java, and C# C 119 7.6 Exercises C 132 Contents C iii 7.7 Explorations C 135 8 Composite Types C 136 8.1.3 Variant Records (Unions) C 136 8.5.2 Dangling References C 144 8.7 Files and Input/Output C 148 8.7.1 Interactive I/O C 148 8.7.2 File-Based I/O C 149 8.7.3 Text I/O C 151 8.9 Exercises C 160 8.10 Explorations C 162 9 Subroutines and Control Abstraction C 163 9.2.1 Displays C 163 9.2.2 Stack Case Studies: LLVM on ARM; gcc on x86 C 167 9.2.3 Register Windows C 177 9.3.2 Call by Name C 180 9.5.3 Implementation of Iterators C 183 9.5.4 Discrete Event Simulation C 187 9.8 Exercises C 191 9.9 Explorations C 193 10 Data Abstraction and Object Orientation C 194 10.6 True Multiple Inheritance C 194 10.6.1 Semantic Ambiguities C 196 10.6.2 Replicated Inheritance C 200 10.6.3 Shared Inheritance C 201 10.7.1 The Object Model of Smalltalk C 204 10.9 Exercises C 208 10.10 Explorations C 211 11 Functional Languages C 212 C iv Contents 11.7 Theoretical Foundations C 212 11.7.1 Lambda Calculus C 214 11.7.2 Control Flow C 217 11.7.3 Structures C 219 11.10 Exercises C 223 11.11 Explorations C 225 12 Logic Languages C 226 12.3 Theoretical Foundations C 226 12.3.1 Clausal Form C 227 12.3.2 Limitations C 228 12.3.3 Skolemization C 230 12.6 Exercises C 232 12.7 Explorations C 234 13 Concurrency C 235 13.5 Message Passing C 235 13.5.1 Naming Communication Partners C 235 13.5.2 Sending C 239 13.5.3 Receiving C 244 13.5.4 Remote Procedure Call C 249 13.7 Exercises C 254 13.8 Explorations C 256 14 Scripting Languages C 258 14.3.5 XSLT C 258 14.6 Exercises C 270 14.7 Explorations C 272 15 Building a Runnable Program C 273 15.2.1 GIMPLE and RTL C 273 15.7 Dynamic Linking C 279 15.7.1 Position-Independent Code C 280 15.7.2 Fully Dynamic (Lazy) Linking C 282 Contents C v 15.9 Exercises C 284 15.10 Explorations C 285 16 Run-Time Program Management C 286 16.1.2 The Common Language Infrastructure C 286 16.5 Exercises C 295 16.6 Explorations C 296 17 Code Improvement C 297 17.1 Phases of Code Improvement C 299 17.2 Peephole Optimization C 301 17.3 Redundancy Elimination in Basic Blocks C 304 17.3.1 A Running Example C 305 17.3.2 Value Numbering C 307 17.4 Global Redundancy and Data Flow Analysis C 312 17.4.1 SSA Form and Global Value Numbering C 312 17.4.2 Global Common Subexpression Elimination C 315 17.5 Loop Improvement I C 323 17.5.1 Loop Invariants C 323 17.5.2 Induction Variables C 325 17.6 Instruction Scheduling C 328 17.7 Loop Improvement II C 332 17.7.1 Loop Unrolling and Software Pipelining C 332 17.7.2 Loop Reordering C 337 17.8 Register Allocation C 344 17.9 Summary and Concluding Remarks C 348 17.10 Exercises C 349 17.11 Explorations C 353 17.12 Bibliographic Notes C 354 Programming Language2 Syntax 2.3.5 Syntax Errors EXAMPLE 2.43 The main text illustrated the problem of syntax error recovery with a simple ex- Syntax error in C (reprise) ample in C: A=B:C+D; The compiler will detect a syntax error immediately after the B, but it cannot give up at that point: it needs to keep looking for errors in the remainder of the pro- gram. To permit this, we must modify the input program, the state of the parser, or both, in a way that allows parsing to continue, hopefully without announcing a significant number of spurious cascading errors and without missing a signif- icant number of real errors. The techniques discussed below allow the compiler to search for further syntax errors. In Chapter 4 we will consider additional tech- niques that allow it to search for additional static semantic errors as well. Panic Mode Perhaps the simplest form of syntax error recovery is a technique known as panic mode. It defines a small set of “safe symbols” that delimit clean points in the input. When an error occurs, a panic mode recovery algorithm deletes input tokens until it finds a safe symbol, then backs the parser out to a context in which that symbol might appear. In the earlier example, a recursive descent parser with panic mode recovery might delete input tokens until it finds the semicolon, return from all subroutines called from within stmt,andrestartthebodyofstmt itself. Unfortunately, panic mode tends to be a bit drastic. By limiting itself to a static set of “safe” symbols at which to resume parsing, it admits the possibility of delet- ing a significant amount of input while looking for such a symbol. Worse, if some of the deleted tokens are “starter” symbols that begin large-scale constructs in the language (e.g., begin, procedure, while), we shall almost surely see spurious cascading errors when we reach the end of the construct. EXAMPLE 2.44 Consider the following fragment of code in an Algol-family language: The problem with panic mode C 1 C 2 Chapter 2 Programming Language Syntax IF a b THEN x; ELSE y; END; When it discovers the error at b in the first line, a panic-mode recovery algorithm is likely to skip forward to the semicolon, thereby missing the THEN. When the parser finds the ELSE on line 2 it will produce a spurious error message. When it finds the END on line 3 it will think it has reached the end of the enclosing struc- ture (e.g., the whole subroutine), and will probably generate additional cascading errors on subsequent lines. Panic mode tends to work acceptably only in rela- tively “unstructured” languages, such as Basic and (early) Fortran, which don’t have many “starter” symbols. Phrase-Level Recovery We can improve the quality of recovery by employing different sets of “safe” sym- bols in different contexts. Parsers that incorporate this improvement are said to implement phrase-level recovery. Whenitdiscoversanerrorinanexpression,for example, a phrase-level recovery algorithm can delete input tokens until it reaches something that is likely to follow an expression. This more local recovery is better than always backing out to the end of the current statement, because it gives us the opportunity to examine the parts of the statement that follow the erroneous expression. EXAMPLE 2.45 Niklaus Wirth, the inventor of Pascal, published an elegant implementation of Phrase-level recovery in phrase-level recovery for recursive descent parsers in 1976 [Wir76, Sec. 5.9]. The recursive descent simplest version of his algorithm depends on the FIRST and FOLLOW sets defined at the end of Section 2.3.1. If the parsing routine for nonterminal foo discovers an error at the beginning of its code, it deletes incoming tokens until it finds a member of FIRST(foo), in which case it proceeds, or a member of FOLLOW(foo), in which case it returns: procedure foo() if not (input token ∈ FIRST(foo) or EPS(foo)) report error() –– print message for the user repeat delete token() until input token ∈ (FIRST(foo) ∪ FOLLOW(foo) ∪{$$}) case input token of ...:..
Recommended publications
  • Using the Unibasic Debugger
    C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\DEBUGGER\BASBTITL.fm March 8, 2010 10:30 am Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta UniData Using the UniBasic Debugger UDT-720-UDEB-1 C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\DEBUGGER\BASBTITL.fm March 8, 2010 10:30 am Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Notices Edition Publication date: July 2008 Book number: UDT-720-UDEB-1 Product version: UniData 7.2 Copyright © Rocket Software, Inc. 1988-2008. All Rights Reserved. Trademarks The following trademarks appear in this publication: Trademark Trademark Owner Rocket Software™ Rocket Software, Inc. Dynamic Connect® Rocket Software, Inc. RedBack® Rocket Software, Inc. SystemBuilder™ Rocket Software, Inc. UniData® Rocket Software, Inc. UniVerse™ Rocket Software, Inc. U2™ Rocket Software, Inc. U2.NET™ Rocket Software, Inc. U2 Web Development Environment™ Rocket Software, Inc. wIntegrate® Rocket Software, Inc. Microsoft® .NET Microsoft Corporation Microsoft® Office Excel®, Outlook®, Word Microsoft Corporation Windows® Microsoft Corporation Windows® 7 Microsoft Corporation Windows Vista® Microsoft Corporation Java™ and all Java-based trademarks and logos Sun Microsystems, Inc. UNIX® X/Open Company Limited ii Using the UniBasic Debugger The above trademarks are property of the specified companies in the United States, other countries, or both. All other products or services mentioned in this document may be covered by the trademarks, service marks, or product names as designated by the companies who own or market them. License agreement This software and the associated documentation are proprietary and confidential to Rocket Software, Inc., are furnished under license, and may be used and copied only in accordance with the terms of such license and with the inclusion of the copyright notice.
    [Show full text]
  • IEEE Standard 754 for Binary Floating-Point Arithmetic
    Work in Progress: Lecture Notes on the Status of IEEE 754 October 1, 1997 3:36 am Lecture Notes on the Status of IEEE Standard 754 for Binary Floating-Point Arithmetic Prof. W. Kahan Elect. Eng. & Computer Science University of California Berkeley CA 94720-1776 Introduction: Twenty years ago anarchy threatened floating-point arithmetic. Over a dozen commercially significant arithmetics boasted diverse wordsizes, precisions, rounding procedures and over/underflow behaviors, and more were in the works. “Portable” software intended to reconcile that numerical diversity had become unbearably costly to develop. Thirteen years ago, when IEEE 754 became official, major microprocessor manufacturers had already adopted it despite the challenge it posed to implementors. With unprecedented altruism, hardware designers had risen to its challenge in the belief that they would ease and encourage a vast burgeoning of numerical software. They did succeed to a considerable extent. Anyway, rounding anomalies that preoccupied all of us in the 1970s afflict only CRAY X-MPs — J90s now. Now atrophy threatens features of IEEE 754 caught in a vicious circle: Those features lack support in programming languages and compilers, so those features are mishandled and/or practically unusable, so those features are little known and less in demand, and so those features lack support in programming languages and compilers. To help break that circle, those features are discussed in these notes under the following headings: Representable Numbers, Normal and Subnormal, Infinite
    [Show full text]
  • Introduction to Python
    Introduction to Python Wei Feinstein HPC User Services LSU HPC & LONI [email protected] Louisiana State University March, 2017 Introduction to Python Overview • What is Python • Python programming basics • Control structures, functions • Python modules, classes • Plotting with Python Introduction to Python What is Python? • A general-purpose programming language (1980) by Guido van Rossum • Intuitive and minimalistic coding • Dynamically typed • Automatic memory management • Interpreted not compiled Introduction to Python 3 Why Python? Advantages • Ease of programming • Minimizes the time to develop and maintain code • Modular and object-oriented • Large standard and user-contributed libraries • Large community of users Disadvantages • Interpreted and therefore slower than compiled languages • Not great for 3D graphic applications requiring intensive compuations Introduction to Python 4 Code Performance vs. Development Time Python C/C++ Assembly Introduction to Python 5 Python 2.x vs 3.x • Final Python 2.x is 2.7 (2010) • First Python 3.x is 3.0 (2008) • Major cleanup to better support Unicode data formats in Python 3.x • Python 3 not backward-compatible with Python 2 • Rich packages available for Python 2z $ python -- version Introduction to Python 6 IPython • Python: a general-purpose programming language (1980) • IPython: an interactive command shell for Python (2001) by Fernando Perez • Enhanced Read-Eval-Print Loop (REPL) environment • Command tab-completion, color-highlighted error messages.. • Basic Linux shell integration (cp, ls, rm…) • Great for plotting! http://ipython.org Introduction to Python 7 Jupyter Notebook IPython introduced a new tool Notebook (2011) • Bring modern and powerful web interface to Python • Rich text, improved graphical capabilities • Integrate many existing web libraries for data visualization • Allow to create and share documents that contain live code, equations, visualizations and explanatory text.
    [Show full text]
  • Kednos PL/I for Openvms Systems User Manual
    ) Kednos PL/I for OpenVMS Systems User Manual Order Number: AA-H951E-TM November 2003 This manual provides an overview of the PL/I programming language. It explains programming with Kednos PL/I on OpenVMS VAX Systems and OpenVMS Alpha Systems. It also describes the operation of the Kednos PL/I compilers and the features of the operating systems that are important to the PL/I programmer. Revision/Update Information: This revised manual supersedes the PL/I User’s Manual for VAX VMS, Order Number AA-H951D-TL. Operating System and Version: For Kednos PL/I for OpenVMS VAX: OpenVMS VAX Version 5.5 or higher For Kednos PL/I for OpenVMS Alpha: OpenVMS Alpha Version 6.2 or higher Software Version: Kednos PL/I Version 3.8 for OpenVMS VAX Kednos PL/I Version 4.4 for OpenVMS Alpha Published by: Kednos Corporation, Pebble Beach, CA, www.Kednos.com First Printing, August 1980 Revised, November 1983 Updated, April 1985 Revised, April 1987 Revised, January 1992 Revised, May 1992 Revised, November 1993 Revised, April 1995 Revised, October 1995 Revised, November 2003 Kednos Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description. Possession, use, or copying of the software described in this publication is authorized only pursuant to a valid written license from Kednos Corporation or an anthorized sublicensor.
    [Show full text]
  • Data General Extended Algol 60 Compiler
    DATA GENERAL EXTENDED ALGOL 60 COMPILER, Data General's Extended ALGOL is a powerful language tial I/O with optional formatting. These extensions comple­ which allows systems programmers to develop programs ment the basic structure of ALGOL and significantly in­ on mini computers that would otherwise require the use of crease the convenience of ALGOL programming without much larger, more expensive computers. No other mini making the language unwieldy. computer offers a language with the programming features and general applicability of Data General's Extended FEATURES OF DATA GENERAL'S EXTENDED ALGOL Character strings are implemented as an extended data ALGOL. type to allow easy manipulation of character data. The ALGOL 60 is the most widely used language for describ­ program may, for example, read in character strings, search ing programming algorithms. It has a flexible, generalized, for substrings, replace characters, and maintain character arithmetic organization and a modular, "building block" string tables efficiently. structure that provides clear, easily readable documentation. Multi-precision arithmetic allows up to 60 decimal digits The language is powerful and concise, allowing the systems of precision in integer or floating point calculations. programmer to state algorithms without resorting to "tricks" Device-independent I/O provides for reading and writ­ to bypass the language. ing in line mode, sequential mode, or random mode.' Free These characteristics of ALGOL are especially important form reading and writing is permitted for all data types, or in the development of working prototype systems. The output can be formatted according to a "picture" of the clear documentation makes it easy for the programmer to output line or lines.
    [Show full text]
  • Numerical Computation Guide
    Numerical Computation Guide Sun™ Studio 9 Sun Microsystems, Inc. www.sun.com Part No. 817-6702-10 July 2004, Revision A Submit comments about this document at: http://www.sun.com/hwdocs/feedback Copyright © 2004 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. This distribution may include materials developed by third parties. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and in other countries, exclusively licensed through X/Open Company, Ltd. Sun, Sun Microsystems, the Sun logo, Java, and JavaHelp are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon architecture developed by Sun Microsystems, Inc. This product is covered and controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.
    [Show full text]
  • CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 12
    CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 12: Symbol Tables February 15, 2008 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; (character stream) Lexical Analysis Token if ( b == 0 ) a = b ; stream Syntax Analysis if (Parsing) == = Abstract syntax tree (AST) b0ab if Semantic Analysis boolean int Decorated == = AST int b int 0 int a int b Errors lvalue (incorrect program) CS 412/413 Spring 2008 Introduction to Compilers 2 Non-Context-Free Syntax • Programs that are correct with respect to the language’s lexical and context-free syntactic rules may still contain other syntactic errors • Lexical analysis and context-free syntax analysis are not powerful enough to ensure the correct usage of variables, objects, functions, statements, etc. • Non-context-free syntactic analysis is known as semantic analysis CS 412/413 Spring 2008 Introduction to Compilers 3 Incorrect Programs •Example 1: lexical analysis does not distinguish between different variable or function identifiers (it returns the same token for all identifiers) int a; int a; a = 1; b = 1; •Example 2: syntax analysis does not correlate the declarations with the uses of variables in the program: int a; a = 1; a = 1; •Example3: syntax analysis does not correlate the types from the declarations with the uses of variables: int a; int a; a = 1; a = 1.0; CS 412/413 Spring 2008 Introduction to Compilers 4 Goals of Semantic Analysis • Semantic analysis ensures that the program satisfies a set of additional rules regarding the
    [Show full text]
  • Introduction to Programming CSC 103
    COURSE MANUAL Introduction to Programming CSC 103 University of Ibadan Distance Learning Centre Open and Distance Learning Course Series Development Copyright © 2016 by Distance Learning Centre, University of Ibadan, Ibadan. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior permission of the copyright owner. ISBN: 978-021-592-1 General Editor: Prof. Bayo Okunade University of Ibadan Distance Learning Centre University of Ibadan, Nigeria Telex: 31128NG Tel: +234 (80775935727) E-mail: [email protected] Website: www.dlc.ui.edu.ng Vice-Chancellor’s Message The Distance Learning Centre is building on a solid tradition of over two decades of service in the provision of External Studies Programme and now Distance Learning Education in Nigeria and beyond. The Distance Learning mode to which we are committed is providing access to many deserving Nigerians in having access to higher education especially those who by the nature of their engagement do not have the luxury of full time education. Recently, it is contributing in no small measure to providing places for teeming Nigerian youths who for one reason or the other could not get admission into the conventional universities. These course materials have been written by writers specially trained in ODL course delivery. The writers have made great efforts to provide up to date information, knowledge and skills in the different disciplines and ensure that the materials are user-friendly. In addition to provision of course materials in print and e-format, a lot of Information Technology input has also gone into the deployment of course materials.
    [Show full text]
  • Design and Implementation of the GNU Prolog System Abstract 1 Introduction
    Design and Implementation of the GNU Prolog System Daniel Diaz Philippe Codognet University of Paris 1 University of Paris 6 CRI, bureau C1407 LIP6, case 169 90, rue de Tolbiac 8, rue du Capitaine Scott 75013 Paris, FRANCE 75015 Paris, FRANCE and INRIA-Rocquencourt and INRIA-Rocquencourt [email protected] [email protected] Abstract In this paper we describe the design and the implementation of the GNU Pro- log system. This system draws on our previous experience of compiling Prolog to C in the wamcc system and of compiling finite domain constraints in the clp(FD) system. The compilation scheme has however been redesigned in or- der to overcome the drawbacks of compiling to C. In particular, GNU-Prolog is based on a low-level mini-assembly platform-independent language that makes it possible to avoid compiling C code, and thus drastically reduces compilation time. It also makes it possible to produce small stand-alone executable files as the result of the compilation process. Interestingly, GNU Prolog is now com- pliant to the ISO standard, includes several extensions (OS interface, sockets, global variables, etc) and integrates a powerful constraint solver over finite domains. The system is efficient and in terms of performance is comparable with commercial systems for both the Prolog and constraint aspects. 1 Introduction GNU Prolog is a free Prolog compiler supported by the GNU organization (http://www.gnu.org/software/prolog). It is a complete system which in- cludes: floating point numbers, streams, dynamic code, DCG, operating sys- tem interface, sockets, a Prolog debugger, a low-level WAM debugger, line editing facilities with completion on atoms, etc.
    [Show full text]
  • Interpreters Machine Interpreters
    Interpreters There are two different kinds of interpreters that support execution of programs, machine interpreters and language interpreters. Machine Interpreters A machine interpreter simulates the execution of a program compiled for a particular machine architecture. Java uses a bytecode interpreter to simulate the effects of programs compiled for the JVM. Programs like SPIM simulate the execution of a MIPS program on a non-MIPS computer. © CS 536 Spring 2006 43 Language Interpreters A language interpreter simulates the effect of executing a program without compiling it to any particular instruction set (real or virtual). Instead some IR form (perhaps an AST) is used to drive execution. Interpreters provide a number of capabilities not found in compilers: • Programs may be modified as execution proceeds. This provides a straightforward interactive debugging capability. Depending on program structure, program modifications may require reparsing or repeated semantic analysis. In Python, for example, any string variable may be interpreted as a Python expression or statement and executed. © CS 536 Spring 2006 44 • Interpreters readily support languages in which the type of a variable denotes may change dynamically (e.g., Python or Scheme). The user program is continuously reexamined as execution proceeds, so symbols need not have a fixed type. Fluid bindings are much more troublesome for compilers, since dynamic changes in the type of a symbol make direct translation into machine code difficult or impossible. • Interpreters provide better diagnostics. Source text analysis is intermixed with program execution, so especially good diagnostics are available, along with interactive debugging. • Interpreters support machine independence. All operations are performed within the interpreter.
    [Show full text]
  • Design and Implementation of the Symbol Table for Object- Oriented Programming Language
    International Journal of Database Theory and Application Vol.10, No.7 (2017), pp.27-40 http://dx.doi.org/10.14257/ijdta.2017.10.7.03 Design and Implementation of the Symbol Table for Object- Oriented Programming Language Yangsun Lee Dept. of of Computer Engineering, Seokyeong University 16-1 Jungneung-Dong, Sungbuk-Ku, Seoul 136-704, KOREA [email protected] Abstract The symbol table used in the existing compiler stores one symbol information into a plurality of sub tables, and the abstract syntax tree necessary for generating symbols has a binary tree structure composed of a single data structure node. This structure increases the source code complexity of modules that generate symbols and modules that reference symbol tables, and when designing a compiler for a new language, it is necessary to newly design an abstract syntax tree and a symbol table structure considering the characteristics of the language. In this paper, we apply the object-oriented principle and visitor pattern to improve the abstract syntax tree structure and design and implement the symbol table for the object - oriented language. The design of AST (abstract syntax trees) with object-oriented principles and Visitor patterns reduces the time and cost of redesign because it makes it easy to add features of the language without the need to redesign the AST (abstract syntax tree) for the new object-oriented language. In addition, it is easy to create a symbol through the Visitor pattern. Symbol tables using the open-close principle and the dependency inversion principle can improve the code reusability of the source code that creates and refer to the table and improve the readability of the code.
    [Show full text]
  • Floating Point Exception Tracking and NAN Propagation
    Floating point exception tracking and NAN propagation By Agner Fog. Technical University of Denmark. © 2018-2020 CC-BY. Last updated 2020-04-27. Abstract The most common methods for detecting floating point errors are based on exception trapping or a global status register. These methods are inefficient in modern systems that use out-of-order parallelism and single-instruction-multiple-data (SIMD) parallelism for improving performance. It is argued that a method based on NAN propagation is more efficient and deterministic. Problems with NAN propagation in current systems are discussed. Examples of implementation in the C++ vector class library and in an experimental instruction set named ForwardCom are presented. The IEEE-754 standard for floating point arithmetic may need adjustment to accommodate the needs of modern forms of parallelism. Contents 1 Introduction ....................................................................................................................... 1 2 Exception trapping ............................................................................................................. 2 3 Using a status register ....................................................................................................... 3 4 Using errno ........................................................................................................................ 3 5 Parallel error detection ...................................................................................................... 3 6 Propagation of INF and NAN
    [Show full text]