The use of symbol-state tables

Size: px
Start display at page:

Download "The use of symbol-state tables"

Transcription

1 The use of symbol-state tables A. C. Day Computer Centre, University College London, Gordon Street, London WC This paper describes how a certain kind of table may be used to check the syntax of a string of symbols. In its simplest form, a symbol-state table closely resembles afinitestate machine, and requires a large amount of space, often to store duplicated information. By means of the subroutine principle such duplication may be avoided, and recursive use of the table achieved, making possible the checking of recursive structures. When syntax checking is not the only aim, or when checking needs to be performed which is beyond the scope of the table, sections of program coding may be called from the table. Applications have included the writing in FORTRAN of a syntax checker for FORTRAN, and the automatic proof reading of dictionary entries. Received January Arrays are often found to be useful as an alternative way of storing programming information, rather than coding a great many conditional instructions. An example of this is the use of decision tables, in which the fulfilment of a set of conditions leads to the execution of a set of operations, the conditions and the operations being specified by the table. Another example is that of transition matrices, as used in compiler writing. Usually in this case the next symbol in the input stream and the symbol at the top of a stack are used to denote the row and column of the matrix. Their intersection gives the place in the matrix at which is stored the address of a subroutine to handle the incoming symbol. This is shown diagrammatically in Fig.. The tables described in this paper are also used to store supplementary programming information, and are useful stack symbol Input symbol aids when any kind of syntax checking needs to be performed. In a symbol-state table the next symbol in the input stream denotes the column, and the current state gives the row. The intersection of these in the table yields a datum which may be the new state, an error indication, or certain other kinds of information see Fig.. If the datum in the table is always a new state, then the symbol-state table is equivalent to a finite state machine with no output. If the datum is always a subroutine address, then the table is a transition matrix. However, there are many other possibilities. I will deal here with the practical possibilities rather than the theoretical classifications. Examples of simple symbol-state tables An elementary example should make clear the way in which a symbol-state may be used for syntax checking. Let us suppose that it is necessary to check the syntax of FORTRAN GOTO statements. We will further suppose that the keyword GOTO has already been identified, so that all that needs to be done is to check the remaining non-blank characters of the statement. These will be Input symbol Downloaded from by guest on October ;urrent state Subroutine Fig.. Transition matrix The Computer Journal Volume Number November Fig.. Symbol-state table

2 FOLLOWS: GO TO part of name EXPECTS: /label \{label, / \ label, / \> label f alph. char. < ALPH. NUM. Fig.. Checking simple and computed GO TO our input symbols, which we will consider to be terminated by a further symbol called end of statement. A subroutine which we will call NEXT is needed to deliver the type of the next symbol. The types will be:. Alphabetic characters.. Numeric s.. Left bracket.. Right bracket.. Comma... For simplicity we will first assume that the only permittcu forms are the simple GOTO and the computed GOTO, i.e. the forms: GOTO label GOTO label, label..., name where label represents a string of to decimal s, and name must begin with an alphabetic character, which is then followed by to alphabetic or numeric characters. A symbol-state table which will check the syntax of these GOTO statements is shown in Fig.. Certain cells are left blank for greater readability. These would normally be filled with negative numbers, indicating an error condition. A zero cell indicates that the whole statement has been checked, with no errors detected. A positive cell is to be interpreted as the new state. On the left-hand side of the table in Fig. there are two columns of comments which have been found useful when constructing large or complex tables. The problems which arise then are similar to those encountered i Tlie use of symbol-state tables when programming in absolute non-symbolic machine code. The left-hand column of comments gives some indication of the symbols which have been found immediately before reaching that state. The right-hand column shows which symbols are to be expected and therefore permitted. The table in Fig. must be used in conjunction with a driving program, of course. A suitable section of FORTRAN coding for performing this task is given in Prog.. It is assumed that the table in Fig. has been loaded into the array called TABLE in Prog.. This array has been dimensioned with rows to allow for expansion as we deal with more complex examples. DIMENSION TABLE, INTEGER, TYPE, TABLE C SET INITIAL = C GET THE TYPE OF THE NEXT INPUT CALL NEXT TYPE C RETRIEVE THE NEXT FROM THE TABLE = TABLE, TYPE C TEST FOR ERROR, EXIT OR CONTINUE IF,, C SUCCESSFUL EXIT - NO ERRORS FOUND CONTINUE * C ERROR EXIT CONTINUE Prog. We will now see how the table in Fig., driven by the coding above, checks the FORTRAN statement: GOTO,,, IPT The table is entered with an initial state of when the next symbol in the input stream is the one immediately following the GOTO. When the cell in the table is positive, it is taken to be the state for examining the next symbol. The sequence of states may be shown as follows: Downloaded from by guest on October Next symbol Symbol State Cell of table ^ X» "", I ^ A U -^j -^ P T

3 A. C. Day FOLLOWS : GOTO name, EXPECTS: label I {label, alph. char, { label, / label f ALPH. NUM. Fig.. Amendment to Fig. for checking assigned GO TO in addition to simple and computed GO TO In Fig. there are cells left blank, to be filled with negative error flags. By choosing different negative integers for different error conditions, we are able to diagnose up to different types of error. Of course, such detail is hardly necessary, and several cells may be given the same error number. At the error exit, we may print out different messages according to the error number, or we may print out a standard diagnostic together with the error number itself. The checking performed by the table in Fig. is not adequate for many purposes. For instance, we do not test to see that names and labels do not exceed their maximum permitted lengths. Nor do we ensure that the name is integer in type. However, this is intended merely as a simple example to show the workings of a symbol-state table. Note that the driving loop in this example is only three FORTRAN statements in length. It is true that one of these three is a call to a subroutine, but this subroutine NEXT need not be very complex, and it would be needed whatever method of checking was used. FOR- TRAN code is conserved because the table is in effect interpretive code. This concept of the table as code is a useful one, as it may be developed to cover subroutines within the body of the table, which may in fact be called recursively, and also calls from the table to sections of program coding in order to perform special actions which are beyond the scope of the table. These ideas will be developed in the remainder of the article. Table subroutines A further type of GOTO statement exists in FOR- TRAN, namely, the assigned GOTO. This has the format: GOTO name, {label, label... j Fig. shows the amendments which need to be made to Fig. in order for the table to test the syntax of all three types of GOTO. Rows of the table in Fig. which are not mentioned in Fig. are assumed to remain the same. At this point there is considerable redundancy in the table, as rows - are identical with rows -. These two sections are both checking for the structure: label, label... We cannot directly combine these two sections, because after rows - we must look for, name whereas after rows - only the end of statement is permitted. The redundancy and waste of space which is apparent here becomes progressively more of a problem as the syntax which is tested becomes more detailed. This is obviously the kind of problem which, when coding, can be handled by a subroutine which is called from two different places. The redundancy in the symbol-state table under consideration can be overcome by means of a table analogue for a subroutine. Throughout the rest of this paper such an analogue will be written as subroutine in italics to distinguish it from a coded subroutine. Instead of having two blocks of rows which are identical, only one version of these rows is kept, and when this is entered, the return address is stored. The return address is here the row which should be used as the old state on leaving the subroutine. FOLLOWS: GOTO {label..., part of name part of name name, {label... label, Fig.. EXPECTS: label j {label, [name, / -, L \, name name falph. char. -< [ falph. char. I {label, label, label f label J, ' anything ALPH. Checking simple, assigned and computed GOTOs using a subroutine rows - NUM : Downloaded from by guest on October

4 DIMENSION TABLE, INTEGER, TYPE, TABLE, RET C SET INITIAL AND RETURN ADDRESS = RET = C GET THE TYPE OF THE NEXT INPUT CALL NEXT TYPE C LOOK UP THE NEXT IN THE TABLE = TABLE, TYPE C TEST FOR ERROR, EXIT OR CONTINUE IF,, C POSITIVE - IS IT MORE THAN IF.LT. GO TO C SUBROUTINE CALL - UNPACK RETURN ADDR. RET = MOD, = / GO TO CIF RETURN ADDR. IS NOT ZERO, GO TO IT k IF RET.EQ. GO TO = RET RET = GO TO C SUCCESSFUL EXIT - NO ERRORS FOUND CONTINUE C ERROR EXIT CONTINUE Prog. The table in Fig. is the equivalent of those in Figs. and in the checking it performs, but rows - of the former take the place of the duplicated rows of the latter. Rows - of Fig. are a subroutine for checking two or more labels, separated by commas, and terminated by a right bracket. This subroutine is called from two cells of the table, rows and, column in each case. In order to call a subroutine two row addresses are needed, one to indicate the starting row of the subroutine, and one for the return row. This information is packed into one cell in Fig. by the arbitrary method of multiplying The use of symbol-state tables the subroutine address by and adding to it the return address. Of course, two tables could be used, one of which would contain only the subroutine addresses for calls, but this would be very wasteful of space. A zero cell in the table now has two meanings. When executing a subroutine it means 'go to the return address' as in row of Fig.. Outside a subroutine it means 'exit from the table' as in row, column of Fig.. The FORTRAN coding needed to drive the table will now have to be amended. A variable RET will be used to store the return address. Each time a positive datum is obtained from the table it is now necessary to test whether it is greater than. The coding will now be that of Prog.. In FORTRAN the assigned and computed GOTO statements have in common the string label, label... It will be seen from Fig. that the subroutine is not called until the first common symbol the left bracket is encountered. It usually happens that we do not know whether the subroutine needs to be called until we reach the first symbol which could have been checked by that subroutine. In Fig. the left bracket is checked in rows and, so that it is pointless to have the subroutine check it over again. Therefore I adopt the convention that on a call to a subroutine the next symbol is obtained from the input stream ready for the subroutine to check it. Thus in Fig. the first symbol to be checked by the subroutine is the first numeric inside the brackets. A similar convention needs to be adopted on returning from a subroutine. In the example used here, we know that control should pass from the subroutine as soon as the right bracket is found, so we could return from row, column of Fig., obtaining the next symbol from the input stream as we do so. However, the more usual case is that we only realise that we ought to have returned from the subroutine when examining the first symbol which is not to be checked by that subroutine. Therefore the convention I adopt is to return on the first symbol not handled by the subroutine, and not to get the next symbol from the input stream as control is passed back. This is why, in the coding of Prog., when a return address is used as the next state, control is passed to statement rather than to statement. This means that in Fig. row appears to be wasted. Its purpose is really to get the next symbol beyond the right bracket, in order to return with this symbol to the return address either row or row, where this symbol will be checked. It is not necessary to put error codes in row, e.g. to trap an erroneous left bracket. All such checking can be done when the return address is reached, i.e. in this case, row or row. Once again, this is merely an example to show what can be done by means of symbol-state tables. In this case we have saved rows out of by using a subroutine. When the syntax to be checked is more complex, the savings which accrue by using subroutines become very considerable indeed. The FORTRAN loop which is executed when there are no calls, errors or returns is still only four statements in length. Nested and recursive calls The FORTRAN coding for use with the table in Downloaded from by guest on October

5 Fig. was written with the assumption that only one subroutine would be called at a time. It is very useful to be able to have nested calls. As a call to a symbol-state table subroutine does not change the table in any way, these calls may in fact be recursive with no additional machinery. FOLLOWS: EXPECTS: fbeginning exprn fop < t exprn Fig.. ^ NAME OP Checking expressions by recursive calls OTHER Recursive techniques are particularly useful for checking recursive structures. As an example, let us consider expressions which are defined by the following BNF grammar: <name> ::= A B C D E F G H I J K L M N O P Q R S T U V W X Y Z <op> ::= + - * / <exprn> ::= <name> «exprn» <exprn><op><exprn> The third rule is a recursive definition of <exprn> in terms of itself. Examples of expressions defined by this grammar are: F A +B «G/D - E*M + P The syntax of all expressions defined by this grammar may be checked by the symbol-state table in Fig.. For both nested and recursive calls the return addresses must be kept in a stack. FORTRAN coding to drive Fig. is therefore a little more complicated, but Prog. is sufficient. Subroutine NEXT also needs to be amended in order to deliver the types of symbols required by Fig.. An extra column column has been added to Fig. in order to cope with invalid symbols which are encountered by NEXT. When NEXT finds a symbol which it cannot assign to any of the five types, it makes it type. All of the cells in column contain error codes, so that the invalid symbol is trapped by the same mechanism which finds symbols in invalid positions. One weakness of Fig. is that both a return from a call, and exit from the table, can occur when either a right bracket or the end of statement is reached. This means that excess right brackets could cause exit from the table before the whole statement has been checked. This could have been avoided by adding extra rows to the table, so that the first call to the subroutine is separated from all other recursive calls. For interest, this table is given in Fig.. However, the economy of Fig. may be preserved simply by the addition of the statement labelled in Prog., to check on final exit from the table that the end of statement has in fact been reached. A. C. Day As an example, let us take the expression G/D - E*M + P and trace the sequence of states as this expression is DIMENSION TABLE,, STACK INTEGER, TYPE, TABLE, STACK * C SET INITIAL AND LEVEL OF CALLS = LEVEL = C GET THE TYPE OF THE NEXT INPUT CALL NEXT TYPE C LOOK UP THE NEXT IN THE TABLE = TABLE, TYPE C TEST FOR ERROR, EXIT OR CONTINUE IF, if, C POSITIVE - IS IT MORE THAN IF.LT. GO TO C SUBROUTINE CALL - INCREMENT LEVEL LEVEL = LEVEL + IF LEVEL.GT. GO TO C UNPACK RETURN AND SUBROUTINE ADDR. STACK LEVEL = MOD, = / GO TO C IF STACK IS NOT EMPTY, RETURN k IF LEVEL.EQ. GO TO = STACK LEVEL LEVEL = LEVEL - GO TO C EXIT - NO ERRORS FOUND - TEST IF IF TYPE.NE. GO TO * C ERROR EXIT CONTINUE. C CALLS ARE NESTED TOO DEEPLY CONTINUE Prog. Downloaded from by guest on October

6 The use of symbol-state tables Next symbol Symbol type G / D - E * M + P Old state New state Top of stack "' ^ ^ ^ ^ / ^ ^ X ^ Level checked. In each state the stack contains the number of values given by the variable LEVEL, but here only the last value placed in the stack will be shown. The table being used is that in Fig.. Note that on a call to a subroutine the new state is used to give both the next old state, and also the return address which is pushed down on the stack. On return from a subroutine no new symbol is obtained from the input stream, but the next old state is derived by 'popping' the top of the stack. The sequence of states will be as in the table above. The power of symbol-state tables is seen in the fact that only three rows are sufficient to check recursive structures of considerable complexity. Rows - of Fig. may themselves be called as a subroutine if such expressions occur at different places in higher level structures. In that case the FORTRAN coding given in Prog. is sufficient for both the higher level structures and the expression subroutine; no more coding is needed for the driver program than that given. Action calls Just as writers of programs in high level languages find it convenient at times to call subroutines written in assembly language, so writers of symbol-state tables sometimes find it necessary to perform part of the syntax checking by means of specially written program statements rather than by means of rows in the matrix. In either case the motivation may be economy of space or time, or in order to do something which is not possible in the basic medium. It is possible for a symbol-state table to call sections of program coding, control usually being handed back to the table again. A convenient name for such a process is action call. The need for this may be illustrated using Fig.. beginning { name op exprn exprn exprn exprn /name op op fop \ NAME OP OTHER Fig.. Expanded to check expressions by recursive calls Column of rows and, and columns and of rows and, are used to check for a FORTRAN variable name, which must begin with an alphabetic character, which may then be followed by up to five alphabetic or numeric characters. All that the table in Fig. does is to check that the first character is alphabetic, and that any subsequent characters are alphabetic or numeric. No check is made on the length of the name, or its type which for an assigned or computed GOTO must be integer. The length of the name could be checked by means of a subroutine, but this would use up an extra five rows in the symbol-state table. At the expense of an extra column in the table a test could be made as to whether the first character of the name was between I and N, but the type may have been set by an explicit type statement. The only way to test the type for sure is to keep a table of names and their attributes, which a symbol-state table is unable to do. What is needed is a section of program coding which can be called from the table, and which will process a name, checking its length and type. This could be done by modifying Fig., row, column, to the number. The convention would be that the ten-thousands indicates that this is an action call. The next two s specify that action is required. The final s give the row to which control should be returned after the action call. The contents of columns and in row are now irrelevant, as the coding for the action call will process all alphabetic and numeric characters belonging to the name. The same action call will be required from row, column, so this cell in the table will be changed to. In the same way, Fig. does not check labels sufficiently, and could be supplemented with action coding for this purpose. No FORTRAN label may be more than five decimal s in length. Also any thorough checking of a FORTRAN program will need to keep a table of labels, and must amend the table for all labels referenced in GOTO statements to ensure that the program segment contains these labels, and that they are attached to executable statements. To check a label in these ways could be the purpose of action. Then row, column of Fig. would be changed to, meaning 'action call, return address '. All other checking of labels in Fig. would similarly use action. The revised form of Fig. is given in Fig.. Obviously a FORTRAN driving program for use with the table in Fig. must be different from that used with the table of Fig.. If the next state retrieved from the table is greater than, then a further test must be made to see whether it is greater than, in which case the three numbers must be unpacked from the cell. A computed GOTO based on the required action here or leads to the appropriate action coding. Downloaded from by guest on October

7 A. C. Day ALPH. NUM. Fig.. Fig. modified to include action calls for checking names and labels. Note that rows, and could now be condensed into one row. This has not been done in order to preserve similarity with Fig.. Z id UH z < Q U s«z" CO ftze Sis. o< ii oa ow za! S ft w gaction P <: Multiple symbol-state tables There are certain problems for which more than one symbol-state table may be needed. For example, when checking FORTRAN statements, the FORMAT statement will need a different symbol-state table and a different subroutine to deliver the type of the next input symbol from all other statements. This is because in most FORTRAN statements there is no significant difference in type between such characters as A, Fand X, whereas in the FORMAT statement they must be treated as different types of symbols. The number of columns for a table checking FORMAT statements will normally be greater than for one checking other statements. The two tables could only be combined at the expense of a considerable wastage of space. It may even be necessary at times to have a hierarchy of symbol-state tables, the higher tables checking the order of items whose internal structure has been checked by lower tables. For example, let us consider a hierarchy of tables for checking the syntax of FORTRAN. The lowest level tables will check the syntax of statements. There will probably be two of these, one to check FORMAT statements, and the other to check all other statements. For both these tables the symbols will be characters in the input stream. A higher level table will be needed to check for the ordering of statements within program segments O u. Z ENT L O a: D gl!i a < ATEMEN YPE W O M a Downloaded from by guest on October Action calls: Error message statement out of order. Error message END line missing. Error message statement is illegal in BLOCK DATA. Error message null subprogram. Error message if the statement is not labelled. Error message END not preceded by transfer of control. Error message subprogram contains no executable statement. Error message unrecognised statement. Fig.. Checking for the order of FORTRAN statements

8 The use of symbol-state tables A suitable table for checking that this conforms to the specification of ASI FORTRAN is shown in Fig.. In this case the symbols are FORTRAN statements which have already been checked using the lowest level tables. The table in Fig. has no subroutines, so the hundreds is used to indicate action calls. The actions required are shown beneath the table. A higher level table still could be used in which the symbols are program segments, and in which a test is made that one and only one main program, and not more than one BLOCK DATA subprogram, occur. However, this can be done more economically by keeping flags which are set by action calls from the table in Fig.. The point is that complex structures may be checked by using a hierarchy of tables, thereby increasing their power. Applications From the examples given here it will be apparent that symbol-state tables are a great help in designing syntax checkers for a programming language. Compilers do not do all the syntax checking which may be desired, as they are almost always biased towards some manufacturer's version of the language, and hardly ever check for an internationally agreed standard. Consequently there arises a need for syntax checkers written in a high level language in order to be machine independent which test the syntax of programs in a high level language, e.g. a FORTRAN program to check the syntax of a FORTRAN program and flag every statement which does not conform to the ASI standard. This could be a great help in establishing whether or not a particular program is machine independent. The size of such a syntax checker can be greatly reduced by using symbolstate tables, without impairing the speed. Another application has been that of processing text material in a natural language. A project was undertaken at the Computer Centre of University College London under a grant from the School of Oriental and African Studies to produce the final volume of Sir Ralph Turner's Comparative Dictionary of Indo-Aryan Languages. This was to be a phonetic analysis, listing all those headwords which contained examples of certain sequences of symbols. The, Sanskrit headwords from the dictionary were punched on to paper tape, then copied on to magnetic tape. The Sanskrit is represented in the dictionary by a Romanised transliteration which includes many 'diacritics', i.e. marks above and below the letters. For computer input these composite symbols had to be coded as the letter followed by special characters representing the diacritics, e.g. t became T became S/ a became A/= A magnetic tape had to be produced for automatic typesetting on which every printable symbol composite or not had to be represented by an integer, e.g. t was represented as, a as, and so on. The problem was to recognise groups of characters in the input stream as the corresponding printable symbols, and to do it efficiently. A symbol-state table was written with a subroutine which built up the printable symbols. Each time a letter was found in the input stream, the subroutine was called. Action calls from the subroutine as the letter and any following diacritics were processed, built up the resulting single integer. In fact, as the subroutine was called, a count was initialised to a certain value depending on the letter which had been encountered. When a diacritic was found, the count was incremented by an amount depending on the diacritic. When a character was encountered which could not be part of the printable symbol, control was handed back from the subroutine, and at the same time the resulting count was placed in the output stream. This process enabled some proofreading to be performed, as certain invalid sequences of characters were trapped by the symbol-state table. Other possible uses of symbol-state tables which have suggested themselves are pattern-matching, parsing, or even with suitable action calls as the core of an interpreter. The great drawback to the tables presented here is the labour of constructing them by hand. However, it should not be too difficult to write programs which will accept rules in an appropriate form, and which will build a table to check statements according to those rules. These tables provide a powerful technique which should not be confined to compiler writers, or to those who program in assembly languages. Acknowledgements My thanks are due to Paul A. Samet, who first introduced me to simple symbol-state tables. Alan Shaw has assisted me under grants from the National Computing Centre for work on syntax checkers and from the School of Oriental and African Studies for work mentioned above. Downloaded from by guest on October References CHAPIN, N.. Parsing of Decision Tables, CACM, Vol., No., pp. -. GRIES, D.. Use of Transition Matrices in Compiling, CACM, Vol., No., pp. -. FELDMAN, J., and GRIES, D.. Translator Writing Systems, CACM, Vol., No., pp. -.

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack. Other Automata We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack. From all of this information we decide what state

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

2.2 Syntax Definition

2.2 Syntax Definition 42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions

More information

MACHINE INDEPENDENCE IN COMPILING*

MACHINE INDEPENDENCE IN COMPILING* MACHINE INDEPENDENCE IN COMPILING* Harry D. Huskey University of California Berkeley, California, USA Since 1958, there has been a substantial interest in the development of problem-oriented languages

More information

Stating the obvious, people and computers do not speak the same language.

Stating the obvious, people and computers do not speak the same language. 3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what

More information

COMPILER DESIGN LECTURE NOTES

COMPILER DESIGN LECTURE NOTES COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:

More information

LL Parsing, LR Parsing, Complexity, and Automata

LL Parsing, LR Parsing, Complexity, and Automata LL Parsing, LR Parsing, Complexity, and Automata R. Gregory Taylor Department of Mathematics and Computer Science Manhattan College Riverdale, New York 10471-4098 USA Abstract It

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing

More information

Developing Real-Time Systems

Developing Real-Time Systems Developing Real-Time Systems by George R. Dimble, Jr. Introduction George R. Trimble, Jr., obtained a B.A. from St. John's College in 1948 and an M.A. in mathematics from the University of Delaware in

More information

Symbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is

More information

UNIT III & IV. Bottom up parsing

UNIT III & IV. Bottom up parsing UNIT III & IV Bottom up parsing 5.0 Introduction Given a grammar and a sentence belonging to that grammar, if we have to show that the given sentence belongs to the given grammar, there are two methods.

More information

Programming Lecture 3

Programming Lecture 3 Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements

More information

9. Elementary Algebraic and Transcendental Scalar Functions

9. Elementary Algebraic and Transcendental Scalar Functions Scalar Functions Summary. Introduction 2. Constants 2a. Numeric Constants 2b. Character Constants 2c. Symbol Constants 2d. Nested Constants 3. Scalar Functions 4. Arithmetic Scalar Functions 5. Operators

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

A simple syntax-directed

A simple syntax-directed Syntax-directed is a grammaroriented compiling technique Programming languages: Syntax: what its programs look like? Semantic: what its programs mean? 1 A simple syntax-directed Lexical Syntax Character

More information

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6

More information

Hashing. 1. Introduction. 2. Direct-address tables. CmSc 250 Introduction to Algorithms

Hashing. 1. Introduction. 2. Direct-address tables. CmSc 250 Introduction to Algorithms Hashing CmSc 250 Introduction to Algorithms 1. Introduction Hashing is a method of storing elements in a table in a way that reduces the time for search. Elements are assumed to be records with several

More information

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 20 Intermediate code generation Part-4 Run-time environments

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

SETUP AND UPDATING OF THE CRITERION TREE FIUE. Tom E v s l i n and Thomas Lewis. The criterion tree dictionary, required as part of the syntactic

SETUP AND UPDATING OF THE CRITERION TREE FIUE. Tom E v s l i n and Thomas Lewis. The criterion tree dictionary, required as part of the syntactic ISR-7 June 196U VIII. VIII-1 SETUP AND UPDATING OF THE CRITERION TREE FIUE Tom E v s l i n and Thomas Lewis 1. Introduction The criterion tree dictionary, required as part of the syntactic processing described

More information

Theory and Compiling COMP360

Theory and Compiling COMP360 Theory and Compiling COMP360 It has been said that man is a rational animal. All my life I have been searching for evidence which could support this. Bertrand Russell Reading Read sections 2.1 3.2 in the

More information

SMURF Language Reference Manual Serial MUsic Represented as Functions

SMURF Language Reference Manual Serial MUsic Represented as Functions SMURF Language Reference Manual Serial MUsic Represented as Functions Richard Townsend, Lianne Lairmore, Lindsay Neubauer, Van Bui, Kuangya Zhai {rt2515, lel2143, lan2135, vb2363, kz2219}@columbia.edu

More information

1. Lexical Analysis Phase

1. Lexical Analysis Phase 1. Lexical Analysis Phase The purpose of the lexical analyzer is to read the source program, one character at time, and to translate it into a sequence of primitive units called tokens. Keywords, identifiers,

More information

3.5 Practical Issues PRACTICAL ISSUES Error Recovery

3.5 Practical Issues PRACTICAL ISSUES Error Recovery 3.5 Practical Issues 141 3.5 PRACTICAL ISSUES Even with automatic parser generators, the compiler writer must manage several issues to produce a robust, efficient parser for a real programming language.

More information

CS323 Lecture - Specifying Syntax and Semantics Last revised 1/16/09

CS323 Lecture - Specifying Syntax and Semantics Last revised 1/16/09 CS323 Lecture - Specifying Syntax and Semantics Last revised 1/16/09 Objectives: 1. To review previously-studied methods for formal specification of programming language syntax, and introduce additional

More information

COMPILERS BASIC COMPILER FUNCTIONS

COMPILERS BASIC COMPILER FUNCTIONS COMPILERS BASIC COMPILER FUNCTIONS A compiler accepts a program written in a high level language as input and produces its machine language equivalent as output. For the purpose of compiler construction,

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

Introduction to Lexing and Parsing

Introduction to Lexing and Parsing Introduction to Lexing and Parsing ECE 351: Compilers Jon Eyolfson University of Waterloo June 18, 2012 1 Riddle Me This, Riddle Me That What is a compiler? 1 Riddle Me This, Riddle Me That What is a compiler?

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design i About the Tutorial A compiler translates the codes written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target

More information

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages!! Chapter 3 Regular Expression and Lexer Xu Liu Recap! Copyright 2006 The McGraw-Hill Companies, Inc. Clite: Lexical Syntax! Input: a stream of characters from

More information

Summary: Direct Code Generation

Summary: Direct Code Generation Summary: Direct Code Generation 1 Direct Code Generation Code generation involves the generation of the target representation (object code) from the annotated parse tree (or Abstract Syntactic Tree, AST)

More information

Non-deterministic algorithms

Non-deterministic algorithms Carnegie Mellon University Research Showcase Computer Science Department School of Computer Science 1-1-1966 Non-deterministic algorithms Robert W. Floyd Carnegie Mellon University Recommended Citation

More information

Symbol Tables. ASU Textbook Chapter 7.6, 6.5 and 6.3. Tsan-sheng Hsu.

Symbol Tables. ASU Textbook Chapter 7.6, 6.5 and 6.3. Tsan-sheng Hsu. Symbol Tables ASU Textbook Chapter 7.6, 6.5 and 6.3 Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Definitions Symbol table: A data structure used by a compiler to keep track

More information

EECS 311: Data Structures and Data Management Program 1 Assigned: 10/21/10 Checkpoint: 11/2/10; Due: 11/9/10

EECS 311: Data Structures and Data Management Program 1 Assigned: 10/21/10 Checkpoint: 11/2/10; Due: 11/9/10 EECS 311: Data Structures and Data Management Program 1 Assigned: 10/21/10 Checkpoint: 11/2/10; Due: 11/9/10 1 Project: Scheme Parser. In many respects, the ultimate program is an interpreter. Why? Because

More information

Review of Number Systems

Review of Number Systems Review of Number Systems The study of number systems is important from the viewpoint of understanding how data are represented before they can be processed by any digital system including a digital computer.

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Semantics of COW. July Alex van Oostenrijk and Martijn van Beek

Semantics of COW. July Alex van Oostenrijk and Martijn van Beek Semantics of COW /; ;\ \\ // /{_\_/ `'\ \ (o) (o } / :--',-,'`@@@@@@@@ @@@@@@ \_ ` \ ;:( @@@@@@@@@ @@@ \ (o'o) :: ) @@@@ @@@@@@,'@@( `====' Moo! :: : @@@@@: @@@@ `@@@: :: \ @@@@@: @@@@@@@) ( '@@@' ;; /\

More information

UNIT -2 LEXICAL ANALYSIS

UNIT -2 LEXICAL ANALYSIS OVER VIEW OF LEXICAL ANALYSIS UNIT -2 LEXICAL ANALYSIS o To identify the tokens we need some method of describing the possible tokens that can appear in the input stream. For this purpose we introduce

More information

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 20th May 2016 Time: 14:00-16:00

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 20th May 2016 Time: 14:00-16:00 Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Compilers Date: Friday 20th May 2016 Time: 14:00-16:00 Please answer any THREE Questions from the FIVE Questions provided This is a CLOSED

More information

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

Typing Control. Chapter Conditionals

Typing Control. Chapter Conditionals Chapter 26 Typing Control 26.1 Conditionals Let s expand our language with a conditional construct. We can use if0 like before, but for generality it s going to be more convenient to have a proper conditional

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Computational Science & Engineering

UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Computational Science & Engineering COMP60081 Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE M.Sc. in Computational Science & Engineering Fundamentals of High Performance Execution Wednesday 16 th January 2008 Time: 09:45

More information

CPS122 Lecture: From Python to Java

CPS122 Lecture: From Python to Java Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

The Logical Design of the Tokeniser

The Logical Design of the Tokeniser Page 1 of 21 The Logical Design of the Tokeniser Purpose 1. To split up a character string holding a RAQUEL statement expressed in linear text, into a sequence of character strings (called word tokens),

More information

1 Motivation for Improving Matrix Multiplication

1 Motivation for Improving Matrix Multiplication CS170 Spring 2007 Lecture 7 Feb 6 1 Motivation for Improving Matrix Multiplication Now we will just consider the best way to implement the usual algorithm for matrix multiplication, the one that take 2n

More information

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays

A Beginner s Guide to Programming Logic, Introductory. Chapter 6 Arrays A Beginner s Guide to Programming Logic, Introductory Chapter 6 Arrays Objectives In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested

More information

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator:

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator: Syntax A programming language consists of syntax, semantics, and pragmatics. We formalize syntax first, because only syntactically correct programs have semantics. A syntax definition of a language lists

More information

Final Examination May 5, 2005

Final Examination May 5, 2005 CS 4352 Compilers and Interpreters Final Examination May 5, 2005 Name Closed Book. If you need more space ask for an extra sheet. 1. [4 points] Pick the appropriate data structure for each purpose: storage

More information

Get Free notes at Module-I One s Complement: Complement all the bits.i.e. makes all 1s as 0s and all 0s as 1s Two s Complement: One s complement+1 SIGNED BINARY NUMBERS Positive integers (including zero)

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

Chapter 8 :: Composite Types

Chapter 8 :: Composite Types Chapter 8 :: Composite Types Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter08_Composite_Types_4e - Tue November 21, 2017 Records (Structures) and Variants

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

CSE Theory of Computing Fall 2017 Project 1-SAT Solving

CSE Theory of Computing Fall 2017 Project 1-SAT Solving CSE 30151 Theory of Computing Fall 2017 Project 1-SAT Solving Version 3: Sept. 21, 2017 The purpose of this project is to gain an understanding of one of the most central problems of computing: Boolean

More information

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

UNIT-II. Part-2: CENTRAL PROCESSING UNIT Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:

More information

CROSSREF Manual. Tools and Utilities Library

CROSSREF Manual. Tools and Utilities Library Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN

More information

The New C Standard (Excerpted material)

The New C Standard (Excerpted material) The New C Standard (Excerpted material) An Economic and Cultural Derek M. Jones derek@knosof.co.uk Copyright 2002-2008 Derek M. Jones. All rights reserved. 1722 6.8.1 Labeled statements labeled statements

More information

GNU ccscript Scripting Guide IV

GNU ccscript Scripting Guide IV GNU ccscript Scripting Guide IV David Sugar GNU Telephony 2008-08-20 (The text was slightly edited in 2017.) Contents 1 Introduction 1 2 Script file layout 2 3 Statements and syntax 4 4 Loops and conditionals

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This book is licensed under a Creative Commons Attribution 3.0 License 6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars

More information

Parsing Combinators: Introduction & Tutorial

Parsing Combinators: Introduction & Tutorial Parsing Combinators: Introduction & Tutorial Mayer Goldberg October 21, 2017 Contents 1 Synopsis 1 2 Backus-Naur Form (BNF) 2 3 Parsing Combinators 3 4 Simple constructors 4 5 The parser stack 6 6 Recursive

More information

CSE Theory of Computing Fall 2017 Project 4-Combinator Project

CSE Theory of Computing Fall 2017 Project 4-Combinator Project CSE 30151 Theory of Computing Fall 2017 Project 4-Combinator Project Version 1: Nov. 20, 2017 1 Overview At this point you understand computations that happen as planned series of individual steps where

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer: Theoretical Part Chapter one:- - What are the Phases of compiler? Six phases Scanner Parser Semantic Analyzer Source code optimizer Code generator Target Code Optimizer Three auxiliary components Literal

More information

Direct Functions in Dyalog APL

Direct Functions in Dyalog APL Direct Functions in Dyalog APL John Scholes Dyalog Ltd. john@dyalog.com A Direct Function (dfn) is a new function definition style, which bridges the gap between named function expressions such as and

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

III Data Structures. Dynamic sets

III Data Structures. Dynamic sets III Data Structures Elementary Data Structures Hash Tables Binary Search Trees Red-Black Trees Dynamic sets Sets are fundamental to computer science Algorithms may require several different types of operations

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55. 1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

In this chapter you ll learn:

In this chapter you ll learn: Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading on

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

Table : IEEE Single Format ± a a 2 a 3 :::a 8 b b 2 b 3 :::b 23 If exponent bitstring a :::a 8 is Then numerical value represented is ( ) 2 = (

Table : IEEE Single Format ± a a 2 a 3 :::a 8 b b 2 b 3 :::b 23 If exponent bitstring a :::a 8 is Then numerical value represented is ( ) 2 = ( Floating Point Numbers in Java by Michael L. Overton Virtually all modern computers follow the IEEE 2 floating point standard in their representation of floating point numbers. The Java programming language

More information

Part 5 Program Analysis Principles and Techniques

Part 5 Program Analysis Principles and Techniques 1 Part 5 Program Analysis Principles and Techniques Front end 2 source code scanner tokens parser il errors Responsibilities: Recognize legal programs Report errors Produce il Preliminary storage map Shape

More information

Lexical and Syntax Analysis. Top-Down Parsing

Lexical and Syntax Analysis. Top-Down Parsing Lexical and Syntax Analysis Top-Down Parsing Easy for humans to write and understand String of characters Lexemes identified String of tokens Easy for programs to transform Data structure Syntax A syntax

More information

Volume II, Section 5 Table of Contents

Volume II, Section 5 Table of Contents Volume II, Section 5 Table of Contents 5...5-1 5.1 Scope...5-1 5.2 Basis of...5-1 5.3 Initial Review of Documentation...5-2 5.4 Source Code Review...5-2 5.4.1 Control Constructs...5-3 5.4.1.1 Replacement

More information

Scheme Quick Reference

Scheme Quick Reference Scheme Quick Reference COSC 18 Fall 2003 This document is a quick reference guide to common features of the Scheme language. It is not intended to be a complete language reference, but it gives terse summaries

More information

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table COMPILER CONSTRUCTION Lab 2 Symbol table LABS Lab 3 LR parsing and abstract syntax tree construction using ''bison' Lab 4 Semantic analysis (type checking) PHASES OF A COMPILER Source Program Lab 2 Symtab

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

British Informatics Olympiad Final 30 March 1 April, 2007 Sponsored by Lionhead Studios. Parsing

British Informatics Olympiad Final 30 March 1 April, 2007 Sponsored by Lionhead Studios. Parsing British Informatics Olympiad Final 30 March 1 April, 2007 Sponsored by Lionhead Studios Parsing This question is quite long do not worry if you do not get to the end Backus-Naur form One of the first tasks

More information

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function TAFL 1 (ECS-403) Unit- V 5.1 Turing Machine 5.2 TM as computer of Integer Function 5.2.1 Simulating Turing Machine by Computer 5.2.2 Simulating Computer by Turing Machine 5.3 Universal Turing Machine 5.4

More information

PRELIMINARY APPLE BASIC USERS MANUAL OCTOBER Apple Computer Company. 770 Welch Rd., Palo Alto, CA (415)

PRELIMINARY APPLE BASIC USERS MANUAL OCTOBER Apple Computer Company. 770 Welch Rd., Palo Alto, CA (415) PRELIMINARY APPLE BASIC USERS MANUAL OCTOBER 1976 Apple Computer Company. 770 Welch Rd., Palo Alto, CA 94304 (415) 326-4248 This is a PRELIMINARY manual. It will, most likley, contain errors, incorrect

More information

It can be confusing when you type something like the expressions below and get an error message. a range variable definition a vector of sine values

It can be confusing when you type something like the expressions below and get an error message. a range variable definition a vector of sine values 7_april_ranges_.mcd Understanding Ranges, Sequences, and Vectors Introduction New Mathcad users are sometimes confused by the difference between range variables and vectors. This is particularly true considering

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd 19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading

More information

The basic operations defined on a symbol table include: free to remove all entries and free the storage of a symbol table

The basic operations defined on a symbol table include: free to remove all entries and free the storage of a symbol table SYMBOL TABLE: A symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating

More information

Chapter 3: Lexing and Parsing

Chapter 3: Lexing and Parsing Chapter 3: Lexing and Parsing Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Lexing and Parsing* Deeper understanding

More information

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore (Refer Slide Time: 00:20) Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 4 Lexical Analysis-Part-3 Welcome

More information

Informatica 3 Syntax and Semantics

Informatica 3 Syntax and Semantics Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines

More information

UNIT-4 (COMPILER DESIGN)

UNIT-4 (COMPILER DESIGN) UNIT-4 (COMPILER DESIGN) An important part of any compiler is the construction and maintenance of a dictionary containing names and their associated values, such type of dictionary is called a symbol table.

More information

CS 415 Midterm Exam Spring SOLUTION

CS 415 Midterm Exam Spring SOLUTION CS 415 Midterm Exam Spring 2005 - SOLUTION Name Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

Parsing. Roadmap. > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing

Parsing. Roadmap. > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing Roadmap > Context-free grammars > Derivations and precedence > Top-down parsing > Left-recursion > Look-ahead > Table-driven parsing The role of the parser > performs context-free syntax analysis > guides

More information

Special Section: Building Your Own Compiler

Special Section: Building Your Own Compiler cshtp6_19_datastructures_compiler.fm Page 1 Tuesday, February 14, 2017 10:31 AM 1 Chapter 19 Special Section: Building Your Own Compiler In Exercises8.31 8.33, we introduced Simpletron Machine Language

More information

Chapter 7 File Access. Chapter Table of Contents

Chapter 7 File Access. Chapter Table of Contents Chapter 7 File Access Chapter Table of Contents OVERVIEW...105 REFERRING TO AN EXTERNAL FILE...105 TypesofExternalFiles...106 READING FROM AN EXTERNAL FILE...107 UsingtheINFILEStatement...107 UsingtheINPUTStatement...108

More information

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Week 02 Module 06 Lecture - 14 Merge Sort: Analysis So, we have seen how to use a divide and conquer strategy, we

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information