A PROGRAM TO COUNT OPERATORS AND OPERANDS FOR ANSI-FORTRAN MODULES. Computer Sciences Department Purdue University West Lafayette, Indiana 47907

Similar documents
Computer Science 281 Binary and Hexadecimal Review

PROBLEMS (Cap. 4 - Istruzioni macchina)

ON THE LIMITS OF TEXT FILE COMPRESSION. V. y. SHEN and M. H. HALSTEAD. Computer Sciences Department Purdue University w. Lafayette, IN 47907

EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

LC-3 Assembly Language

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

2) Write in detail the issues in the design of code generator.

1 Classical Universal Computer 3

Chapter 7 Assembly Language

Instruction Set Architecture (ISA)

Object Oriented Software Design

Semantic Analysis: Types and Type Checking

Informatica e Sistemi in Tempo Reale

The previous chapter provided a definition of the semantics of a programming

Object Oriented Software Design

A Programming Language for Mechanical Translation Victor H. Yngve, Massachusetts Institute of Technology, Cambridge, Massachusetts

Chapter 2: Elements of Java

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Chapter One Introduction to Programming

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Compiler Construction

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Programming Languages CIS 443

Moving from CS 61A Scheme to CS 61B Java

Introduction. What is an Operating System?

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Lumousoft Visual Programming Language and its IDE

MACHINE INSTRUCTIONS AND PROGRAMS

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

VB.NET Programming Fundamentals

Introduction to Python

Programming Languages

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Embedded C Programming, Linux, and Vxworks. Synopsis

Lecture 9. Semantic Analysis Scoping and Symbol Table

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

2014 HSC Software Design and Development Marking Guidelines

Computational Mathematics with Python

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

General Software Development Standards and Guidelines Version 3.5

MASSACHUSETTS INSTITUTE OF TECHNOLOGY PROJECT MAC. Memorandum-M-352 July 21, 1967 ABSTRACT

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

High level code and machine code

CHAPTER 7: The CPU and Memory

MACHINE ARCHITECTURE & LANGUAGE

QA Analysis of the WRF Program

Computational Mathematics with Python

Introduction to Embedded Systems. Software Update Problem

So far we have considered only numeric processing, i.e. processing of numeric data represented

Solution for Homework 2

PART B QUESTIONS AND ANSWERS UNIT I

13 File Output and Input

Big Data Technology Map-Reduce Motivation: Indexing in Search Engines

Section of DBMS Selection & Evaluation Questionnaire

SOME EXCEL FORMULAS AND FUNCTIONS

COMPUTER SCIENCE TRIPOS

Chapter 6: Programming Languages

Compiler Construction

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Introduction to Java

New Tools Using the Hardware Pertbrmaiihe... Monitor to Help Users Tune Programs on the Cray X-MP*

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Problem Solving Basics and Computer Programming

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

MATLAB Programming. Problem 1: Sequential

BASIC COMPUTER ORGANIZATION AND DESIGN

Module 2 Stacks and Queues: Abstract Data Types

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Time Clock Import Setup & Use

Z80 Instruction Set. Z80 Assembly Language

Computer Programming Tutorial

6.080/6.089 GITCS Feb 12, Lecture 3

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT,

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

Arithmetic Coding: Introduction

Symbol Tables. Introduction

Decision Logic: if, if else, switch, Boolean conditions and variables

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

C Compiler Targeting the Java Virtual Machine

CSCI 3136 Principles of Programming Languages

CPU Organization and Assembly Language

Python Loops and String Manipulation

Top 72 Perl Interview Questions and Answers

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

SOFTENG250FC: Introduction to Software Engineering

1 Description of The Simpletron

Computational Mathematics with Python

Lab Experience 17. Programming Language Translation

Data Integrator. Pervasive Software, Inc B Riata Trace Parkway Austin, Texas USA

PIC Programming in Assembly. (

Sources: On the Web: Slides will be available on:

Transcription:

A PROGRAM TO COUNT OPERATORS AND OPERANDS FOR ANSI-FORTRAN MODULES Karl J. Ottenstein Computer Sciences Department Purdue University West Lafayette, Indiana 47907 CSD-TR 196 June 1976 This paper describes a program which scans an arbitrary number of ANSI-FORTRAN modules, counting the basic software science parameters [Halstead 1972] for each module. There is no syntax checking code in the analyzer since conformance to the ANSI standard is easily verified by existing compilers. It is essential, therefore, that all input follow the standard for accurate results. Most of the analyzer itself is written in ANSI-FORTRAN, allowing not only portability, but also the ability to run the program on itself as a test procedure. Only the following statements effect the counts of operands and operators: - assignment - ASSIGN - CALL - DO - GO TO - IF Most counts are accumulated as described by [Bulut 1974a]: - All arithmetic, boolean, and replacement operators are counted. - Function (subroutine) names are operators. - Each GO TO to a unique label is a unique operator.

- 2 - - The ASSIGN statement is counted as an assignment. - IF ia an operator. - Statement labels in GO T0()M,L2,L3 are counted as GO TO L1, GO TO L2, GO TO L3. - Bracketing ia an operator occurring as parenthetical grouping or a (DO,DO-foot) pair. - Subscripting as indicated by parentheses is counted as such. - All commas are operators. - The implied EOS (end of statement) operator is counted. The foil owing differences (additions) are present: - Parameters are treated as variables. - No attempts are made at correcting impurities in the programs [Bulut 1974^]. Bulut had resolved local variable ambiguity and had detected certain common subexpressions related to array addressing. - Each computed (assigned) GO TO counts as a unique "special" GO TO since there is a unique (implied) jump into a jump table. - All constants are mapped into real numbers. The integers are handled trivially. The boolean constants.true, and.false, are mapped to 1.0 and 0.0 respectively. Hollerith constants are ignored since they are only permitted in DATA statements. - Statement functions are ignored. Input Format Input to the analyzer consists of any number of ANSI- FORTRAN modules terminated by a card with an asterisk (*) in column one. Transporting the Analyzer Bringing up the analyzer on a new machine requires two things if that machine is not a 60-bit CDC machine:

- 3 - - changing certain global parameters, - rewriting certain machine dependent routines. The analyzer consists of the following ANSI modules: ANALYZE - driver CONSCH - searches the constant table for a given value DIMCHK - scans dimensioning statements, recording array sizes EXPR - scans and counts an expression GOTO - searches goto-table for a given label INITM - initializes for a new module INITP - initializes program NULINE - increments lines-per-page count and pages on overflow NUSTMT - reads and packs one FORTRAN statement PAGE - performs page ejection and titling PARSE - determines statement type, counting everything except expressions PMATCH - searches input for a matching right parenthesis PRSTAT - prints out statistics at the end of a module REALNO - scans a number and returns its real value SCAN - scans one token from the input stream SKIP - skips blanks in source statement SUMARY - prints a summary of the statistics for each module in the run (provided that more than one module was scanned). The constants that require changing are in INITP: - PDEPTH, page depth (in lines) - SYSIN, logical input unit number - SYSOUT, logical output unit number - SYSSUM, logical unit number for a scratch summary file. The non-ansi modules that may require rewriting are: CODE - converts a character to an integer on the range 0 to 63 according to the CDC interna 1 representation (display code) DIGIT - returns true if its input is the character code for a digit LETDIG - returns true if its input is the character code for a letter or a digit LETTER - returns true if its input is the character code for a letter LOOKUP - searches the hash table for a given symbol NUMCVT - converts a numeric character string to its integer representation WRTNAM - writes the name of a symbol from the hash table and its frequency of occurrence.

- 4 - Implementation Note3 Much of the slowness and awkwardness of the program is caused by the conformance to the ANSI-standard (specifically, the one character per word restriction). A P- register trace showed that most execution time was spent doing I/O and removing blanks from the input statements. If efficiency is not satisfactory, the loop in NUSTMT which handles blank removal might be coded in machine language. lg both the table name and the variable indicating its size. The size variables are set in INITP and should be changed to reflect any new dimensioning in the common blocks. if Lc

- 5 - REFERENCES [Bulut 1974a] Bulut, Nedet, Halstead, M. H., and Bayer, Rudolf, Experimental validation of a structural property of FORTRAN algorithms. CSD TR 115- Purdue University (April 1974). [Bulut 1974b] Bulut, Neodet, and Halstead, Maurice H. Impurities found in algorithm implementations. CSD TR 111. Purdue University (1974)- [Halstead 1972] Halstead, M. H. Natural laws controlling algorithm structure? ACM SIGPLAN Notices 7,2. (February 1972) 19-26. NOTE: The program source is not included as part of this technical report any longer. It has been substantially modified since 1976. Contact the Software Metrics Research Group at Purdue for information about the current version and other counters.