The Creation of a Compiler for the LITTLE Language

Total Page:16

File Type:pdf, Size:1020Kb

The Creation of a Compiler for the LITTLE Language The Creation of a Compiler for the LITTLE Language Will Cassella, Woodrow Melling, Bradley White Montana State University CSCI 468 - Compilers Spring 2017 Table of Contents Table of Contents 1 Section 1: Program 3 Program Specification 3 Source Code 4 IRGenerator 4 IRInstruction 5 Lexer 6 LexerGrammar 8 Listener 10 Operand 20 Symbol 22 SymbolTable 23 TinyEmitter 24 Section 2: Teamwork 30 Section 3: Design Pattern 31 Section 4: Technical Report 32 Introduction 32 Background 32 Methods and Discussion 34 Scanner 34 Background 34 Methods 34 Difficulties 35 Parser 35 Background 35 Methods 35 Difficulties 36 Symbol Table 36 Background 36 Methods 37 Difficulties 37 Semantic Routines 38 Background 38 1 Methods 38 Difficulties 39 Full Fledged Compiler 39 Background 39 Methods 39 Difficulties 40 Conclusion and Future Work 40 Section 5: UML 41 Section 6: Design Trade-offs 43 Section 7: Software Development Lifecycle 44 2 Section 1: Program Program Specification The following source code is a simple compiler for the LITTLE programming language. The compiler is written in Java and utilizes the ANTLR library to generate various classes based on the grammar defined within LexerGrammar. The program is invoked through the Lexer class, which takes a LITTLE source code file as a command line argument. The LITTLE code is then passed through the scanner which was generated by the ANTLR library to tokenize the source code. The stream of tokens will pass through the parser, which was also generated by ANTLR based on the predefined grammar. The parser will build a tree data structure from the given input, as well as check that the syntax is correct based on the grammar definition provided. After the tree is created, it is traversed by the Listener class, which performs symbol-table construction as well as intermediate representation (IR) generation of the code. The SymbolTable is an ordered hash map where the keys are the symbol’s name and the value is a Symbol object, and is used to track variables. The Symbol object will contain a type, name and value. Each scope within the input file will contain a unique SymbolTable and these tables are further organized within a tree data structure allowing nested scopes to have an association with their respective parent scope. The last step of the compiler is IR generation. Unlike commercial compilers, we are not performing optimization techniques on the intermediate code. The Listener will instantiate an IRGenerator which contains a stack of IRInstruction objects. The IRInstruction objects contain two instances of the Operand class, which are integer, float, or string variables, and one operation, in assembly, such as ADDI or MULTI. Furthermore, these instructions are created as the Listener traverses the syntax tree. The generated IR is independent of any machine architecture and is consumed by the TinyEmitter class which then emits assembly code for the Tiny VM architecture. Further details on these processes are provided in the technical report, section four. 3 Source Code IRGenerator import java.util.ArrayList; ​ import java.util.Stack; ​ public class IRGenerator ​ { public IRGenerator() ​ ​ { label_stack = new Stack<>(); ​ ​ ​ ​ expr_instructions = new Stack<>(); ​ ​ ​ ​ instructions = new ArrayList<>(); ​ ​ ​ ​ next_temp = 1; ​ ​ ​ ​ } public Operand allocate_temporary() ​ ​ { Operand result = Operand.temp_operand("$T" + next_temp, null); ​ ​ ​ ​ ​ ​ ​ ​ next_temp += 1; ​ ​ ​ ​ return result; ​ ​ } public IRInstruction add_instruction() ​ ​ { IRInstruction result = new IRInstruction(); ​ ​ instructions.add(result); ​ ​ return result; ​ ​ } public IRInstruction push_instruction() ​ ​ { IRInstruction top = new IRInstruction(); ​ ​ expr_instructions.push(top); ​ ​ return top; ​ ​ } public IRInstruction top_instruction() ​ ​ { if (!expr_instructions.empty()) ​ ​ ​ ​ { return expr_instructions.peek(); ​ ​ ​ } else ​ { ​ return null; ​ ​ } 4 } public IRInstruction pop() ​ ​ { if (!expr_instructions.empty()) ​ ​ ​ ​ { IRInstruction top = expr_instructions.pop(); ​ ​ instructions.add(top); ​ ​ return top; ​ ​ } else ​ { ​ return null; ​ ​ } } public void push_label(String label) ​ ​ { label_stack.push(label); ​ ​ } public String pop_label() ​ ​ { return label_stack.pop(); ​ ​ ​ } public String top_label() ​ ​ { return label_stack.peek(); ​ ​ ​ } public Stack<String> label_stack; ​ ​ ​ ​ public Stack<IRInstruction> expr_instructions; ​ ​ ​ ​ public ArrayList<IRInstruction> instructions; ​ ​ ​ ​ public int next_temp; ​ ​ ​ } IRInstruction public class IRInstruction ​ { public enum OP ​ ​ { ADDI, ​ ​ ADDF, ​ ​ SUBI, ​ ​ SUBF, ​ ​ MULTI, ​ ​ MULTF, ​ ​ DIVI, ​ ​ 5 DIVF, ​ ​ STOREI, ​ ​ STOREF, ​ ​ GT, ​ ​ GE, ​ ​ LT, ​ ​ LE, ​ ​ NE, ​ ​ EQ, ​ ​ JUMP, ​ ​ LABEL, ​ ​ READI, ​ ​ READF, ​ ​ WRITEI, ​ ​ WRITEF, ​ ​ WRITES, ​ ​ UNDETERMINED_RESERVED, ​ ​ } @Override ​ public String toString() ​ ​ { String str = op.toString(); ​ ​ if (operand_1 != null) ​ ​ ​ ​ ​ ​ { str += " " + operand_1; ​ ​ ​ ​ } if (operand_2 != null) ​ ​ ​ ​ ​ ​ { str += " " + operand_2; ​ ​ ​ ​ } return str + " " + result; ​ ​ ​ ​ ​ ​ } public OP op = null; ​ ​ ​ ​ ​ ​ public Operand operand_1 = null; ​ ​ ​ ​ ​ ​ public Operand operand_2 = null; ​ ​ ​ ​ ​ ​ public Operand result = null; ​ ​ ​ ​ ​ ​ } Lexer import org.antlr.v4.runtime.*; ​ import org.antlr.v4.runtime.tree.ParseTreeWalker; ​ import java.util.List; ​ public class Lexer ​ 6 { private static void output_ir(List<IRInstruction> instructions) ​ ​ { // Output ir preamble ​ System.out.println(";IR code"); ​ ​ ​ ​ ​ System.out.println(";LABEL main"); ​ ​ ​ ​ System.out.println(";LINK"); ​ ​ ​ ​ // Output instructions ​ for (IRInstruction instruction : instructions) ​ ​ { System.out.println(";" + instruction); ​ ​ ​ ​ } // Output post ​ System.out.println(";RET"); ​ ​ ​ ​ ​ System.out.println(";tiny code"); ​ ​ ​ ​ } public static void main(String[] args) throws Exception ​ ​ ​ ​ { try ​ { ​ // Read in the micro file from the command line arguments ​ org.antlr.v4.runtime.ANTLRFileStream fileStream = new ​ ​ org.antlr.v4.runtime.ANTLRFileStream(args[0]); ​ ​ // Create a new lexer on the specified 'CharStream' ​ lexerGrammarLexer lexer = new lexerGrammarLexer(fileStream); ​ ​ ​ CommonTokenStream tokens = new CommonTokenStream(lexer); ​ ​ //Vocabulary vocab = lexer.getVocabulary(); ​ // Create a parser from the stream of tokens lexerGrammarParser parser = new lexerGrammarParser(tokens); ​ ​ ​ // Remove the error listener to not interfere with the output stream ​ parser.removeErrorListeners(); ​ // Parse from the beginning of the rules ​ ParseTreeWalker walker = new ParseTreeWalker(); ​ ​ ​ Listener listener = new Listener(); ​ ​ walker.walk(listener, parser.program()); output_ir(listener.ir_generator.instructions); ​ ​ ​ ​ ​ ​ TinyEmitter emitter = new TinyEmitter(); ​ ​ String result = emitter.emit_code(listener.current_scope, ​ ​ listener.ir_generator.instructions); ​ ​ ​ ​ System.out.println(result); ​ ​ } catch (IllegalArgumentException e) { ​ ​ System.out.println(e.getMessage()); ​ ​ 7 } } } LexerGrammar grammar lexerGrammar; ​ ​ /* Program **/ program : 'PROGRAM' id 'BEGIN' pgm_body 'END'; ​ ​ ​ ​ ​ ​ ​ id : IDENTIFIER; ​ ​ ​ pgm_body : decl func_declarations; ​ ​ ​ decl : string_decl decl | var_decl decl | ; ​ ​ ​ ​ ​ /* Global String Declaration */ string_decl : 'STRING' id ':=' str ';' ; ​ ​ ​ ​ ​ ​ ​ str : STRINGLITERAL; ​ ​ ​ /* Variable Declaration */ var_decl : var_type id_list ';' ; ​ ​ ​ ​ var_type : 'FLOAT' | 'INT'; ​ ​ ​ ​ ​ any_type : var_type | 'VOID'; ​ ​ ​ ​ ​ id_list : id id_tail; ​ ​ ​ id_tail : ',' id id_tail | ; ​ ​ ​ ​ /* Function Paramater List */ param_decl_list : '(' param_decl param_decl_tail ')' | '(' ')' | ; ​ ​ ​ ​ ​ ​ ​ param_decl : var_type id; ​ ​ ​ param_decl_tail : ',' param_decl param_decl_tail | ; ​ ​ ​ ​ /* Function Declarations */ func_declarations : func_decl func_declarations | ; ​ ​ ​ func_decl : 'FUNCTION' any_type id param_decl_list 'BEGIN' func_body 'END'; ​ ​ ​ ​ ​ ​ ​ func_body : decl stmt_list; ​ ​ ​ /* Statement List */ stmt_list : stmt stmt_list | ; ​ ​ ​ stmt : base_stmt | if_stmt | while_stmt; ​ ​ ​ ​ ​ ​ ​ base_stmt : assign_stmt | read_stmt | write_stmt | return_stmt; ​ ​ ​ ​ ​ ​ ​ ​ ​ /* Basic Statements */ assign_stmt : assign_expr ';' ; ​ ​ ​ ​ assign_expr : id ':=' expr; ​ ​ ​ ​ ​ read_stmt : 'READ' '(' id_list ')' ';' ; ​ ​ ​ ​ ​ write_stmt : 'WRITE' '(' id_list ')' ';' ; ​ ​ ​ ​ ​ return_stmt : 'RETURN' expr ';' ; ​ ​ ​ ​ ​ /* Expressions */ expr : expr_prefix factor; ​ ​ ​ 8 expr_prefix : expr_prefix factor addop | ; ​ ​ ​ factor : factor_prefix postfix_expr; ​ ​ ​ factor_prefix : factor_prefix postfix_expr mulop | ; ​ ​ ​ postfix_expr : primary | call_expr; ​ ​ ​ ​ ​ call_expr : id '(' expr_list ')'; ​ ​ ​ ​ ​ ​ expr_list : expr expr_list_tail | ; ​ ​ ​ expr_list_tail : ',' expr expr_list_tail | ; ​ ​ ​ ​ primary : '(' expr ')' | id | INTLITERAL | FLOATLITERAL; ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ addop : '+' | '-'; ​ ​ ​ ​ ​ mulop : '*' | '/'; ​ ​ ​ ​ ​ /* Complex Statements and Condition */ if_stmt : 'IF' '(' cond ')' decl stmt_list else_part 'ENDIF'; ​ ​ ​ ​ ​ ​ ​ else_part : 'ELSE' decl stmt_list | ; ​ ​ ​ ​ cond : expr compop expr; ​ ​ ​ compop : '<' | '>' | '=' | '!=' | '<=' | '>='; ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ /* While statements */ while_stmt : 'WHILE' '(' cond ')' decl stmt_list 'ENDWHILE'; ​ ​ ​ ​ ​ ​ ​ start: .*? EOF; ​ ​ ​ WS: (' ' | '\t' | '\r' | '\n' ) -> skip; ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ INTLITERAL: [0-9]+; ​ FLOATLITERAL: [0-9]*'.'[0-9]+ ; ​ ​ ​ STRINGLITERAL: '"'.*?'"'; ​ ​ ​ ​ ​ COMMENT: '--'.*?'\n' -> skip; ​ ​ ​ ​ ​ ​ ​ KEYWORD:
Recommended publications
  • Cognitive Programming Language (CPL) Programmer's Guide
    Cognitive Programming Language (CPL) Programmer's Guide 105-008-02 Revision C2 – 3/17/2006 *105-008-02* Copyright © 2006, Cognitive. Cognitive™, Cxi™, and Ci™ are trademarks of Cognitive. Microsoft® and Windows™ are trademarks of Microsoft Corporation. Other product and corporate names used in this document may be trademarks or registered trademarks of other companies, and are used only for explanation and to their owner’s benefit, without intent to infringe. All information in this document is subject to change without notice, and does not represent a commitment on the part of Cognitive. No part of this document may be reproduced for any reason or in any form, including electronic storage and retrieval, without the express permission of Cognitive. All program listings in this document are copyrighted and are the property of Cognitive and are provided without warranty. To contact Cognitive: Cognitive Solutions, Inc. 4403 Table Mountain Drive Suite A Golden, CO 80403 E-Mail: [email protected] Telephone: +1.800.525.2785 Fax: +1.303.273.1414 Table of Contents Introduction.............................................................................................. 1 Label Format Organization .................................................................. 2 Command Syntax................................................................................ 2 Important Programming Rules............................................................. 3 Related Publications...........................................................................
    [Show full text]
  • A Compiler for a Simple Language. V0.16
    Project step 1 – a compiler for a simple language. v0.16 Change log: v0.16, changes from 0.15 Make all push types in compiler actions explicit. Simplified and better documentation of call and callr instruction compiler actions. Let the print statement print characters and numbers. Added a printv statement to print variables. Changed compiler actions for retr to push a variable value, not a literal value. Changes are shown in orange. v0.15, changes from 0.14 Change compiler actions for ret, retr, jmp. Change the description and compiler actions for poke. Change the description for swp. Change the compiler actions for call and callr. Changes shown in green. v0.14, changes from 0.13 Add peek, poke and swp instructions. Change popm compiler actions. Change callr compiler actions. Other small changes to wording. Changes are shown in blue. v0.13, changes from 0.12 Add a count field to subr, call and callr to simplify code generation. Changes are shown in red. v0.12 Changes from 0.11. Added a callr statement that takes a return type. Fix the generated code for this and for call to allow arguments to be pushed by the call. Add a retr that returns a value and update the reg. v0.11: changes from 0.10. Put typing into push operators. Put opcodes for compare operators. fix actions for call. Make declarations reserve a stack location. Remove redundant store instruction (popv does the same thing.) v0.10: changes from 0.0. Comparison operators (cmpe, cmplt, cmpgt) added. jump conditional (jmpc) added. bytecode values added.
    [Show full text]
  • Programming Basics - FORTRAN 77
    CWCS Workshop May 2005 Programming Basics - FORTRAN 77 http://www.physics.nau.edu/~bowman/PHY520/F77tutor/tutorial_77.html Program Organization A FORTRAN program is just a sequence of lines of plain text. This is called the source code. The text has to follow certain rules (syntax) to be a valid FORTRAN program. We start by looking at a simple example: program circle real r, area, pi c This program reads a real number r and prints c the area of a circle with radius r. write (*,*) 'Give radius r:' read (*,*) r pi = atan(1.0e0)*4.0e0 area = pi*r*r write (*,*) 'Area = ', area end A FORTRAN program generally consists of a main program and possibly several subprograms (i.e., functions or subroutines). The structure of a main program is: program name declarations statements end Note: Words that are in italics should not be taken as literal text, but rather as a description of what belongs in their place. FORTRAN is not case-sensitive, so "X" and "x" are the same variable. Blank spaces are ignored in Fortran 77. If you remove all blanks in a Fortran 77 program, the program is still acceptable to a compiler but almost unreadable to humans. Column position rules Fortran 77 is not a free-format language, but has a very strict set of rules for how the source code should be formatted. The most important rules are the column position rules: Col. 1: Blank, or a "c" or "*" for comments Col. 1-5: Blank or statement label Col. 6: Blank or a "+" for continuation of previous line Col.
    [Show full text]
  • 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]
  • Fortran 90 Programmer's Reference
    Fortran 90 Programmer’s Reference First Edition Product Number: B3909DB Fortran 90 Compiler for HP-UX Document Number: B3908-90002 October 1998 Edition: First Document Number: B3908-90002 Remarks: Released October 1998. Initial release. Notice Copyright Hewlett-Packard Company 1998. All Rights Reserved. Reproduction, adaptation, or translation without prior written permission is prohibited, except as allowed under the copyright laws. The information contained in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance or use of this material. Contents Preface . xix New in HP Fortran 90 V2.0. .xx Scope. xxi Notational conventions . xxii Command syntax . xxiii Associated documents . xxiv 1 Introduction to HP Fortran 90 . 1 HP Fortran 90 features . .2 Source format . .2 Data types . .2 Pointers . .3 Arrays . .3 Control constructs . .3 Operators . .4 Procedures. .4 Modules . .5 I/O features . .5 Intrinsics . .6 2 Language elements . 7 Character set . .8 Lexical tokens . .9 Names. .9 Program structure . .10 Statement labels . .10 Statements . .11 Source format of program file . .13 Free source form . .13 Source lines . .14 Statement labels . .14 Spaces . .14 Comments . .15 Statement continuation . .15 Fixed source form . .16 Spaces . .16 Source lines . .16 Table of Contents i INCLUDE line . 19 3 Data types and data objects . 21 Intrinsic data types . 22 Type declaration for intrinsic types .
    [Show full text]
  • Control Flow Graphs • Can Be Done at High Level Or Low Level – E.G., Constant Folding
    Optimizations • Code transformations to improve program – Mainly: improve execution time – Also: reduce program size Control Flow Graphs • Can be done at high level or low level – E.g., constant folding • Optimizations must be safe – Execution of transformed code must yield same results as the original code for all possible executions 1 2 Optimization Safety Optimization Safety • Safety of code transformations usually requires certain • Safety of code transformations usually requires certain information that may not be explicit in the code information which may not explicit in the code • Example: dead code elimination • Example: dead code elimination (1) x = y + 1; (1) x = y + 1; (2) y = 2 * z; (2) y = 2 * z; (3) x=y+z;x = y + z; (3) x=y+z;x = y + z; (4) z = 1; (4) z = 1; (5) z = x; (5) z = x; • What statements are dead and can be removed? • Need to know whether values assigned to x at (1) is never used later (i.e., x is dead at statement (1)) – Obvious for this simple example (with no control flow) – Not obvious for complex flow of control 3 4 1 Dead Variable Example Dead Variable Example • Add control flow to example: • Add control flow to example: x = y + 1; x = y + 1; y = 2 * z; y = 2 * z; if (d) x = y+z; if (d) x = y+z; z = 1; z = 1; z = x; z = x; • Statement x = y+1 is not dead code! • Is ‘x = y+1’ dead code? Is ‘z = 1’ dead code? •On some executions, value is used later 5 6 Dead Variable Example Dead Variable Example • Add more control flow: • Add more control flow: while (c) { while (c) { x = y + 1; x = y + 1; y = 2 * z; y = 2
    [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]
  • FORTRAN 77 Language Reference
    FORTRAN 77 Language Reference FORTRAN 77 Version 5.0 901 San Antonio Road Palo Alto, , CA 94303-4900 USA 650 960-1300 fax 650 969-9131 Part No: 805-4939 Revision A, February 1999 Copyright Copyright 1999 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303-4900 U.S.A. All rights reserved. All rights reserved. This product or document is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or document may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Portions of this product may be derived from the UNIX® system, licensed from Novell, Inc., and from the Berkeley 4.3 BSD system, licensed from the University of California. UNIX is a registered trademark in the United States and in other countries and is exclusively licensed by X/Open Company Ltd. Third-party software, including font technology in this product, is protected by copyright and licensed from Sun’s suppliers. RESTRICTED RIGHTS: Use, duplication, or disclosure by the U.S. Government is subject to restrictions of FAR 52.227-14(g)(2)(6/87) and FAR 52.227-19(6/87), or DFAR 252.227-7015(b)(6/95) and DFAR 227.7202-3(a). Sun, Sun Microsystems, the Sun logo, SunDocs, SunExpress, Solaris, Sun Performance Library, Sun Performance WorkShop, Sun Visual WorkShop, Sun WorkShop, and Sun WorkShop Professional are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries.
    [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]
  • 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
    [Show full text]
  • Dynamic Security Labels and Noninterference
    Dynamic Security Labels and Noninterference Lantian Zheng Andrew C. Myers Computer Science Department Cornell University {zlt,andru}@cs.cornell.edu Abstract This paper explores information flow control in systems in which the security classes of data can vary dynamically. Information flow policies provide the means to express strong security requirements for data confidentiality and integrity. Recent work on security-typed programming languages has shown that information flow can be analyzed statically, ensuring that programs will respect the restrictions placed on data. However, real computing systems have security policies that vary dynamically and that cannot be determined at the time of program analysis. For example, a file has associated access permissions that cannot be known with certainty until it is opened. Although one security-typed programming lan- guage has included support for dynamic security labels, there has been no examination of whether such a mechanism can securely control information flow. In this paper, we present an expressive language- based mechanism for securely manipulating dynamic security labels. The mechanism is presented both in the context of a Java-like programming language and, more formally, in a core language based on the typed lambda calculus. This core language is expressive enough to encode previous dynamic label mechanisms; as importantly, any well-typed program is provably secure because it satisfies noninterfer- ence. 1 Introduction Information flow control protects information security by constraining how information is transmitted among objects and users of various security classes. These security classes are expressed as labels associated with the information or its containers. Dynamic labels, labels that can be manipulated and checked at run time, are vital for modeling real systems in which security policies may be changed dynamically.
    [Show full text]
  • X86 Assembly Language Reference Manual
    x86 Assembly Language Reference Manual Part No: 817–5477–11 March 2010 Copyright ©2010 Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related software documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are “commercial computer software” or “commercial technical data” pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms setforth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065.
    [Show full text]