Ye con only 5de a short di: tLtill: F : iI 1! I, +p hut e - CORE

163
SOMEASCTSOF ERROR CORRECTION OP PROGRAMMING LAN G1TAG RS by Mil. iton L'1u1 T'IU ', Ye con only 5de a short di: tLtill: F : iI 1! I, +p hut e: a o ii see pl ant;, there that nooi1; i to Ie , IuIi10-. Týýr; n, A thesis submitted for tho dgn of Doctor of Philosophy at the BRUNEL tThIVE. RS ITY 1976

Transcript of Ye con only 5de a short di: tLtill: F : iI 1! I, +p hut e - CORE

SOMEASCTSOF ERROR CORRECTION

OP PROGRAMMING LAN G1TAG RS

by

Mil. iton L'1u1 T'IU

', Ye con only 5de a

short di: tLtill: F : iI 1! I, +p

hut e: a o ii see pl ant;,

there that nooi1; i to Ie ,

IuIi10-.

Týýr; n,

A thesis submitted for tho d�gn

of Doctor of Philosophy at the

BRUNEL tThIVE. RS ITY

1976

BEST COPY

AVAILABLE Poor text in the original thesis. Some text bound close to the spine. Some images distorted

Ac Q OWLS M OTS

I am very indebted to Profee3or Dr. Igor Ale1c antler for his

guidance, encouragement and many helpful discussions during the period

of this project. These facts were very important in completing

this thesis.

Also, I would like to thank Professor Douglas Lewin for his help

and for many suggestions that guided me in this important area of

rosenroh.

Thanks are also due tö all my colleagues, in special Clylton

Fornandea, for their help and "feedback" in learning English.

I wich to thamk the Ministry of Learning and Education of Romania

for financial support.

A1sov I wich to thank Mrs. J. Marshall who typed ttiis thesis.

Finally I would like to thank my wife for her undo retnnt1ing,

p1ienee and encouragement during the period of this research.

Militon ? r®ntiu Brunel University

November 1976

I

ABSTRACT

This thesis treats the prob] em of error correction in rt

context free language, and the desijrn of an error correcting

parser for the BASIC laxiguuge.

'2wo important thi. ýgs can be said about this thesis.

First,, it presents the problem of error correction in a

context free language, and the existing results in the field.

The concept of a context free language as a model for a programming

language, and the definitions and results used later are presented

or reviewed. A distanoe between two strings is defined and used to

J velop a "minimum distance error correcting parser".

Second, the thesis develops two global error correctiiig parsers.

The first one is the top-down L; )oths,. l error correcting purser,

ý, i, tairwdd by tran3forming Unger's top-down sparser ii, t. o an error

ee(t Ling one.

Then the idea of Graham and of eOLIltn:, _; riK the

:. ii r rounding context of the error,, i8 exten dt, d , tir, i , Juhai :: 11, x; -1 G

i r,., 2cdhnce error corredting Parser is obta. ir, e, i 1,. v ,., -, Iys. ilig the

e context of the error, available fm,, the iz, q w t. -it , "iºlcl;.

These parsers, and other kxlown inetliod b arc t, l, ut. Lu Llesit»

gym, partially ixnplemetit an error c; orrcc, till t; [. rye :,, ý , ', 'I. ý; I U C.

2

CONTENTS

Acknowledgements

Abytraot

Notations

1. Introduction

1.1. Statement of the problem

1.2. The main parts of this theaie

2. T asio definitions

2.1. Context-free ]anguagea

2.2. The parsing problem

2.3. An efficient parsing algorithm for context-free

languages

A global top-down parser

. 5. Parsing a simple precedence 1; rammar

. «. 6. Acceptore

page 1

2

5

7

7 10

13

13

16

18 28

32

34

',. The problem of error correction and a survey of previous work 38

`. 1. The distance between two strings 3R

j. 2. The problem of error correction in a prograi u ging

]ai gage ýº: '-

1.3. A survey of the previous work in error recov.: ry and

error correction techniques 1ý5

,.: ome error correcting parsers 51

),. 1. Error correction by a tra. n$ducer 52

1ý. ý. Fsror correction in a regu1 tir 1 nnKunE; e 5j

143. A simple precedenoe error correcting par: =er 59

3

! ý. 1ý". A global top-down error correcting laa ner 91

! ý. ý. Summauy 102

5. Thu tIo: 3igri of an error cox"rcjc; tin,, parser for B! ýUC-111: e

1U2

5.1. The general er)l particular fettturuu of T3A. UUC 104

5.2. Structural design of an error-correctirig j aruor for F1ALIC 107

ti. Conclusion and future viork 118

ý;. 1. What are the results of this thesis; ? 118

;. ý. What remains to be done? 121

ý. 5. Finally , what is they real nwiturt or th vr�t) iern 123

1. is i b] iot; rup}, y 125

. 1. Appendi- I-1,11d syntax of BAS]C 13(7

ýý. ý" Appencti. 2- Program for bull tint, ) I1.

i; uatri x

Appen(lix ,3-

The top-down error corr©otlrat, I-tar.; er 1I1'

". 1 . Appendix 4- The simple prectActiot: error

NOTATIONS

A an

A= (a I P(a) }

aEA

ACB

AlB

AVB

a)p(a)

AXR

P: A --+ A

L

r, - (N, T, P, S)

y

ft :A . --º (X

rr1

1.115

Tills

T+

E

ksýý,

the set A has elements a,, a2, ... an"

A is the set of all elements a which

have the property p, i. e. p(a) is 'True'.

a belongs to A

all elements of A belong to B

the set of all common elements of the sets A and B

the union of the sets A and B

ithere exists a such that p(a) is "'True'.

the set of all pairs (a, b), where ae A,

and b GB

the empty set

f is a map from A to B

implies. Often this symbol is used in this

thesis to denote a relation between strings,

defined in section 2.1.

usually denotes a language

notation defined in section 2.1. G stands for

grammar, N stands for nontt: rminsl a] 1)hehet,

T stands for terminal a] phf bet, Pis the set

of all productions of the týrnmrniir G, tAnd S

denotes tho sentence meta: +yrnbo1.

V denotes the set of all 3yrnbo] s, 3 . e.. V= NVT

the production rT is A --s (x

is the i-t)i production of l'

left hand side (of the prn)chiction rc is A)

right hand side (of the pro, tuction if is ce )

denotes the set of all strings over the set

T, but nonexnpty.

Is the empty string (or the null el ernent for

concatenation) i

5

T is the. set of all strings over the alphabet

To i. e. T= T+v {t }

a, b, c,... usually denote characters from T

x, y, z,.. usually denote characters from V

u, v, w usually denote strings of T

r, oc, denote strings of V

has the same meaning as - -+ (symbol used

by Baohus of al. )

is the transitive closure of . -. iº defined

in section 2.1.

min f(a) the minimum of f(a)s for those values of

a that have property p.

? T-; 1'(9. x) N is the set of all subset., of the o et T

Gt=(It, Tso, z0, F) denotes a pushdovin autorw. ton, defined on

page 35

(º, IT , r', rQ, Sts,

is o, Z0, F) denotes e trra, naduoei. r e.: i; iociuttid vv. lth the

pushdown automaton 11, ,. Ul'irlud or, krage 52

is the stack a1pphabdt of it push, town automaton

is the output aiphabt, t o L' a fl'ü. ll: i, lll(; csr

I

i

6

I INTRODUCTION

I. I. 9TAT M NN OF 'PCE FRO MM

With the increasing use of computers the writing of computer programs

is becoming a time consuming and therefore expensive activity. Very

often a program . e., compi; ed five times before the . rat correct version

of it is obtained, Thi is particularly true in universities, where

many students are faced with their first program. It has been

observed r At, M2, L9_7 that a large peroenta; e of errors encountered

rsre very simple ones, like one insertion, one deletion, or one sub-

Htitution. Thus it beoorrLes possible to design schemes which correct

errors or provi. d, o,, good diagnostics.

11 Often the detected errors can be "corrected" in many ways, since

one cannot decide exactly what the user intended to say. In this

clº, 6e it 1a important to provide good diagnoatice, or sometimes to

i jut i cate all po3M. ble ways of correcting the error. The compiler

iw, it show which substrin, t(p. 13Videe. _i1y symbol) is 1. r, error, why there is

t1 ii error, and how this error can be corrected.

The process of using a computer for solving probat ms consists,

f i. mit of aUß in finding an agreed form of communication between the

(c, )mputer and the user. The problem must be 'sent' mad 'under: itood'

by computer. The need for coding informs tion anti it. i tri, nsmission

to the computer in obvious and has arisen ae a result of the exiitenoe

of computers themselves. The appear+tnoe of high-level progr inning

languages has solved the problem of coding for cornmunic, ttion in a

two-way man-machine channel.

Being developed for communication in a two-way chr, nne1, programming

1-tnguagea were not designed for error correction with is given error-

oorreoting capability, like error-correcting block codes ZP2, F5) for data

trtnsmieaion. Designers of ], angiw of did not consider the occurrence Sin(e m ms concepta)wxiich are defixiod Lately are used in this chapter,

the page where thie is done ie indicated in the paG"anthesia.

7 hkh-

of errors ill their &iesign . However they allow error detection, in

the sense that a message would be sent back to the programmer when

this detection takes placo. Tht'+ tw, )-w-iy communication channel is

more evident in an interactive system.

Receiving a list of errors the wer will correot them and send

the program back to the computer. Therefore it iz important that as

many errors as possible be detected in one pass. But often, after

detecting an error the compiler fails to detect some other errors,

or detects 'imaginary' errors. Take for example a FORTRAN program

in which the first DITJMNSXON statement is erroneous. This causes

many compilers to 'think' that alll statements containing arrays are

incorrect. It seems self-evident that a good compiler should always

correct an erroneous DIMENSION statement.

We say that a program is a correct version of aninput string (p. 18)

if this program ie, in some way, the most similar to the iput string.

It is difficult to say what should be understood by "the most similar".

Ah o very often the solution is not unique and it is impossible to

clhoose any one alternative by any criteria other than iirbitiia/ ones.

This impossibility of general error correction and the need for

tIiH detection of all or almost all errors leads us to the bo ncept of

error recovery. By error recovery one understands the removal of the

effect of a detected error and 'a

decision on how to continue to analyse

thh input string (p. 4.3).

Although a programming lie was designed without error-correction

in mind, it still contains enough redundancy to permit the detection

of almost all probable errors. At the same time the correction of

uunriy of them is possible.

All codes are constructed from basic symbols whjcli form their

alphabets. For programming 1anguage6 the alphabet consists of letters,

digits, and other special characters. However we can look at a

programming language in a different way, that is, as a stratified language.

8

Some words are built from the basin alphabet symbols. Statements

are then formed with these lexical words. The program is an ordered

sequence of statements.

At any one point in error correction one can only be concerned

with a epeotfic level or the programming language. At the level of

a compiler the lfie ýa

the set of all correct programs. At the

level of interpreter the language is the set of all correct statements.

At the level of a acanner the language is the set of all lexical words!

There gare four types \pf errors which we can find in a programs

lexical errors (ex. GOTU ilt3t©ad of GOTO)

syntax errore(ex. V2(5.5), not V2(5,5) )

. ', "- semma, ntio errors (ex. DIM V2(0) ) for a positive integer)

-, logical errors( ex. NEAT-8tra. texnetat on a wrong; line).

A programmer who does not know the intent of the user can correct the

ri rst three types of error. However many semantic errors can-be

corrected through his experience rather than using the syntax of the

11t1ºguh, ge itself. The information needed to correct lexical and

, iyntax errors is contained almost entirely in the syntax of the

B thtementa, and not of the program itself. The error:; which can be

corrected from the syntax of the program are only a few, and sorcu3 of

theirs very rarely happen.

Some methods to correct errors will be described ur developed in

thie thesis. Then the design of ar error col"1"ecLJ,,,, 1»1: c. ý" ýiiii be

i t' i ei, ted, and an implementation tp correct ei-ro ;,., t tho 'Level of

i�i, erp, i eter will be descrLbed.

9

1.2. THE MAIN PARTS Ors THE THESIS

This their treats the problem of error correction in a pro-

gramming language. Different error-correcting parsers are discussed

and used to design an error correcting parser for BASIC.

Existing work in this area will be discussed and all notions

used in this thesis will be briefly defined. As seen this first

chapter states the-problem of error correction, and its importance

to programming.

The second-chapter d$. ocussee the background field of this thesis.

The notion of a context-free language, introduced by Chomsky (1956)

C2J, and Naolcus at al (for the purpose of studying a programming

language) (1960) L M, N22, in defined here. The problem of sentence

recognition and parsing are also presented. Then some important

prnryers are d®sorlbed. Only a few among many existing p tr; 1W schemes for

dI fferent subolassee, or for the entire class of c ontezt-free languages

I,,. ve been included. The choice was restricted to all those parsers

which are used or referred to in the latter pert of the thesis.

t: ItKpter Two ends with the definition of finite state w, ehinee and

pushdown automata, as reeognizera for regular languxger+, or context-

t'rde 1nr ges, respectively. Also the notion of h t. rnn8ducer is

d of ined .

The third chapter introduces the problem of error correction in

a more formal way. First one defines (nectioýn 3.1) the notion of

error, the edit operation as an action to correct the error, and the

distance between two strings. Ten, based on this distance, the

correction of an arbitrary string is defined. AAJ. 1..,. ) u) Mio im ti . 1, y thi correction

of an arbitrary string w is defined, it is imderiinr+d in many places

iýl an this thesis!, that w tn practice is not sn erI UýOL

version of an initially correct sentence. After all we are studying

the problem of oom inication in the ºnan-machine channel, and we are

10

interested iii decoding algoritlui, s f', wr Ineaningt'ul iizf'ormation.

Section 3-3- is a survey of thy: literature in the field of errpr

correction for diffei-erst claw os of 1LU1 uagus.

The riiain results of this thesi., are prese4ited in the fourth chapter.

They open the possibility for the dosieri of a global top-down error

correcting parier. This design will be done for the BASIC language in

the fifth chapter.

The first section of chapter four presents, üriefly, error correction

iq a transducer. This is a limited correotion, of on7 y anticipated errors.

Section "2. prasente error co. iTeotian in a reFular larrguago(p. 34. ).

Although a progrsmixig language is iiot usually recuJer, many parts of

1 t, oen be desorlbed by regular grauuuar.

The neat two sections contain the most imlportfu, t results of the

L.,,.;; is. A global simple precedenoe parser ie given ißt su& tion 4.3. aria

, , ]. oba1 top-doom eri"o v correoting parser for, the w itire class of

iiLe L flee 1l1 uag; is its presented ii, st cti, )n The erryr covrecti. i1r,

ýýx3 are called g oba. J. einte the,,, anta_lyse the (soiAe, xt ui' the Whole

i ttt string in order to deoidd how to col-reut Lh (rro, '. Tit- 61_oba. 1. Loýl -

-,. tt tl. t'ror Cot rectin(', parebr is t Ld res, 11L of the Eiob. tJ

. , i-. j. 11Lo tL11 �i i'k)1' ý:, ýi'1'c:.:,. lYlg JhL'SC. ýý, wtl paruer ini: roduoed by Unger '

For both error t: oi'rciotiiig parý,. rs Utetttioneo r, tý , ye tl, 'j pv,,: dss of

ý, ý. 7': ot tst, iý1 iytti: 3b" ,. t -i uurrecLion doa. j not haJpe1' t11,, wa lysi.: of

U,, 1.1, j-f. i'ser$ can be 'viewed as hav1il(; two utou, iB 1., s i I'. ittr, d by Ltiv'y / fj ý

, .' in `G2, L6J ): a "staJidard iuodd" used Yo. i' the a,, alyai, s of

(;,, ifact sentanoes., and an "error coi-recL. irlp, u, l , '" I'tlr, ; Lwidat-d Inokle

j,, ', )etlt;, 1s at the same speed as the original 1-ur'Seir r, w arialysirrg any

il, 1 L : string anti], the dutuotion of at ie: t olio UIT11'.

Thu global 6A 'c r euur1'ec: tint; [)FIr:, 0r V) i' a 8-i llli Ju J_lu'EuL1iýb

u.. i uuý1s the idoa of (; ondeni<; irig tho . uriv u11; iiitg eon t. t. , _L of Ll, d urxor

11

hhh. -

to acquire more information needed for correction (see Graham and

RrLodes r G22 ), fiere the context of the whole string is analysed

and condensed by a "scanning phase" that is equivalent to the

"s3tandard mode" of the parsing prooesti mentioned above. It soana

the input string character by ohr+racter, detects simple phraseq,

aM reduces them to the ; orresponding metasylnbols(p13)It also detects

and reports the errors, marking the detection points of the errors on

the etack(pj2 If no errors are detected, this phase terminatos with

a complete analysing of the corresponding sentence,

If errors are detected, the error correction mode is entered

Hr'tar the whole input string has been scanned, condensed, and the

reduced version. of, the i. mput string has been stored in the stack.

it analyses the contents of the stack, which n(-, w cont, -iins all the

. iºformation available from the input : string, Krad makes t dec. L: ýio, l

, ii,., »it how to correct the errors.

While the global top-down error correotinj; parser Is valid for

: +iiy programming language, the global pimple pr©oedenc, - error correcting

!, xser is not, since not all programming languages R r, a : pimple prricedence

t -, nguagee.

Sometimes a programming language can be tr"anyfortacd into t+ Himple

precedence language by a ouitable change of

if this is possible, clearly the globril simple pr"cedniinsi error-

correcting parser can be used. Otherývise the j,, dob. d e]Tor

..,, i renting parser, which is not ver"j ert'i ei --r, t, ruin t, be uh,: d.

1. hvertheleLs its eff'ic; ienc, y can be imf, i"uvad by eomi, mintl it with

�I. her, more efficient parsers. This is invest. iKatL t iii the i fifth

, "t, apti: r, where an error cat rccting �ari r for ßAC 1 ý, L: 1vä. 1 E', i ed and

.. _ij(: u; 3&d. Finally the last chapter lool(5 back at th j)II. )I, lei1i8 treated in

thl. e thesis, rna1dri some Suggestions for fut ua"& wo vi.. ktuo the entire

i roblew is briefly ]ooked at f, u rn a totally . jif'f'ej"h,, t but broader point

'i1' View.

12

CHAPTER II

BASIC DEFINITIONS

2.1. CONTEXT FRFiE LANGUAGES

In order to study programming languages, a theoretical model for these

languages is necessary. It is not intended to present here the entire

theory of formal languages, Since the class of context-free languages

introduced by Chomsky , 027 isa Oonvanient model, genurai ly accepted, the

discussion will be restricted to this class.

An alphabet x is a finite nonc^empty set of elements which we cal .4

eii tl, er symbols or terminaL3. Any finite sequence

al a2 .. & n

of symbols is called a string. n is the length of the string. We

denote by E the, empty string, i. e. the string of length zero. The set

of all strings of nonzero length is denoted by T and T*Q Tu{E}

ito the set of all strings over ý+ .A language with the t iphabet T

is a subset of T. We need a finite procedure to specify this subset.

A context-free grammar G is a quadruple (N, T, P, S) where

-N is a finite set of metasymbols called nonterminals or variables

-T is the alphabet of the language. V=NvP is called

the vocabulary.

-S is a "distinguished" metasyrnbol, called ce tenoh iuetasymbol/? 7.

-P is a finite set of productions. A producti_oti is nn ordered pair

(A, lX ), AEN' of GV. It means that in buy string over

V, the nonterminal A can be replaced by the s trind rX . Often it

1. i denoted by A ----s pC and sometimes is celled ai ewritint rule.

In bottom-up parsing we reduce the string oc to the vhriable A, thus to

any production (A ' oc' ) there corresponds a rsduction rule 0C (---- A.

We say that A is the left hand side (LH ), and (X is the right hand

side (RHS) of this production.

Once we have defined the grammar. G, we must show how it can be used

to generate the language. First we show how the produotiorD can be used

13

to derive some new strings from existing ones.

For a given grammar G we define a relation over V

We say that the strirn oc e V+ directly produces the string

¬V, and write (X if there are some strings

r1, r2 ¬V, find a nontermina]. A such that

CC " rx\ A r2

p r, 1 r2,

and (A , 7) is a produotlon. We also say that p directly reduces

to CC , and write OC . Note that for any produotio-O A -º

we have A If the grammar G is properly agreed we

write ===--> instead of

We say that Gl' produces and write rx or reduces

to OC , and write ý-- - OC, if there exists an inter; ur n, n ýw 1

firm a sequence of direct derivations

an oco Dry a2... = oc t- p. wo say that oc if OC ±ý ýfý " or if DC 75

We are able now to define the language generated by the grtimmar G

A : +tring produced by the distinguished metasymbol 3 is cealled it

i ntential form. A sentence is a sentential form conbisting only of

riontenninals. The language L(G), generated by the grammar G, is

the set of all sentences, i. e.

L(f3 )o {w Sý- watdwe 7r*} (2.1.2)

A phrase of a sentential form a is a substring w that can be

generated by a variable. More formally, if oc s , 51 rj 1; ý2 is a sentential

form, ý is a phrase of pC if there exists a mettisymbol A such that

>, A t32 ' and A --ý-, ý ºý .A phrase is call ud a simple phrase

if it is a right hand side of a production.

The purpose of having a grammar is to describe a language. All

produotions in the gru nar are expected to be useful, i. e. to help in the

derivation of at least one sentence. In addition, we would like to have

a minimum number of productions, For example a production A --s A

1 Ll.

replaces the metaiymboi A by itself and is useless in the sense that

a new grammar, without this production, generates the same language.

It is known that for any context-free grammar there exists an

equivalent context-free grammar which is 8 -free LG. 2. Two grammars

are equivalent if they both generate the same laxi; uaae. A grammar is

said to be E-free, if thýr® is no produotion of the form A ----ý

We will casumo that all our grammars are 6 -free.

Also wo. W ,U require that all grammars are reduced. This is impor..

tant when we analyse a sentence in our language. If a variable, A does

not generate a phrase, thie, vart. able does not appear in the derivation

of any sentenoe, ", a lt Is futile to try to reduce a phrase to A. A

context free gr+ iiar G(N,, T, P, S) is said to be reduced

if for any variable, ACN the following conditions holds

1) there exists a sentential form that contains A, i. e. there

exists some Str ngo CC, 43 6V and the derivation

s -4 «A13 . 2) the nontezmina]. A generates at least one terminal string, i. e.

there is a string wET such that A- -}--> w.

3) the derivation AA is not possible.

Finally one needs to mention that for each nonterminM]. A of the

,; r -romar G there exists a grammar GA CN, T, p, A) aeaociated with

it. The grammar G is reduced if all 1anguage. s LA 3L( tjA ) are

nonempty and the sentences of JVA are phrases in L.

15

2.2. THE PARSING PROBLEM

For a given language L (grammar G), an important problem is to

discover if an arbitrary string w ET is a sentence of L.

According to the previous definitions, w in a sentence of L if it

is possible to form the sequence of direct derivations

(2.2.1) s_ ixo* aq 11

ßi2 cýý ... din We

The process of obtaining this sequence of direct derivations is called

parsing. We can batter illustrate this sequence of derivations by a

Hyntax tree. The, root of this tree is the distinquished metabymbol 3.

To each derivation ai Oci*1 there corresponds a produotion A --0

that has been used to replace the variable A In aci by 11

(Compare with 2. t. 1). Correspondingly, there exists a node in the

Hyntax tree labelled Aw , th the desoendente labelled, from left to right

11 , x2 , ... , %1 , where

"zl720. "xl " Let ue for example, ooneider the grammar

0a( {oum., . 4} ,

{a ,+9*},

P, s1 ß)

where

Pm{ ýt1A1-* B4 @um - -º faQ + eilt ? ASr -" a, fac --s a* fag }0

: ýi roe

9WM-*. 9+M"0, a+ 'P a+fag=a+a* f40? a+a*a 0(2.2.2

holde, a+ a* a is a sentence and K11 other interm#-d Late Htringe are

: sentential forms. The syntax tree of the eentenial form fac, + sum is

I; iven in fig. 2.2.1a and the syntax tree of the sentence a+ a* a is

;; Ivan in fig. 2.2.1b.

&UMM

/N Aum

a)

t'om'

ra. tao

a Fig. 2.2.1

16

The sequence of derivations of the sentence a+ a* a is not unique.

The following sequence of derivations

eum fao+eum ,P +fac; _;, fao+a*fag=4 fA9+a*a a+ a* a

Fi1so holds. (2b2.3)

But in our case, both derivations (2.2.2) or (2.2.3) have the same syntax

tree shown in fig. 2.2. kb.

Neverthele©s,, therei'are languages which have two different syntax

trees for the same sentence. Such a language is called ambiguous.

In any unambiguous lang uai3e there exists exactly one syntax tree for each

eentenoe. With this we Associate a canonical derivation, from many

possible derivation of the eentenoe w. -The derivation

is canonical if each direct derivation oxi = oci+1 , is obtained by

rdplacing the leftmost metmeymbol of the sentential form Oci " That is,

oc iuR d3 , Oc 1+1 to u where u is a terminal string and

A --* is la

production.

There are different methods of parsing a sentence. If we try to

h, tald the syntax tree of the sentence w starting fron the root S,

icing downwards towards w, we have top-down parsing. If we start

with the sentence* w and try to make reductions to arrive to S, i. e.

going upwards in the syntax tree, we have bottom-up phruing. Almost

all parsing methods are left-to-right since the Nyrnbol. 3 in the sentence

w are read from left to right. Often both methods of par, iing are

: otnbined to obtain a more efficient scheme.

Some parsinc methodß are presented in the mxt paragraphs since we

neHd to use or refer to them.

17

2.3. AN EFFICII! NT PARSING ALGORITHM MR CONTEXT". FRP LANGUAGES

Here we intend to present briefly some algorithms for parsing some

classes of context-free languages. The first, due to Earley (Ei JP

is the most genera, and efficient one, for the class of all context-free

languages.

We assume the, productions in our grammar G are numbered from

1 to n. We add a now terminal symbol q4L to mark the and of each

sentence, anew distinguished metaoymbol So and the production number Os

0 944 We often need to examine those productions with the same LHS. Vie say

that a production with the variable A on its LES is an A-production.

Let wna a2 ... %r,; 46 be the input string to be analysed. The deri-

vation of the string w must start with 80 +S Then an 0. -

production must be-chosen to continue the derivation. Normally we choose

the first one. If we fail, we try to use the second 3-production, then

tt, e third, and soon, until we succeed in finding a derivation. Earley's

7+ 1 E; oitthm tries to eliminate backtracking, by keeping till possible syntax

trees for the previously analysed eubstring a1 a2 ... ai . It builds

lists of states for each 3. =o, 1,... ,n. A suite in the list

Li is a 3-tuple '(j ,1, IL ), where j denotes the yank of production

concerned, I is a pointer in this production (o . 1. j_j , where

. ºj is the length of the PM of j-th production), and k is a number

ehowing the position in the input string w, where the production number

j begins to be considered. If I= 1i , the state (j, j. , 1t ) is

called a final state. It means that all symbols in the RES of production

j have been successfully matched against a phrase in the string w.

Each list Li is built by three operationst : SCANNER, PREDICTOR, and

COMPLETER. Their actions are shown below .

We illustrate this method by an example, and then describe it by a

concise algorithm.

18

LeSt us consider the grammar G with the following produotiones

no $ root ----y list 94

TC1 list ---ý array

T(2 t . ist ----i array , list

7T3 $ array ----s var ( intg , intg )

f4 i array', =----ý var ( intg )

TC t var 4

A

ri . rk. s vai

. W7 3 'PAntg :, 4

T', i t intg .-. n. - i ý. . ntg

and the sotaz

11 ý+ { i0ot ' 1iit array , var 0 intg}

T

Let us try to parse the otr-Ing a ., A(1 .t) 44

. ýýý .

r ý, µ

All syntax trees must begin with the root, i. e. with the tree from

fig. 2.3.1a. Thua the state (o ,o, o) riet be ix, the list Lo

a. t. jjce the production concerned is the production Ro , and we have not

m<itched anything yet. More intuitively, this state its denoted by a

pointer in the produotion ? top and the number i, derived from the

list Lt (i. e. i' in a pointer in the input etrinW, d i. note(i by a full atop) :

1) root --w--o " list 944 200i. e. (o ,o00).

We can "predict" now that a Ust-produotion Inuit be used, and thug the

states

2) list ý.. ýj� , array so, i. e. (1, o, o)

3) list a. . array , list so, i. e. (2, o, o)

rdpresented by fig. 2.3. ß, b, must be added to list Lo . These two steps

combined, give the possible syntax trees represented in fig. 2.3.1o.

We can predict now'(see fie. 2.3.10) that an y-produotion murrt be

used, and, the etataa

19

I

root

list

ý; ýqnt

, r.

root

list IN

tM"tly ýý; ý, '

list hat

array array ' list (b)

n4+

root

" :: ý

-ý, ý

array

array

i vt/r ( i1tg intg ,)

(d)

var

A

var

(e) V

array

var ( intg

Fi, Z . 2.3.1. I

20

p 118r.

4) array var ( intg , intg) so, Lee (3 ,o, o) "

5) array .r_., . var ( intg) :0, i. e. (4, o, o) ,

must be added to Lo . Finally the states

6) var-.. --. ý. 6 :o, i. e. (5 o. o),

7) var --.. ý-. ý. Al :0, i. e. (6 ,o, o) ,

must be added (in the acne "predictive" way) to Lo.

We acan. now the first symbol A of the string w and we look for

estates with A immediately--after the pointer. If we find one, we must

move the pointer one position to the right since we have matched t his

symbol with the symbol immediately after the pointer in the right hand

side of that production. Since we hive scanned the f iret symbol in the

string, the list is formed. In our oeee, theatatee

8) var . ý. ý.. _. p A.: o, i. e. (5,1, o)

91v&r ----s A. 1 S09i. e. (6,1,0 )

neigt be added to L,.

:ji rice 8) is a final otate, i. e. the whole RDS of the produotion IT5 has

lhuen matched against a phrase of the string w, all states in Lo with

vrtr immediately after the pointer, must be added to L1 with the pointer

moved one position to the right, to iidicate that var has been completely

used. Thus we "complete" the lint I, 3 with the states

10ý array var .( intg , intg )soo)

11) array ---.... var oý ( intg o, i. e. (i, 1, o

There are no other final states in I, therefore the list L1 is complete.

't'here is no variable, immediately after the pointer, Iii any state of L1,

thus the prediction phase does not add other states to LI.

We scan now the next symbol "(" and try to matcti it with the symbol

after the pointer in the states of LI . The mr, tah is successful for the

stetes J0) and 11) and "the scanner" adds the states

12) arrayý. ý. ý var (. intg , intg) s o, i. e. (3 ,2, o)

13) array ---ý var ( intg ioli. e. (4,2, o)

to L2 . These are not final states, thus the completer cannot act.

21

But the variable intg occurs immediately after the pointer, and we

"predict" that all intg-productions can be used ißt this stage. The

states

14) intg 2, i. e. (7 ,o, 2)

15) intg . ---a. .1 intg : 2, i. e. (8 ,o, 2)

must be added to L2 ; There are no other states that can be added to L2.

The next symbol to be scanned is a3 .. "1" . The "scanner" adds

the states

1.6) intg ---,., :2, i. e (7 ,1,2) .ý

17) intg ----. ý, 1. intg :2, i. e. (ß , -1 ,2)

to L3 . The state 46) is a final one. The production Ir7 used in

et! ita 16) has bean initiated in list L2 . Therefore all states from

L2 with intg immediately after the pointer, must be added to L3 with

the pointer moved one position to the right. Thus the states

IA) ar. ray .. --, var (intg ., in tg)io, i. e. (3

,3,0)

19) array -----º var (intg .): o, i. e. (4

,3, o) ,

inii: it be added to L3. State 17) has the metaoymbol LnýZ after the

pointer, thus the "predictor" taust add the states

20) intg ----r .113, i. e. (7 ,o, 3)

21. ) intg ---+ .1 intg :3, i. e. (8 ,o, 3)

to L3 . There are no other states that can be added to L3.

The next symbol to be scanned is a "1". The "scnnner" adds

the State8

22) intg ----! ý I. t3 3

23) intg -----t 1. intg 13, i"e. (H ,1 ,3

to L4. State 22) i: i a final one, the "compl-: ter" must add the state

24) intg --. ---: 1 intg .i2 2 ,2

to L4 . This again is a final state, carried from the list L2, thus

all stat es in L2 with intg immediately after the poin ter must be added

to L4 with the pointer moved one position to the right. They are:

22

25) arrary --=r var ( intg ., intg ): o, i. e. (3 ,3, o)

26) array var ( intg .)$o, i. e. (4,3o).

Since the state 23) contains the variable int immediately after the

pointer, the predictor adds to L4 the following states

27) intg ---ý-ý . 1. :4, i"e" (7 ,o, 4)

28) intg intg =4, i. e. (a ,o, 4) .

No other states can be added to L4.

We scan now the symbol a5 and the "scanner" adds the state

29) array ------' var I( intg .so, i. e. (4,4.9 o)

to L5 . This is a final state "carried" from Lo , thus the completer

must add the states

30) list ----. a- array .1o, i. e. (1 ,1, o)

31) list -----ý array . list :o, i. e. (2,1, o)

to L5 p' Since 30) is a final state the "completer" adds the following

8 tate

32) root -----I list . 944 :00i. e, (o ,1, o)

to L5 . There are no other states that can be added to L5.

Finally the last symbol a6 is scanned. The state

33) root -----ý list 4.: 0i. e. (o, 2, o

usu. +t be added to L6 . The presence of this state in L6 shows that

the string w is a correct sentence, since the root-production has been

completely matched against lt.

We must now build the syntax tree for w. Note that a final state

mhowe that a simple phrase can be generated by the correspording production.

We must search backward through all the information stored in these states,

! trod keep only the final states encountered. The synta . trea . rs, ý be seem in

Fig. 2,3.4.

23

To do this, we need some link pointers between states. In the

prooess of forming the list of states, a new state 8 was added by

"scanner", "predictor" or "completer", starting from a previously existing

state q (and q1 there are two states in the completing steps).

Thus , the state s must have a, pointer to the state q, if 0 was

obtained by the "soanner" from q. , or two pointers if e was obtained

by the completer, the trat one to the final state q, the second one

to the other state. The ], ist of all states, for our example, together

with these link pointers, can be seen in fig. 2.3,2.

We maust start with state (0,2,0 )(in our example, state 33),

store all states to which there is a pointer, and retain only the final

states to form the syntax tree of the eentenoe.

This process is ®et out in fig. 2.3.3.

The parsing algorithm for the input string

w= at a2 .* as 44

I ti the language generated by a context free grammar Q with the prod..

m-ttons CCM s Ai }x(ý) ZJ)

... xis) ,j=1,2, ... , n,

ii ud

i . LL 77- 0 is Tr os root ý--} º3

A) The racognizers

a) At the beginning all liste Li tire empty. Add the state

(0 ,0; 0) to L

b) For im0 to n and for each state, am(j, I, is ) in Li,

execute the following steps, until no other etitee can be added

to Li:

1) Predictor: If is is nonftnal and x ('j)

is « nonterminal, 0)

then for each . -produot: Lon Tft , add tim state (t00, i)

to Zi.

24

The input strings w. A(1.1 )

State Intuitive description of Pointers the etrnte due to

list L o 1) ( 0 , 0, 0 root . list 94 $ 0

2) ( 1 1 9 9 , list . array $ 0

3) ( 2 , 0, 0) list . array , list s 0

4) ( 3 , 0, 0 array . var ( Intg , intg )s 0

5) ( 4 , 0, 0) array . var (intg) s 0

6) ( 5 , 0", 0) var .A s 0

7) ( 6 , 0, 0) var . A1 s 0

1.1. e r, I, 1 aý = A

E3) ( 5 1 0) var A. s 0 scanner6) , , 9) ( 6 , 1, 0) var A. 1 $ 0 scanner7)

10) ( 3 , 1, 0 array var .( intg , intg ): 0 completer 8) 4)

11) ( 4 , 1, 0 array var .( intg s 0 completer 8) 5)

Lint L2 : 4

a2 = (

L2) ( 3 , 2, 0 array var (. intg , intg )s 0 scanner 10)

1.3) ( 4 , 2, 0 array var (. intg s 0 scanner 11)

14) ( 7 , 0, 2 intg .1 : 2

L5) ( 8 , 0, 2) intg .1 intg : 2

llA L, : a3 a 1

Ir) ( 7 , 1, 2 intg 1. s ? scanner 14)

1'l) ( 8 , 1, 2 intg 1 intg s 2 scanner 15)

1i) ( 3 , 3, 0 array var ( intg ., i. ntg ): completer 16) 12)

19) ( 4 , 3, 0 array var ( intg . completer 16) 13)

20) ( 7 , 0, 3) tntg .1 : 3

21) ( 8 , 0, 3 intg .I intg : 3

l ß: 4t L4 a4 = 1

2, '') ( 7 , 1, 3) intg 1. .i act, uxier 20)

2'5) ( 8 , 1, 3 intg 1. intg : 3 ecHnner 21)

q) ( 8 , 2, 2 intg 1 intg completer 22) 17)

2', ) ( 3 , 3, 0 array var ( i. ntg ., intg ): 0 completer 24) 18)

26) ( 4 , 3, 0 array var ( intg . 0 completer 24) 13)

2'! ) ( 7 , 0, 4) intg .1 4

2t+) ( 8 , 0, 4 intg .1 in tg : I

liyt Lr_ : a5 )

29) ( 4 , 4, 0 array var ( intg) . : o sctnner 26)

'0) ( 1 , 1, 0 list array . : 0 completer 29) 2)

31) ( 2 ' ]. , 0 list array ., list 0 completer 29) 3)

32) ( 0 . 1. 0 root list .A 0 completer 30) 1) linst L6 : a6 = 444

33) ( 0 , 2, 0 root list e. $ 0 scanner 32)

Fi. a. 2. i.?. 25

The current examined state This state was It hbs link The next states Number intuitive representation formed by pointers to to be examined

(33) root list ;{ s 0 scanner 32) 32)

32) root list 0 completer 30) 1) 30) 1) (30) list array . : 0 completer 29) 2) 29) 2) 1) (29) array var ( intg . t 0 scttnne. r 26) 26) 2) 1)

26) array var ( intg .) : 0 completer 24) 13) 24) 13) 2) 1ý (: 4) intg I intg . a 2 completer 22) 17) 22) 17) 2) 1) (22) intg 1. ý, 3 3 scanner 20) 20) 17) 13) 2) 20) intg .I s 3 predictor - 17) 13) 2) 1) 17) intg ]. . intg 3 2 scanner 15) 15) 13) 2) 1) i'; ) i. ntg .1 intg i 2 predictor - 13) 2) 1) 13) rray var (. intg) $ 0 scanner 11)

"' 11) 2) 1)

11) Firray var .( intbr ) : 0 completer 8) 5) 8) 5) 2) 1)

)s) vir A. 3 0 scanner 6) 6) 5) 2) 1) I)) var .A s 0 predictor - 5) 2) 1)

1) tirray , var ( intg $ 0 predictor - 2) 1) 1 i: st . array 3 0 predictor - 1)

1) root . list 46 : 0 -

Vie'. ý. ý.

var

111-16P 0-, a .50 J+

26

2) Completer.: If a is a filial Estate and j1, k1, t) is in L{

and Ai Rx 1)j0 then add the state (j1, k, ý+1,

t) to L1. Add

two link pointers, the first to a, and the second to

3) Scanner: If s is nonfinal and Xj+, is terminal, then if

x +ý,

+ ai+i, add the state (j, l+t, k) to L3+1. Add a link

pointer to the state s.

4) If Li+1 3. e empty, then reject the string*

a) If Ln+1 x{(0,2.0)) , then the atri. ng its a sentence in the

language.

B) or constructing the syntax tree of the sentence w, begin

with the state (o, 2''t o) ! Ln*j, oheek in order all states oonneoted

by ]ink pointers, and retain only the final states.

b

27

2.4. A GLOBAL TOP-DOWN PARSER

In a top-down parsing algorithm we must choose an 3-produotion with

which to start. Our target is the input string woa. a2 ... an A6 .

In the previous algorithm one input character 'a1' is read at a time.

Knowing a1 , some S-produotions can be eliminated. If, in some way,

we read the whole etri. n& w, it nlay be possible to decide whioh of the

S-productions mußt be chosen.

Unger (U22 has suggested euch an algorithm. Suppose that the

input string is wnabbcddef and the grammar has the produotions

IT $S-0. a 31 82d S3 f

21S -+. adS2B

rr3 :S --,. b s2

1r4 : S2 -º b

n'5: S2 cd

lr6: S3-te

R7 : 33 ---. aSj.

1 Iah S-production T(j :30a8j 32 d S3 f is na n t11y the f irut

choice. The the first character 'a' of this : 3-production matches the

iir t input symbol, 'f' matches the last one, S1 52 lfluwt he tentatively

witched against bbo or bbcd (since we do not. know which one of

Lio. ie two input characters 'd' , oorraepondy to 'd' in the right hhrid

:ihIe of the production rri), rind : 33 mußt match de, or e, reepectj_v e. ]_y.

We define an A-phraee as a phra: ie that crtn bi ci wi ved from the

tiutttanainal A, i. e. p( is an A-phraye if A --0-4 Dc .

We need to match S, 1 32 against bb c. For doing this, the

. -itrine; bbc must be decomposed into two sub, itrti i ik, +tnd cX2 euch

tlittt a1 is an $, -phrase and cx2 is an 32 phraHe. There quay be

many ways of doing this.

Since, even if we succeed in matching S1 S2 aL; nLnet bbc there

is the possibility of failing to match the rest of the string against

the rest of th-+ right hand aide of the production rr , we need a

28

.ý.

strategy to chock all ways of obtaining a derivation of the

e tring. We assume that the productions of our grammar are ordered, and all

A-productions are arranged consecutively for any metasymbol A. Cex athly

this can be done for any context frae grammar.

At any stage of the parsing process the important pnob3. eon which

we face is that of deoid. ing if a &Lveu terminal string is an A-phrase.

We need. a procedure which ° ariewers thin question and gtveix the detivatthn

I, Aa. (2.4.. 1) We are grin to describe the pr"oaedure PI . A$E(A, Cc 9R). This

procedure reaoMl: ie3 it CC is an Ar-phrase. It is a logi. I variable

which is "Prue' . i. ` CC it an A-phr"as e, and 'False' JS OC is not an

Jº-Fahraa Ia.

Let

Tr (A,, i1a ?_ Li ]. Ii+1

the i-rth A. pzorluction, ý. 1,2ý ... , nA, where u(-' are tenninal

h 1. ringe, poAeibly empty� and Aj rare metasymbols. F

We neod to ohootse one of these productions to nCart the derivation

'. 4.1). For doing this we check a. 11 A-produot. ion.. in order, and for

h: teh one it must be verVied if the right hiiid aid4 of the production

ri (A, i) can match the string (X , If the strijigs u('' , j=1,2, ... ,

u: +1, do not find the identical correspondent substr. iu ;e in the string

OL , then the production IT(Ai) n, ur, t be r. ̀ejuotdd. uutheiwi: 3e the

i Iring pX is deaomponed into eubafrri ngs,

oý ffi uW CXýý'ýuý 'ý a(i)... cx W i)1,

2iii

to Id ocaý i) must be aii&1. ysec1 as A(')-phrases. There can be more than

29 z

U11C: Ula: Vli! 'ý,,,.. 1ý1. 'ýrl `, " ."f hi'ý. L U:.. `iuiJitj to

all of' tic,.., ü: uý . _ý'ruc y. I �er jUý; t _. l e c. at ! c':. ositi or:

of yU Mü

Jalust llavc; tiiu at ! _r:

< u t-, itar; ii. eu. aru of L; aI.

Aý1"-'. l': r'C, ue. (KC, _i3!: t)erg n-, --L our 1iJ, I1' "LY"H uo7"! 51ir-, 1' ti -l"=''tee).

If £111 1ýVt t11e: LT' --Erlj? ll.: "ý : St L!

` tf: c:: 1 Uý

vv

m ust have its _Lun,

'th 'It iC: )i:; t ii\yý wl (1. ý U( 7 L. 'pL1ý" Ort:, Y! ut

satisfyi-ri` oe re, euttiu.

Sir- Cf Ll i

1, lt`; t ÜC Ji f` , f. " fJ, f

we neeu to R), . i. e. the stibnouti: _c

I t.

is used reenzr iv,! ly. A i'lw: ; fl'. rt foi' this suurout _ý, (: c'. rl r, c; io. fii(_'

in fie;.. %;. 1

i i)

PZAsJ (A, GC,. t)

i: 1 k .-1

i : =i+1

Find the production 1c(A, i) : A, u1A1 u2A2.. "u1A1u1+1

No s there

e, decomposition n, No Aa: o(_uI a1 u2a2 . ulalul

to match this Al production

R: =

Yea

, __I es

Exit

No .- min(1- 1 , k) ß

Yes

I in ZJ r_; er econ, noBition

vri t: Z al' ,' e11

rumrLn uruni: n, -,,,, -: b :t the nevi rn%tch for A. be

"ýIonL, er t ,? n u

Fig. 2. x+. 1 Sý: cces

i1

1J "_ý-

-1

2.5. PARSING $II"TLLý PRECE DiNCL GRAM AR

For any grammar G=(N, T, P, S) with the vocabulary

V=NVT, the simple precedence relations .L> are'

defined for all pairs (x, y)sVXV, in the following way:

1) x_y if there is a production r[ EP, rr :A -- axy I3 ,

for some oc, c. V That is, the symbols x and y have the

same precedence if they appear adjacent in a RIM of a production.

This means that, in a sentential form with x and y adjacent, there

is the possibility that x and y can be reduced at the same timo.

2) x ...:: z y if there is a production A -. axB rz , and

there is a derivation Byr, for some cc, Is q rl E. V*.

That is, if x and y are adjacent in a sentential form, it is posrsible

that y and some consecutive characters on the right can be reduced first

to a variable B.

3) x>y if there is a production A ----, - %c. B C 13 ' and there

are the derivations B

Cy

for some strings OC , /3, -r ýe V* In other words, there

exists a sentential form s= cc1 oc txy rý 75 11, , such

that it is possible to reduce first i'x to B, then yT to C, to

obtain the sentential form p(1 aBC X13 p, i. e. x h: is precedence

over y, since it c: 3n be replaced in the sentential form s before y.

The grammar G is a simple precedence gram ar if

a) for all (x, y)eVXV, at most one precedence relation ho'3s,

i, e, it is I mown precisely which one of the symbols x and y must be

reduced first, if they appear consecutively in a sentential form.

b) there are no two productions in the gram it G with identical

right hand sides, i. e. any string can be reduced in at most one way.

c) the grammar is E. -free.

Ob AX B denotes th-, cartesia n pro : u.; t of the sets i,

32

It follows that a derivation k= ±ý A is impossible.

We choose a new terminal symbol to mark the beginning and the

end of the string, and for all xEV we define x, and

x ý. #. The parsing algorithm for a given string

W- 944 E, a2 ... an 9

uses a parsing stack. Initially this parsing stack contains the

symbol 744 , that is, the first input symbol. Let x denote the

topmost stack symbol. The parsing algorithm is:

1) Read the next input symbol ak . If ak is go to step 7.

2) If the relation between x and ak is < or A then go to step 5-

3) If the relation between x and ak is >, go to step 6.

4) There is no relation between x and ak. Output an error message

and stop.

5) Put the symbol ak on the stack (x: = ak ) , and go to step 1.

6) A simple phrase has been stacked. Its end is the topmost character

and all its characters are related by I. Find the production

for which its right hand side matches this simple phrase. Replace

this simple phrase in the stack, by the LBS of the corresponding

production. o to step 1.

If the stack contains S, then the string w ha; been recognised

as a sentence. Otherwise w is not a sentence.

The sequence of productions used for reducing the stick, Frives the

canonical derivation of w.

A flowchart for this algorithm can be found in section 4.;., fie. 4.3.3.

6

7 3

2.6. ACCDPTORä

A context-free language i: 3 charRcterized by the f. ct that its

sentences are those strings accepted by a pushdown automaton zZ"A 35, G1,7. Its

subclass of regular languages is the same as the class of languaLes

accepted by the family of finite state machines ZA3, sý%.

A regular lane ;e is a context-free language with -ill productions

of the form A»aB or Aoa, where a is a terminal symbol

and A and B are variables.

A finite-state rutchine (or finit D automaton) is a sy;: ter N=

K, T, J, so , F) where

-K is it finite nonempty set of states

-T is filºito input '-'lptlLbot

- So EKi:; the initial st., tte

-FcK is a set of final states and

- cr is a transition function : iefined as follows:

a) d: K. XT --> K, and the finite-state machine is

called a deterministic finite-stete machine.

b) d: K )(T s 2K , and the finite-state machine is

called a nondeterministic finite 3 trite nipc'-uine.

The tr'. nsition function d can be ext f: 'i ' for 1' xTk, ü

follows: ý(nfL)=C.

o(cy wu; = a( ý(q

,wi, a, s

for all states all ir_put symbol., 3ET' : nd for in ; ., trig

wET

The set of stririCc accepted by a determ nistic filitP to, t .A }li. ,e

M is

T(1: )_ {w eT*i cj( so ,w )EF }.

The set of strings accepted by a nonletermirdstic finite-st, lte Lrxtchine

M is

io , 34-

It can be proved CF3, G1] that the of these two sets

are identical, i. e. each set accepted by a deterministic finite state , .. �ý

is accepte i by a nondetermü: istic finite st-_tte machin, " ýiric? 'conversely.

An important resist r All , s; J is th'it a las uý}ýe iu regular if

and only if it is accepted by a finite state machine.

A pushdown omaton ( p"d. F. ) is a system M=(K, T, r, a, so, zo, F), tivhere

-K, T, F «nd so have the game meaning as above

-r is a finite alphabet called the stack alphabet

- z0 E j' is the initial stack symbol

- the tI L: isition function S is defined as

J: KXTExF ---! P. 2K xr where T, = Tv{ E} and T is the fsrsily of all subsets of

the eet D.

Intuitively, a P. a.: t. can be described as in f'if-;. ý'. .1.

aa... a ... a input type 2i -

n1

scanning device

.. pushdown ^taCk finite

stete qýL top of control

k the stack

bottom of Lo 1 the s; tack

p" ý, 1

At each moment the st+nte of the p. d. a.. auto mr ton i. a -precisely deý, cr? bed

by the state q of the finite state control, the position of the

scanning device on the input tape and the stack i= Zk Zk ... Zo

These three elements fora the confiCurat on (oja of

the pda at that moment.

We say that (q' a) ,Z i' ) `--- (p --1 r) iff

cr pEý ý'1) (q, a, Z The relation ý--- is the symmetric

transitive closure of ýý .

Ja

The language accepted by the p. d. a. M_ by the final st'. te is

for some cP}

The lar, uaoe accepted by the p. d. a. M by emptied stack is

M)_{wI E. , w, Zo)

An important result is that a language is context-free if and only,

if it is accepted by a pushdown automaton by final state (or by emptied

stack).

Because these automata accept the strings in their corresponding

languages, they are called acceptors (or recognizers). They can be

transformed into transducers, which permit one to obtain a very

efficient parsing algorithm.

A pushdown transducer is a pushdown automaton which hn. s an output

facility. Formally defined a pushdown transducer is a system

(gT, so ,0, F) , where

-KIT ,F, so, Zo , and F have the same meaning as in the

definition of the pushdown automata

-Q is a non-empty finite set of output symbols

- the transition function

dsKX Tt: Xr *P(x r *x )

has the property that J( n, a, z) is a set contnininn it

finite number of elements for any (c, a, z)c IK X T£ Xr.

Fora given p. d. a. K(K, T, F- td, so , z0 ,F) we say

that a pushdown transducer Mt=( jC ,T 1-

,A ý-t

,°e, Zo , F)

is associated with K if for each triple (n ,az6X

Tf x j- ,

we have 6 tPsr d( c, Y-/ý

{( p, r, Y )E

dt ( n' a' z

(see r0lJ). This means that if it is possible for the p, d. a+ to

change the configuration (n 9a, z) into (p, r) the same

change is possible for the pushdown transducer if we are not Lnter-: stec'

in the output.

Thus, the irport, tnt definitions ref*. irdi_ng context-free languages

and their acceptors have been presented. We will meet them ail in the

next sections of this thesis.

6

7 7

CHkPTER III

THE PROBLEM OF ERROR CORRECTION AND

A SURVEY OF PREVIOUS WORD:

3.1. THE DISTANCE B, TW P"N TWO STRINGS

Let o. and p be two strings over the same alphabet V9 ike.

cx = a1 a2 ... an ,

p= b1 b2 ... b

with aiEV, i2 ... ,a and biC V j2 ... ,m

Since we are going to define and study the problem of error correction

in a programming language, we need to measure the similarity between two

strings. For this purpose we shell define a distance between them.

In the process of communication between man and machine errors appear

as a result of misspelling of words, deleting or inserting of characters.

Some edit operations are needed to correct these errors. Formally an edit

operation is a pair (a, b) of characters hot both null , i. e.

(a9b)ý (E ,E)

(W 22. We say that the string 13 is obtained from

the string uc by performing the edit operation ew(a, b) if there are

two strings r,. , r2 E VE auch that

ýr, ar2,

and

f3 =r, br2.

We write [3 =et (X ).

We call the edit operation e-(a, b)a change operation if

aA60býE, and a ý- b. If a=b we prefer to call the edit opera-

tion (b9b) an (unchanging) empty operation since its effect is null when

it is performed (compare with Wagner Z7922). The edit operation ('b)

is called an insert operation and the edit operation (, a ' F- ) is called a

delete operation.

From statistical experience or from other considerations, with each

edit operation e=(a, b) we associate a weight (cost) u(e).

7,7,

Let S be a sequence of edit operations e1 , e2 , ... e that transform

the string Oc into the string j3 , i. e. 1= el(e1 _,

( ... e1 ; OC 1)

... ).

We define the weight (cost) of the sequence S by I

u(s;

There always exists a sequence S of edit operations, which transform

a string or, into the string /3 .A possible one is the following string

of delete operations and insert operations

( a, ' E) r( a2 s s ...

( an s )i (F

v bl )'( ¬' b2 )p... s(¬ 3 m) s

Let S (oc' ý3) be the set of all sequences of edit operations that tranzfcrm

the string Dc into the string; t3 . There is a weight associated with each

sequence SC-S( M, 13 ). We define the distance between the strings oc and

p as the minimum weight of such a sequence, i. e.

d(OC, )_ in u(S1.

SES ((x , /3) Let So be a sequence of edit operations such that

d ((X, 13) =u( So').

This sequence So shows us which characters in the string ()( have been dele-

ted, which characters have been inserted into the string p, and which

chracters ( ai , bi ) correspond one to another by change or empty opeý^a-

tions. We define a trace T between the string tic and correRpondine to

the sequence So. Intuitively the trace is the correspondence between the

characters ai - bj defined by the sequence So of edit operations, i. e. if

( ai ,bj) is in So then (i, j) C- T. Thus a trace T ((Y

between the strings CX and , is a set of pairs of w14;.

the foi1ovwin, 7 , ro, w --i . c.

1,1 'iG n' G II'

2) For any two pairs ( i1 , 3l. )' ('2 1 J2 ) E" T

a) i, =12 if and only if j1= j2.

b) if ii G i2 then ji j2 . 7r.

The weight (cost) of the trace is the weight of the corresponding

sequence of edit operations, i. e.

u(T). u(So). (3.1.3. )

Often we need to compute the distance d( rx , ý?, ) between the

strings OC and /3 " An algorithm for doing this can be found in Wagner (W2J.

Let did denote the distance between the strings

a, 1a2... ai,

and b1 b2 .,, bj 9

for o in ,o <_- jsm. Here the string ci c2 ... ck, for k=0

is considered to be the empty string E" Thus di is the weight (cost)

of deleting all characters a1, a2,..., ai , i. e. i

d4o u ((a k El )) k-ý,

and d091 is the cost of inserting all characters b1 , b2 , ... , bj , i. e.

do9i ut bj) )

and do90 = 0,

Then di+1 9 J+I can be computed according- to the formula:

do, i=

J+, = min ý di+1 sj+ub j+1

di+1 )),

di, 3+1 +u ai+1 ))s

dýrj +u( (a, +1 'b j+1

1,3 . '!..

(see (W22 ). In other words, the formula (3.1.4) su. ys that the stri. n,?

3(p919J +1) = b1 b2 ... bý+1

can be obtained from the string

S( ?C1.3+ý = al a2 ... ai+1

in one of the following three ways: 4

rl

a) the string S(p, 1, j) "" b1 b2 ... bi is obtained from

the string S( c' ,1, i+1 and the symbol bJ+l is inserted. In

this case the distance would be

di+1, j+u((E, bj )).

b) the string Sj+1) is obtained from the string

S(a, 1,1)= a1 a2 ... ai and the symbol a, +, is deleted. In

this case the distance would be di9j+1 +u(( ai+1 £)).

c) the string S( ,3,1, j) is obtained from the string

3( OC ,j, j), and the last character bJ+3 is obtained from the

last character ai*1 In this case the distance would be

di+1, j+1 +u(( ai+1 ' bj+1 )).

6

2,1

3.?. ri l.; PROtiLFIM OF ERROR CORRECT1011 'Y A PHHOCJAMMING

WR are r, - , rn©d in this Un-a . -in .; +, +nn trn. nnmj si_on of' ! nfr+rmn Lion

in a man-in ýý. ý, charnel. The, ,-'. u ', inn he : i_r: formrti. i. on in

properly coded, i. e. we RS8Ume tfl,,, t thp, progr. In is i. rliti.: til. y corrPcl.

But, between the E, rogrLmmer's min(' 'trig. the computer rnowory, rýorno orrorr:

occur. Sn h Prrors can happen w'-An ilht- progrrimmer hiliin 1f wri f, n'; hi. s

program on yelper, or when, furthn-r, 't'-r' , program is punched on rr rc; 4ý, rar

sent in any other way to the comp.. ter. Thus, although fate pi-op, c: inr

received by th#- computer is erroneous, it is an erronoou: i ver, H! ön or

correct pr

It wow.. ieful to study the stal : itioal behnvi_onr of stich R

channel. Some work in this direction can be found in Z7 `j -7 wht-re

Litecky and Ltav. L. { have studied the errors made by n groin o : 31,101,11ts

1earnini Col , rMvl the error di"a, >no81s given by the Cohol-(, (wipilpr.

Al so Damerau (D1 7 and Morgan jC ^ ; ir -, o found. that over 00 1 er+r <"E-, of

errors are simple ones. Damernu brts noted "An irmnection of '.! to .: itemn

rejected because of spelling errors shownr' tNi, at over 30 per cent fell Into

one of four classes of single error -" one '. otter w .ý wrorng, or t mt+ l. etl. er

was missing, or an extra letter livid ; -)e-ýn :. nsortod, or two nrl jiw. oF .

cters had beer: transposed, " and Mc-i-, n sa:,. d: "This report wrt conf'i rriec? by

the author & F' ,n analysis of soveral hundred student pro(*rnn;,,, written In

the FOF? TRJ\ rr !, languages at Cornell. "

As has ray, ty been said, a context free 1ang? wtfin .ia ýnoýj modrll for.

a programing -'LSO. We can find a context {'rr r ,, r, 1ý'-Urn T fnr Fi!. mo

all progrwi, -; hu es, such that ra correct program in a shy f. once n' ;.

But we do not Say that all sentert: of L are cot r'ect pro, nrnln n, f

l ý" Li [a ue L}t;? 1: ß! u(7 6e1Tiiirtic 1u, t. ' 'tot ,, i,, ý",, ,.

The problem of error correct: -'. on cctr, be et; i in the f'o?. 1ctr, r,. nd. wn. y.

A correct so , LX EL has been sent through t; '1i=tnne1 cuu' tL ! +tri_r. ý7

hRn been receivu. d. If Pi coins °. c' F+" 'Ji. L}l Q( ' no errors hlty ocotlrrL

If P differs from G. , but is it raf ýý cor rct ý; ntwice in L, no r: rrors

can be detected. 1f is not ý, : lont-, ncfr of L then errors are

detected. To correct Viem I nrs to tr: onroform the s; tr_nc f3 into the

most probable sent¬nce aeL. Our , -. pproi. ich w-'-11 br- to find that

sentence OC E L th. zt minindses the distance d ( X13 ,x).

A1thou h the Flpproach to error correction is to transform any

program into , correct one, we must be aware of tho Biet th»t the

received string is not a random string, but an erroneous version of

a correct one. It follows that it would be useful to define the

distance d (/�) as in (3.1.2), with the weicht function u

representing the statistical behaviour of the charnel, i. e. the frequency

of the corresponding; edit operations. Based on t1his diotr, nce it seems

that the nearest program is the most probable one.

In the second chapter we have described some yarsiný- lrr: thods for

a content free lanEua, ýe. All these parsers fail to analys an

incorrect sentence, but detect the existence of at least onp error.

In other words all existing ? : r:, ers have rin error tetection capability.

Still, there is a great difference between the error detection

capability of the various parsers. Laxly com i-'-ers to

refuse to analyse a wrong progr., m, while outputtin- in error i: es: _ a-age

on encountering the first error. This was a very inofficient alf>>ror ch.

Today it is expectod teat a compiler should detect s any error.; &s

possible, or, evL-n, to correct some of them. io ao s we ; seed

to remove the effect of the error encountered 'n' to how to

continue to p, 1rse the input string. Often this r'eans that one runt

find a variant to correct those errors. This cr+-,, ýbility of rrmovine

the effect of an error -. n! the decision on how to cor t; n<&e the rrtrsing

of the etrinti;, without :: kippink any portion of thr: input :; trip,;, i

called error recovery. If a parser h, ttis this capability we say that

it is an error recovery p-rser.

41 F3

We say that Ai zr. ser is an error cor cictiný if it tr: tnnforr s

any input string we T*, into the nst di r iiar :. entente u

parses this sentence. In other words, the p': rK. t; r araly:, es the input

string w, and outputs the syntax tree of thF >entetce u, that

satisfies the equality

d (u , w) = thin d(v , w) ,

v6L

where d(u , w) is the distance between the strings u -M w, c efined

in section 3.1. Cert: 1inly if we have the syntax tree of u, we

know perfectly well th,? sentence u.

In the process of parsing, the input eh-racters are scanned,

usually, from left to right. When -n error is d. etected the yatr-3er

has scanned some input charicte. r: ", and the next input chzracter is

q0 We say that i is the detection point of the error. This does

not mean that the character ai_1 (or a1) is erroneou: 1. It only

tells us that the string

al a2 �� FLi-1 ai

is not a prefix of any sentence. For the same 4tri. ng, ýnc' the :. acne

error, this point can be different for different prLrs4ir.., and con be

far away from the n"a+1 point of the error, wll be >7, los-,: n later.

1 44ý

3.3. A 3LRVEY OF TIE PREVIOUS WORK IN ERROR RIB O1T1 RY AND

ERROR CORRECTION T:!; CI-INIOTJ"5

There are three areas in which work has been done in connection

with error-correction in a language.

- error correction of spelling errors in a dictionary of English

words, in an information retrieval system, or in the lexical

analysis phase of a compiler.

- practical error recovery and error correction in a compiler, and

-a theoretical approach to error correction in a context-free

language. -k

3.3.1. Error correction of misspelled words

In an information retrieval system, or in the lexical part of a

programming Language, a dictionary of English words (or names) is

used. The correction of spelling errors is very importpnt in both

fields. Also, a solution possible in one field can be unsatisfactory

in another field.

Work on spelling correction was reported many years ago. Blair

(1960) Z- B2J has proposed a method of compression-decompression for

error correction in a set of English words. Dhlvidson (1962) Z- D2J

gave an algorithm to retrieve riisspelled airline passenger names.

The first work on spelling correction in the context of compilers

can be found in Freeman's (1964) article r F4]. A review of

spelling correction has been given by Morgan (1970) I M2.. 7. "organ

gives techniques for spelling correction in compilers and operating

systems.

Work in error correction of misspelled words in an information

retrieval system has been done at Brunel by the "Associative Parallel

Processor" group (see Dyke and Lea, (1975), (D5J, and Do_nnely Z- D4_7).

t'. 5)

Since trying to match the input word azain.. 4t the words of a dictionary

±s UZUA11y uoii4 LY clearly it is more efficient to

use an associative parallel processor to do this work in par"311el.

Riesman and Hanson (1974) (RiJ, and Ullman (1976) EIIiJ

use

the n-gram technique for error correction in a large dictionary of

English words. An n-3ram is a string of length n. To each n-gram

g=a, a2 ... an ,a weight u(g) is associated. U(g) is

one if there is a word in the dictionary that contains g as a sub-

string, and zero ot1,: rr. ise. These n-grams can be positional. For

example, if n is three, to all trigrams E1 a2 a3

a weight ui24 is defined as one if there is a word w= bI b ... bm in

the dictionary such that bl = al , b2 a2 and b4 - a3 . For all

positions i2 , i3 , i1 <m 24 m i3 n, in

the word w, the weights uil ' 12 i3 are defined similarly.

The set of all n-grams together with their weights (positional or

nonpositional), is called "the syntax" of the dictionary. Since

there are 26n n-grams, the method is practical for n small and in

a relatively larLo i:, j. lUliiLly.

A more theoretical reproach to the problem of i. isspelling is

taken by Wagner et al [L3, W1, W2J. Since it is an efficient

method of c, cll i. ij- in t:. c. case of a small dictionary, we

have presented it in section 4.1., adapted to our purposes.

3.3.2. PRACTICjiL ERROR CORIRECTION AZ R: i, COPo2Y BY CO! PILS RS

The work in error correction and recovery by compilers begins

with Irons (1963) (I2,7 and Freeman 11964) (F4]. Irons maker

local insertions, deletions, or substitutions in the input string,

until a correct sentence is produced. When more than one correction

is possible, Irons keeps all possible derivations for the scanned input

string. He has a table of 9vccessor:, and alternates for each

ýý

symbol. When an error is detected some possible local correction.

are taken from this table. i-iow v6r ; avbj. e4 tho iiiput s16r-in ,, it is i6 or, LcýynbLL.

Freeman has designed a compiler for CORC - the Cornell computing

language, which corrects all errors in the input string, and runs the

corrected program. Much attention is given to r3pelliru7 correction,

But his approach to error correction i concornmd only with : CRC

language.

Levy (L4] attempts to give a theoretical solution for error

correction in deterministic context-free 1arkrwigee. However Levy

himself states in the abstract of 1, is thesis that "the formal model

is not practical" and he suggests some heuristics to improve its

efficiency. This can be done, for example, oy rc icuIiu`1iC -c. ic cýll'ectior,

of some er=-z;. His error correcting algorithm has a "backward move"

and a "forward move", hich try to locate the minimum left and right

context where trlc elroi, iiave occ; acz. tu.

LaFrance (Id, L2 7 based his error correction method on Floyd's

productions. These productions are derived frow the productions of

the grammar, but incorporate some context in them. He uses some

tables of symbols which can follow a given symbol, and generates all

strings of two or three symbols which are correct at the point of error.

Cries (G3J, and Conway and Wilcox fC4J store decisions of

recovery based on the impl©menter't-i knowi ecicre of errora. The t¬ cinique

fails if un nticip+1ted errors occur.

The error correction in a simple precc; dence larCuýsge is studied.

by Wirth and Weber L ,O, W4J, Gries £G4J, Leinius fL62, and

Graham and Rhodes (G22.

Wirth and Gries have suggested local corrections which, when no

relation exists between the topmost stack symbol andthe incoming input

character, transform this situation locally, by deleting the incoming

47

input symbol, or by inserting some ch; Lracters. This method seems

to work for many errors but it is not a general method for error

correction. _ ,1

A good method for error correction in a cimple precedence

language is given by Leinaus (L6J. He considers that huto& tic

error coj. *ncctiw& . uy� oc; vIa<<u at phra3c -Lave).. Loillius

tries to find the smallest substring on the stack, that must be reduced

to a m@tasymbol. Although the account of context information taken

into account to correct the error is limited, his m3thod works well

for the majority of practical errors.

The approach taken by Graham and Rhodes (G2J, lies between

error correction and error recovery. The parsers analysed ire

bottom-up, with no back-up. When an error is encountered, they try

to obtain more inforrnntlon about thi error, by wvilystnp iii nmritMxt.

These are th. roaults from which this thesis starten in the clitß8

of simple precedence l: 1nguagoe. While Loiniun wies only the infornation

acquired from the arrinned input t4trtr , (ImOvim irui Rhoden try to wwilyc+e

the eurroundin,; context in which the error occurs, before mh. kinC Fury

correction. They continue to condense the ntrint7 beyond the btection

point of the error. For doing, Vi1i thore to it "b, i : )cwr'trd wov, 4", that

tries to condense the : tring strick (i. e. the portion precr; dine the

detection point of the error). Then, a "forward move" (ittf-mpts to

condense the string beyond the detection potnt of the error. This

move terminates if mor,: ý errors occur. In this thesis this idea is

extended into a "global move", that scans the entire input string,

and makes all possible reductions. Then a correction phase rnalyses

the stack, which contains now all the information rivailable from the

input string, and corrects the errors.

48

Graham and Rhodes state, about Leinius's work: "He recognises

that if the parsing stack, followed by the current input symbol,

contains any sequence of symbols ab px cd, where a, b, c "d ,

are single symbols, oc is a sequence of symbols, a .-b, c>d,

and b oc c contains an error,, then b ccc can be replaced by any

"locally correct" symbol, as a recovery action. "

This is not necessarily so, as can be seen in the following

example, taken from the language of DIM-statements in B&t. SIC.

Parsing the input string

4A( 10 )9B( 10 (9)0C( 10 )9

after bcanning the iecond comma, the stack could be

har v( 10 "r ( i)

rind the and Lnoy'nbol i lu locally correct, ninon L "ý i -ý , but

this reduction introduces a phrase error. All depends on what is

understood by "locally correct". The problem is that b «_c is

not necessarily a wrong version of a phrase. Nevertheless it oust

contain at least one simple phrase.

In the absence of a global analysis, ýmhar* end Rhodes u3e an

error correction cost function, which helps to choose "the best

correction", when more than one is possible.

Also, their article Z-C2ý constitute:: r very good survey

error correction and recovery.

3.3.3. Ml=-" ýI: ERROR CORý, ECTINC PE1,. SF

Some authors have tried to solve the general problem of error

correction in a context-free lancvage. A di3tanc ? between two str*ngc

is defined as the minimum number of edit operations (subntitution. ',

insertions, or deletions), necessary to ch-enge one string into the

other. Peterson rp1J, Aho nd Peterson f!, 1-7, ud Thor. L. son et

al (TI, T2, T3J, find an extended grammar that menýýrýte., not only

the valid seziterictLi, but ail the o teer "cor. rreotabic" input strings.

Aho anü Yet e :: ýr, "aneL at ti. e c; %-. tull.. . ýjv Zýl'Lüi z ar by actuilig now

error productions to tine or'igil, e. J. ErrtwkL, ar. i'heil a rioL. ifi. iud 1Arleý's

iaxigu. 4ge, grid algorithm is used to parse the input s:. ring in the new

to count the nur,. ber of error product. Lons useL, in the syntax tree

Thomason defines tiirý t operators (correspouLin to change operation,

delete operat-on, wic, insert operation) that act over the productions

of the original gri,;. aj, . r, to obtain the pro Iuc; i; ions of the oxtendud

grayamar, g. lthough they give a nice theoretical solution to error

correction, it is iiot so practical to implemoLt it. The nuznöer of

productions in the extended gra, aar is rauch bigger then in the on . na, 1

one, and the tiL. u Lad. -Llw iuewory space required Cov NL. rsing are

considerable. Lyon A101 trios to overcome this ä. zpediment azna LLeve'_oP3 aal

error correcting parser based on Barley's recogpiizer, witli a odi, 'i ü

SCAN and COALi Leevl( (s.; e sectio;

each step in the input :: tririg,

adding for each l, ro.. uution Tr,

number of states iJ each list

than the number of pro. uctioris

there are res x ra liýt. i L(i)

a 2.7. ) to recotý! ý ijo esi"oi"Ls. tia. sa, rtit

thi; li., t L(i) is ini iaiU. dd by

the JtaG, a (1i

, 1,

. 1. , V) "

Thus he

L(i) is very 1aß. " (;, Üij, g'tr

n the If wo 1"ejý r.. c: 1 that

a:, input elia. "w--tErs, tkiu rwlnbeýr"

of states is very ctni the king aß_1 tiiý c :, tLteti ,us iii,; : ý; ý4

of the parsing proec. . (Thu lust uanponuný of 4Si tu raj, i"cý, u its

the number of error.;;. i! evertheJ. ess, sip ce r: . i]_:; y's ;, r_ýsir. : ýeo _ý. u"

is an efficient on, t: -ds n ethoa ii. ay be iriijJ:.. eIL nte,..

6

j0

Cki PT -! R IV

SG: 1; ilE. OR CORR . Cl'INC. PARS caS ..

This chapter presents four different methods of error

correction in score classes of context feee 1anGuages.

The first section presents a transaucer as Fwni error correctio: i

lar. j; ua; e mechanism. This transducer recognises the seritenceÜ of the

and those strings which are consiaered to be correctable. Such a

method gives only d liiaited capability to correct rntieiý: ated errors.

Second section presents an error correcting algorithhn, for a

regthlar language, clue to WaLmer /'711 %.

The main results of this chapter, and of the thesis, can be

found in third and fourth sections. -

In the third. section is presented a global error correcting

parser for a simple precedence language. This parser e.: ten3s the

idea developed by Graham and Rhoden J G27, of con(icn iir., ý thf: surrour:., ing

yr context of the error. We transfonn it into a gloLal e, "roi" correcting

parser, by scalmint; the whole input string, anti cor... ýr.: ýir<< it before

the correction is li. e. de.

Section 1"rusents a global top-do; en exvor ^o_'rectin,; parser,

for the entire class of cor, te.: t frei langu,;. Les. lr s;.. %rts i'ronc the

global top-dov; n parser descz'ibcd by Unger Z J2,7, and ti"-nisfoii. s it iiAo

an error corracting parser. it: e ef'ficic,: cy of this palser c: Lz uýý

improved by con: cinir. U; it vjith iaore eff'iciwit evro1' OL'1`CC: ý. 111 par6Bcb,

for partieul-i- . -: u ,; lussez of lLnguages, such as

. 'ýý :1 ai' lalibua6Cä

and simple precedence languages. For this reason, the e-"ror eoirectlfg

algorithia for a regular luny-ua ;e due to Wagner , fit

, waz presented

in the secönd section.

All these methods are used in chapter five to design a globca

error correcting; parser for BASIC.

51

4.1. ERROR CORRECTION BY A TRANSDUCER

We have seen in the second chapter that for each regular (context free)

language there exists a finite state (pushdown) acceptor. Also the notion

of a transducer has been defined there.

We say that the transducer

Mt K, Tt zo ,so, F

is associated with the acceptor M=(K, T zo , so ,F) of

the language L if the transition from one state to another for a given

input a is the same for both machines. The difference between them

is the extra output capability of the transducer. Formally this means

that if (q, r, o)EJt(s, a, z)then (q, r)EJ(s, a, z).

But the extra output facility of the transducer can be used, for

example, to parse the sentences in language L accepted by the acceptor M.

(Ollongren (O C). We will use this facility for error correction.

Let Me =( Ke ,T , j" , Cre , zo , so ,F) be an extension of the

acceptor M. in the sense that K c-- K@ and ý, -. J. In other

words, Me is obtained from M by adding new states or new transitions.

Certainly the language L is embedded in the language Le accepted by Me.

We can look upon sentence V, $. E Le as an incorrect version of a sentence

vgl EL. If the associated transducer Mt with the extended acceptor Me

outputs, for each string -E Le ,a sentence we L it can be viewed as an

error-correcting mechanism.

As an example let us consider the regular language accepted by the

finite state machine with the transition diagram given in fig. 4.2.2.

The states O

are final states. It can be seen that the language

accepted by this finite state machine is the set of lists of real numbers

separated by , (DATA-lists in BASIC).

We can define a transducer that accepts any string and outputs a

corresponding list of real numbers. The assumption we make is that all

other characters, except those of the set {', d, +9-9., Eý, are

52

incidentally inserted or have changed a comma. We will define this trans-

ducer starting from the extended automaton with the transition table given

in fig. 4.1.2. There the ununderlined transitions; orrespond to the trans-

itions of the finite state machine given in fig. 4.1.1.

To each transition there corresponds an output (which can be empty).

The output function o: KXT --' A, is given in fig. 4.1.3. In

fact our transducer performs a ', function t that associates to each input

string OCE Ta sentence p in our language, i. e.

tsT ---ýº L.

The set of 'outputs' is Q={ o1 1 02 03 ... 07y \ýy

These outputs are composed from some more elementary actions, that must

be performed to obtain the sequence t( CX )a bl b2 ... bm These

elementary actions are s

a, : print error message

a2: j: =j+1 a3: bj: ai

a4 : bj =af'f

a5 : bý ai+1

a6: b: =o

and the outputs are sequences of ordered actions:

of_ (a2, a3 )

0 3= C a, a2, a3, a, a5)

04 = al, a6 )

05= (a2, a4)

o6= (a, a7)

07 = ý at ý

By this transducer the sequence

`` 981/> > 675 -- 98 , 986 N. 45-

will be transformed into the sentence:

53

\

`,

1 t 1

Fig. 4.1.1.

Inp State

ut d 9

1 2 3 4 ý. 2

2 2 1 5 1 6

3.. .... M_ � 2. 3 4..,.... 3.. 1. . 1.

4 5 4 4 1 4

5 5 3 1 1 6

6 8 7 7 1 7 7

7 8 8 8 1 8. 7

8 9 1 1 1 i s

9 1 1 1 1 l 1

Fig. 4. x. 2.

N

I

54-

2,

4

5

6

8

ý9

tii _. Fig. 4.1.3.

\

A

.`

55

981 , 675 ,- 98 , 986 ,. 45 " The idea of using a transducer for error correction is not new. For

any, deterministic context free language there exists a deterministic push-

down automaton that accepts this language, and parses it. But when 'one

or more errors are encountered, the transducer enters the 'dead' stat

In early compilers the right portion of the input string was scanned and

neglected, until an unambiguous delimiter (as the end of a statement, a

comma in a list, or an arithmetic operator +, -, ýt) was encountered. This

implies remaining-in the 'dead' state until a delimiter is met, that permits

one to decide to which, state to jump.

ugkthe idea of using a transducer can be useful in some situ- -Altho

ations it has some shortcomings. First there is the fact that only the

left context is used to correct these errors and the errors are corrected

always in the same way. Second it can be used only for a small language,

where an exhaustivedecision about each error can be made. For a larger

language, only the predicted errors will be corrected. What is worse

here is the fact that the surrounding (right) context of the error is not

used for error correction. It uses only the information available from

" the left context. This information reflects itself in the current state

of the automaton.

4

56

4.2. ERROR CORRECTION IN A REGULAR LANGUAGE

A general solution to error correction in a regular language, has been

given by Wagner LWiJ.

Let, L be a regular language and let MK, T' CY ' a0 1ý It F) be

the finite state machine that accepts L. For an arbitrary input\string

w=a,. a2 .. * an ,

in T, the problem is to find the nearest sentence in the language.

Let F(j, q) be the minimum number of edit operations needed to

change the substring a1 a2 a3 ;., aJ. into a string uj that brings the

finite state machine from the initial'state so into the state q. By

convention o' for s so

F(o's oo, for soso .

Let u= b1 b2 ... 'b be the nearest sentence in' L, i. e. d( u'w

is minimum. Since any sentence in the language brings the finite state

acceptor from the initial state so into a final state q, we have

d (u, "rr) qmýirnF

(n,. q_) . (4.2. x. )

Therefore the minim= number of corrections *) , er =d(u, w, needed

to change the string w into a sentence in L, can be computed if

F(n, q) are known for all states q ., F

These numbers can be computed by an iterative process. For each pair

of states (s1 , s2 )"and for each input symbol a, let'

V( si , s2 a) be the minimum number of edit operations needed to change

the symbol a into a string v( sl , s2 ,a), which brings the finite

state machine from the state sl into the state s2 . The following

formula holds (wiJ s

*For simplicity it is assumed here that each edit o13ration e has the

weight u(e)=1.

57

F(j+'., s) =smite KF(j,

s1) +V (si ,s, ajý, i

). 4.2.2

Thus, executing this algorithm, only the minimum number of errors needed

to change the input string into a correct sentence, is known. To-Sind

the correct sentence we must go backward to see how d(u, w has

been computed, i. e. the sequence of states (qý , q2 , ..., qn) is

found as follows:

a) there exists a final state qn auch that d(u, w=F(n, qn )

b) for any j<n, there exists a state such that

F( j+ i+ q j+l) a F( j' qq) +V( qj 1g J+1 a j+1) The correct sentence u can be found from the fact that it is the'

shortest string that brings the finite state machine through the states

q., q, 2, ... ,. c

At first glance, this seems to be an excellent solution to error

correction in a regular language. And it is, for an acceptor with a

small number of states and input vocabulary: But when the number of

states grows up and the alphabet consists of 26 letters, 10 numerals

and some more special characters it seems to become impractical. For

a finite state machine with n states and m inputs there must be

stored n2 m numbers V (a1 , a2 ,a). 'A finite state machine with

100 states and 52 input symbols would require a storage of 520Y. words

just for the data. Nevertheless we find this algorithm very useful

when it is combined with other methods of error correction, ac it will

" be done later. -

-_ýz,

v

58

4.3. A 5fltPLE PRECIIDt: 1JCE ERPOR CORZCTING PARSER

A purser for a simple precedence language has been presented in

2.5. That parser can detect an error in two different ways. .

First, when no relation holds between the top stack symbol and the

incoming input symbol. Then one of these two symbols is in error, or

some symbols have been deleted.

Second, when a potential simple phrase oC is detected, but oc is not

a right hand side of any production.

What strategy must be followed for correcting these errors? Two

possible ones are given by Graham and Rhodes Z-62 7, and Leinius (L6J.

They consist mainly in trying to make corrections immediately the error

has been detected, or to condense first the left and right context of the

error, before making a decision. In this thesis this concept is taken a

little further by trying to analyse the context of the entire string, to

make decision- bout the nature of the errors. But, before going into

details, some points can be made about the correction of these errors.

In the first case, the top stack symbols , and the incorin;; input

symbol ak are not related. Two situations reust be taken into account:

- first, some symbols between ak_1 and ak have been deleted. Thus

one or more symbols must be inserted. To insert a character a between

s and ak , there must be a relation between s and a, and between a

and ak .

second, one of these two symbols (ak-, 1 ,r) is erroneous.

y

Since s is already in the stack, it can be a metasywbol - the result of

a reduction of a phrase containing more than one symbol. Thus the assum-

ption that s is in error must be the last one.. There are two cases

that must be considered:

OTC) there is no relation between a and ' which combined k NA

with-the fact that no relation exists between s and ak leads to the

conclusion that ak_. has been., inserted.

as

Ji

P) ak and ak+l are related. This can be a suggestion that ak is

correct. In this case it is probable that one or more symbols between a

and ak are missing, or that s is incorrect.

These facts are tu L but they do not help us to take a decision

on how to correct the error. We will bear these in mind when giving ä

solution to error correction.

When a potential n1e phrase oC is detected, but a is not a right

hand side for any production, it is said (G2, L52 that a phrase error

has occurred. Such an error is seen, for example, in analysing the string

13 10Cci c c2 r132° in the simple precedence grammar G, that contains

the productions

TTi : Ai .-ac, cf

nj.: A> 7c c2 r,

but there is no production of the form:

Tt :A ---. OCc1 c c2 r

In this grammar the substring o(cd c c2 r is considered a simple phrase.

But it is not, since occl c c2 r is not a right hand side of any production.

As an example, let us consider the grammar G, which has the

productions

IT,, : list 0 nr C, rar

112: Rr ---ý - V(101)

ý3 t ar v ('i )

T(4 d (dJ

r5_= ...... v ý .. 1d

it6 : V Z" (4.34)

Here l stands for letter (A ,B ,C,..; 'Y' Zd stands for digit

(0 11 ,2,... , 8,9), and the brackets (. 7 are used to replace

a recursion, i. e. ruJ means that the string u can be repeated any

number of times. The lane generated by G is the set of all lists

in a DIM statement of the BASIC language. The string

w =, A( 94 ,B( 10

12), V( 10 )-yr will be reduced to

60

V ar , ar as can be seen in fig. 1.3.2. Here

v(i' ar ' ar in detected as a potential simple phrase, but it is

not a phrase in our language.

This example reveals a very important fact. A simple precedency

parser produces the canonical derivation of the analysed string. Ths

_. w

is not true if the string contains an error. In the example shown ire!

fig. 4.3.2, the substring B(10,2 is reduced to ar befoi'. e

A(94 is corrected, to yield itself a declared array (coded by the

metasymbol ar

It also reveals that the. detection point of the error can be very

far away from the real error.

r

i

v

Fig. t+. 3.1.

The precedence matrix for the grammar defined by the productions (1k.. j. 1).

N

_, _ 61

4 air sa T. -i -t r1 ri i\... i ')

?'y -Stack String Incoming input Rest of the st ring Tk .n sypibol

A (94, B( 10, 2 ), V( 10 ý"

94, B( 10,2 , V( 10 } ;4

_ýKý `' 'lý7d v ( 94 ,B( 10 2 ), V( 3.0 )7 ,

' L .

rLv ( , rte 9 4, B(

, 10, 2 ), V( 10 _

ý wt 4 ,; t

v9 '

B( 10, 2 ), V( 10 )7ý7ý

w ý` f 1 vý' ß( 10 2 V( 10 )

ý'ý; `F X 4,

e ... K s.:

bs

_o B ( ,

]. 0, 2 ) V( 10 1

) -/7Z

viB ( 10 2 ), V( 10

; -y vv -74 ( 10 , 2 ), V( 10 } 7ý7ý v(i, v( 1 0, 2 ), V( 10 )', 4

946v. y1 0 , 2 ), V( 10 )'74

.. `ý oýi., 9(3.0 º 2 ), V( 10 )7ý'ý'6

41 v

v 2 V ]. 0 7ý4

'747 v. iv (i , 2 v 10 74

vvi, 1) - , Y( 10 )71ý

v ar V, lo 74, 90 v V ( 10 ) 74'

visV ( 10 7ýb läýbv(i, =r, v ( 10 7ý4

v( 1 0 )

Par v 10 )74'

744v(ifarv 10 ) 4.

Fig. 4.3.2

' MJ_"4` 4-1 62,

s

Let us now describe the global error correcting parser in detail.

The parser has to analyse the string:

W= ao al a2 .... n an+l '-

where a0 = an+, = '' are endmarkers. As in 2.5 a stack is used for

storing the information acquired from the previously scanned string. Týe

parsing process has two parts. A scanning one, in which the input chars- . cters are scanned and analysed, and the received information is stored in

the stack. Then a reduction and recovery one, when the information

stored in the stack is used for reducing the stack, by means of the

reduction rules of tho grammar, or for error correction e. nci recovery.

During the scanning phase a pointer is needed in the input string.

Let us say k is the integer such that the next input character is ak .

At the beginning of the scanning phase the delimiter a0= is put onto

the stack, the pointer k is initialised, k=1, and g is initialised

to i. Here n8 denotes the length of the stack string. Stackn is s

the topmost stack symbol.

If the topmost stack symbol s= Stack, n and the incoming input

s character i= ak are not related, then the character i is put onto the

stack, but a question mark '? ' is inserted between s and i. An error

message is given, and the pointer k is increased by one.

If s and i are related then

- if s<i, the beginning of a potential simple phrase is detected,

" the character 'r ' is put onto the stack to mark this beginning, and

i is put onto the stack. The pointer k is increased by one.

- if s=i9 then i is still part of the potential simple phrase

and i is put onto the stack. The pointer k is increased by one.

- if s-1, the ent of the pbtentiai sihple phrase is detected,

and 1J' is put onto the stack to mark this end. At this stage the

stack contains a potential simple phrase enclosed within the brackets (J.

63

The second phase must then start, i. e. a reduction procedure must be

called. If no errors have occurred, then the string enclosed within the

brackets ' [" ' and'J ' is a simple phrase, and it must be reduced to

the corresponding metasymbol. If phrase errors have occurred, they ill

be detected by this reduction procedure, since the potential simple phrase

enclosed within the brackets ' (' and 'J' does not match any right

hand side of a production in the gra mar. \

If errors, marked by the presence of '? ' , have been met in this

potential phrase (now we are not sure if it is a simple phrase or a phrase),

then two alternatives can be followed:

- first, a recovery procedure can be called at this step,

- second, since some more information can be obtained by analysing

the input string further, i is put onto the stack, and the scanning

phase continues.

This scanning phase of the parsing process is summarised in the flow-

chart of the fig. 4.3.3" It finishes when the last input character

an+i , the endmarker is net. At this stage the whole information

" available from the input string, is contained in the stack. The s tack

must be verified, and if needed, a recovery procedure must be followed.

At each step, the parsing process is completely described by the

content of the stack, by the incoming input character i, and by the

rest of the input string, i. e.

state =( Stack i ak l ak+2""" an ) (4.3.2)

is the description of the state of the parsing process.

During the scanning phase, the parsing process may enter the state

x ['? ,. ] Ii 18k+1 als+2 ... an ;). (4.3.3 )

This means that a potential simple phrase, or an erroneous phrase, has

been detected. The most probable situation is the existence of a correct

simple phrase, since the errors are not very likely. As can be seen in

the flowchart of fig. 4.3.3, the procedure RMUCE is called at this state.

64

, '\

Fig. 4.3.3

65

t

The procedure REDUCE analyses the potential simple phrase ?. If

no question marks are found in the string 'ý , no errors have been met

during the scanning phase, and the potential simple phrase is reduced.

This means that the productiow of the graurar are checked, a productioh

A is retained, and the corresponding reduction rule,

is used to replace the simple phrase 'Y by the metasymbol A. If there

is not a production A --ý , then a phrase error has been detected',

and must be reported. A procedure PHRASE is called to correct this phrase

error.

The procedure REDUCE is given in the flowchart of fig. 4.3.4.

\\ If in the string ý there are some errors marked by the presence of

a '? ' ' then a cal to the procedure RECOVER is made. The errors are

corrected at this stage if no ambiguous situations arise. Otherwise the

scanning phase may continue to take more information from the unscanned

string.

The procedure RECOVER tries to reduce the string 7l . It in already

known that ý is erroneous, since '? ' has been met in this string. In

other words ý has the form

I= Pi ? P2 ? ... ?, 3mk .

Here 731 'must have a common prefix with a right hand side of a production,

and Pmk must be a suffix of a right hand side of a production. The

string P2 can be a part of a simple phrase, together with 31 , but

with an occurred error between them. Also P2 can be a simple phrase

itself with erroneous first or last characters.

It is known that the relation between two consecutive characters of

is , and the same relation exists between two consecutive symbols

in the right hand side of a production. Therefore all /Ij must be

substrings in at least one right hand side of a production. If there is

no production

Ar ai Pi a2 (4.3.4)

66

1

for some strings OC2 (possible empty strings), we still say that

a phrase error has occurred (inside p ). This error is discovered when

one does not find a production (4.3.4), for the string t3j . One of the

following alternatives must hold:

- either , 3j is a substring of a right hand side of a production

(4.3.4), incomplete one, since some characters are missing at the beginning

or at the'end of the simple phrase ( OC1 or °2). `.

- or 4A is a simple phrase, and the '? ' is due to errors at its

left and right side,

- or , 3j is not a substring of any right hand side of a production.

Here a new error, a phrase error, is discovered.

- or the whole string pj has been inserted. This is more likely

for a shorter string P3 , and less probable for a longer string Pj .

If the string i contains only one character a, i. e. ?a? is part

of , the probability of insertion, or of error in general, is high.

It follows that all productions (4.3.4) are candidates to be used

in the reduction of , 3j , and must be stored fora later decision. These

decisions will be made after all-substringa Pj have been analysed.

Thus, for each 13j a resolution set Res (ý3ý ) defined by

Res ()ajA, ß) I the production i is A }

i -> «1 '*3j C'(2 J

(4.3.5) is computed and stored.

If Res ( ý3ý ) contains only one pair (m©tasymbol, production),

this production is the only one that can be used to reduce the string Pi.

If Res ( ? 33 )1>, I, (here 1Pidenotes the number of elements in the

set P), then Res ( f3 ), Res can help to decide j _I

which reduction rule to use.

The start of the procedure RECOVER - the decomposition of '7 , is

described in fig. 4.3.5. It is continued by PREFIX (fig. 4.3.6),

SUP= (fig. 4.3.7) and SUBSTRII (fig. 4.3.8), which compute the reso-

lution sets Res (, 31 ), Res ( r3. k ), and Res (13j ) respctively.

68

Ilk)

J1.6. '}"J. )

69

i.

ýt

The produc-tions of the

grarr. mar are;

11 1,

rig, .:. air ,0

t 1

ý+

9

J

70

Fig. 4.3.6

F-

1 ,1

t

a.

I.

Res(mk., kl): =(A, j)

3<nP Yes j := J+11

exit

Fit. 1, -3.7

r yi 3

71 0k

\

72

Pic;. 11-. 3.8

Before-proceeding further, let us analyse some examples. Consider

again the grammar defined by the productions (4.3.1), and let us try to

correct the input strings

W1 =+1 ' A) 5 (9 , 6) ,B

(10 ),

x2 a#i A969B 10 i

x3= 946 A96B (10

and

.\

I

w4a? 0 A (9 ,6B

(10 ), # .

For anyone familiar with BASIC, it is clear that an inserted

is the least error in the string wl ,a change of ' (' to ')' is

the error in w2 ,a missing is the error in w3 , and missing

and ')' are the errors in w4 . The RECOVER procedure is

called at a stage of the parsing process described in fig. 4.3.9 " This

stage is described by a state s, that has three components: the content

of the stack, the incoming input character, and the rest of the string

not yet scanned.

State Stack string ,a

al)wi: 7ý7tLl? )? d

a2)w2s4, ý1? )? dJ

b) w3 : y46 Zv (i , i) ?

a) w4 =#Lv( i ILd? ,7\

Fig. 4.3.9

rest of the string

9'6)'B(10)A4

6B( 10 )#

10 )#, 10 )#46

The contends of the stack is the same in both cases a1) and a2). The

1

character ) is enclosed within the question marks '? ' . It is possible

that ) is inserted, and the fact that L is related to- (1Ld,

see fig. 4.3.1), strengthens this assumption. In this hypothesis the

reduction ld J-- v, derived from the production rt5 , can be made.

Also the fact that ')' can be the result of a change operation

(a' ')' ) must be taken into account. The only possible character is

'(' , since 11>1(1. e-. d. In this case 1 must be reduced to v since

I l' ('

.

73

How can these results be obtained using the resolution sets? In this

case ? /-2? P3ý1'? )? d and

Res(/ )= {(v, 5), (v, 6)}

Res /32) 0)}I since ')' is enclosed within '? '0

Since P2 is very unreliable the first and third resolution sets are used.

They contain a common production 115 : v- ld , end Id = X33 correIponds

to an insertion of , 32 . Also Res ( ßf31 ) contains the production

n6 s v-. i' , and Res (, 33) contains the production TC4 si --'- d, and

the reductions I F-- v, and d ý--- i can be made. This case

corresponds to the case of a change operation. Since v? i appears in

the production 7r3 : ar --o-v (i, this change operation can be

ýf3ý ). Thereby two reductions-are possible for the stack, and

the stack could be

0 Lv 46 Z" v

To choose between them we need some more (right) context. In both cases,

t

A) and a2), the incoming input characters sk is enough, since only one

of the possible topmost stack symbols, v or i, are related to a

In the case al) the relation v =- ( holds, but i is not related to '(',

thus the first reduction must be chosen. In the second case a2), v is

not related to ak but the relation i holds, thus the second

reduction must be chosen. After this correction the parsing process

enters the state

Stack ak Rest of string

al) 4 Ev( 9'6), $(10)9

a2) (v (1 6B (10

In the case b) the strings , 3., -v(i, i) and 132 a1, are

separated by '? '. To these there corresponds the following resolution

sets

74

N

i

Res (f1)ý{(ar, 2)},

Res( 732() }

In both cases only /one

reduction is possible. Furthermore, no changes

are needed in the strings 131 and /32 , to transform them into simplÄ

phrases, since /

, 31 =v ar , using the production rt 2

and

P2 =3 '--- v, using the production 116

Thereby these reduction rules must be used to reduce the stack to

is due to 14 Z-ar ?V. The question mark '? ' between -A and P2

some missing chracters. How does one find them? There are two alter-

natives. First, we try to correct this error at this stage by insertig

a character 'a' related both to ar and v. It happens that only

one character, ', ' , satisfies these conditions. But there can be

more than one such character, and we must use the second alternative in

this case,

Second, since v is related with the incoming input character '(' ,

the scanning phase may continue, and more right context become available.

Here is the continuation of the parsing process.

State: (Stack string , ak Rest of the input string

ýar? v( 0

L Ir? v(Z-i 0)

Z-) Z-`r? v(i )_7 46

"

At this stage the procedure Rh; COVER unuat be called again. To the sub-

there corresponds the resolution strings f3 10 and P2=v(

sets

Res , j, ) " {( Ust .1 )}

ResP2)" :: 0 3)}.

Each resolution set contains only one production. While in the second

set the whole right hand side of the production n3 : -" v(i)

75

is matched by X32 , it is not the same for the string X31 r.

Here the production

rr list ar r, arJ

contains an infinite number of reduction rules, and two of them may be

used heres

'rjý a 8ý" ý_ ýi9t f

1 t,

and

If the reduction ar i-- list is chosen, the stack would be

(ist ? AM ] and the stack cannot be reduced any more. In the

second case, we need a second F. r to complete the reduction rule

ar , ar list , which fits exactly in this case, since ý--- ar

Clearly the '? ' must be replaced by '

Formally, the first resolution set contains the production

IT :A /31uBv.

The string , 31 in not long enough to match the right hand aide of this

production, but there is the possibility that P2 can be reduced to B

and the terminal string u has been deleted,

In the fourth care fit "" 'd' , and , 32 "+1', arm composed of only

one character, but none of them are enclosed within '? ' marls. The

resolution sets area

d ---., Res 4) v, 5 fr

2 Res ('32) = {( v, 6)}.

The second set contains only one reduction rule /32:: -- 1}-- v. Since

v is related to the incoming input character '(' , this rule may be used.

To reduce the string , 31 there are two choices. The first i: i to reduce

d to i, and ! atr 'i) 40, i. e. the result of the reduction is

related to the left context. The result 'v' of the second reduction

rule jd I-- v is not related to the left charaoter ', ' , and the

string /31 Qd does not match the entire right hard side oP the production

TT5 :v id

76

Since only one reduction remains in both cases, they must be used and

the state of the parsing process will be

;v- (i ,i? v( 1ý)

The parsing process continues until it enters the a tate r

46rv(i, i? v(i)) I il E. `ý

At this stage the procedure RECOVER is entered again, the following

resolution sets are found

131. =V( i, i Res (pl) _ {( ax ,2

132=v(i) > Res (p2)= {(ar, 3)},

and the stack must be reduced to 44 Z- , jr

? ar .. At this stage both

resolution sets will contain the same production rule

list ý, nm ft ar _7 .

The reduction rule ar , ar F- ist should be used and the missing

has been discovered.

One must show how the reduction sets can be used to correct the errors

in the string '? = I3l ? 132 ? ... ? /3mk 9 and to reduce it to a meta-

symbol A. Often there is more than one reduction. In that case the

left and the right context must be used to choose the correct reduction,

But there are strings for which the parsing process reaches the state

(1rßJ j #- jE and no other context is available.

Let us first consider the simple case '? M X31 ?

_/32 . Some errors

are present in the string 7, and they can be either missing characters

between Pl and ? 32 , or some changed characters in the tail of p,

or in the head of '32 . Normally p, must be a prefix of a right hand

side of a production, and the resolution set Res (ý31) contains all

productions TTi :A' 13 u, for some string u. If there is no

such production, then a phrase error has been discovered, and it must be

handled by the procedure PHRASE. The resolution set Res (P2 ) contains

all pairs (B, k, with the property that the production TTk --j-V ? 32

has X32 as a suffix. Ajain, phrase errors can be detected when the set

77

Res (P2 ) is built.

For example, such an error is met in analysing the string

w5=j A5( 10) , 9, >v (9 )5

,

in the language generated by the productions (4.3.1). The error is

discovered when the parsing process enters the state

(94Zv(i), i,?, ar2 II£) II

Here both strings 13, =v(i, i, and X32 ar contain phrase errors.

It is assumed that these errors have already been corrected by the

procedure PHRASE. Therefore, (A9j)E Res (131 ) if the production

ni has the form

la) TTi :A

lb) TTY :A -s- /uý

aad (B, k)E Res (2) , if the production TTk has the form

2a) Tfk sB /-x-'32

2b) TCk s B-'" vl32 ý

for some strings u and v.

1

There are several possibilities for correcting the errors and for

reducing the string P1 ? P2 , and they are depicted in fig. 4.3.10.

l) The strings 13,. and 2 are parts of the same phrase. In this

case Res ( , 31 ) and Res ( X32) must contain a common

production

Tt sA2u X32

for some string u The string u has been deleted and this

is the cause of the question mark between /3.1 and ? 32. (Fig. 4.3-10a)-

2) The string must be reduced first to a metasymbol A, using

the reduction rule P, u,. -A, for some string u. It

is considered that t has been deleted and now is inserted

back into the sentence. Then A and 132 must be reduced,

using the reduction

171Au2Ms2 1+B.

Here 1(1 must match the left context and u2 has been deleted

78

.. . s; ,

and now is inserted back into the string. (Fig. 4.3.10b).

Thus, for all pairs (A, j )(E Res (f) must be verified

if A is related to the character on the stack, preceding

and if there is (B, k )E Res( 152) such that` the /_

production irk has the form 1ý

Irk :B0 'ö r2 ' and j 11 A u2

3) This case is similar to 2) but the order of reductiom diffezl.

The string P2 crust be reduced first to a metasymbol B, then

the string f31 uB 772 must be reduced to A. (Fig. 4.340c).

It follows that, for all pairs (B, k)E Res ( P2 ), it

must be checked if there is a production TTY :A

i.. e.,. A, .i)E Res (ý3i) , and if

uB12 for some terminal strings

uandv.

4) The last possibility is that both 71 , and 132 must be reduced

to A, and B respectively. Then, together with more left

and right context, a derivation

CýI, AuBrj2, (4.3.6)

is found. Here Y ?j corresponds to the left context, 12

corresponds to the right context and u is a terminal string

that must be inserted (fig. 4.3. l0d). Certainly if rj,. does

not match the left context, or if ý2 does not match the right

context, the derivation (4.3.6) must be rejected.

These facts are summarised in the flowchart of fig. 4.3.21.

Clearly, the smaller a reduction set is, the better. This is soy

since for a longer substring only a few productions will contain

ý31 For a string r31 consisting of only one character, many prod-

uctions will contain the string /Z,. 9 and the resolution set Res ( P1 )

is larger and less reliable.

When the string 77 contains more than one '? ' , the correction of

the errors seems more complicated, but the idea is the same. Still,

79

\

A

a) ,\

A

1

1ý' B12

c)

i

B

i

u2 12

b)

Fig. 4.3.10

80

l

i 1 1 i

1

C

r

i su2 BL

u1 u3

d)

0

J' z

BUILD SE P1' P2 i

Next pair

For all pairs (A, j)CRes(f1 )

(B, k) ¬ Res(p2)

execute: (is there one

more pair? )

Yes

s there a derivation

C --}--, -` ýý AuB 12

No

Store the Does the Yes derivation production ITk have

B Au 71 P2 the form

B -+ Vu

71 %31u1l 2 No

xaýxt oes the pair production n

has the form A -ý PI uB

0

k No

-1 =EXIT

Next pair

0

Does ýI

match the left context and '72 the

right one?

Yes

Store the derivation

C= ý1 AuB ý2

11 131111 132ý2

Next pair

Store the Yes derivation

A pluB '2

l"1u1 p9 v72

pair

Yes

s the

Next production nI

A

Yes pair of the form

--r131u 13

Fig. 4-3-11-

81

Store the derivation

A 3, U q

there is a slight difference. A string j=2,3, """, nk-1

is enclosed within question marks, and there is the possibility that

has been inserted. Now it is not known A. is the prefix or a suffix

of a phrase, as it was known before about and P2 . Thereby, the

string j=2,3, o", ' mit-1 can be reduced alone, together

with3_ý , together with ý3j+1 , or together with both.

The minimum context that must be taken into account when I is

reduced, is the incoming input character and the immediate left symbol

in the stack. Thus, if the parsing process is in the state

(# 71 qf72j1I rest of string ), the symbols' q

and i must be used to choose a possible reduction for 'l , or part of

7. Let us say, that there is only one metasymbol C that is related

to i, and they both form part of a simple phrase. This is the case

when Matr (C, i==, and there is no other metasymbol B such that

Matr (C, i)__, where Matr is the precedence matrix of the grammar.

Then 13mk must be a suffix of a C-phrase. If Res (/0 Ink

) contains

only the pair (C, k), there is no doubt the production irk must be

used to reduce the string ;3 In this case the reduction is made and

the scanning phase may continue. This discussion is valid and for the

case .z. Let us assume now that it is not possible to choose a unique derivation

for the, string 7, and all derivations

" C: L

=:? > 't1 p1 ul p2 u2 ... 73uik. 72 , (4.3.7)

must be built for some strings '? i 1 772 1 and some terminal strings

u1 I u2 ... I udc-i . Clearly there are a finite number of such deri-

vations, and hopefully, a small number. They can be constructed by an

iterative process.

If all derivations

+ (4.3.8) Aý'qi. 73 .

u1. r2 U2 ... uj-2; j-i 72

are known, they must be used to produce all derivations

fn C ýý ý0 PI "I'32 u2 ... p J1 "J-, 3j`134 (4.3.9)

82

For j=2 the derivations (4.3.8) are known, and they, are given by

Res('31). Thus for j=2,3, ... , mk, a similar process of adding

to the derivations (1+. 3.8)) must be executed. If CONNECT is the

procedure that constructs the derivations (4.3.9) from the derivaaions

(4.3.8), using Res( P, ), then CONNECT must be executed for

j=2,3, ".. , mk" There are four posibilities of constructing the derivation

(z.. 3.9) from (4.3.8)" First is the linkage of to the derivation

(4.3. $) if 72 u. That is, either contains as a PJ ßl3 ý2... pj

substring, or 72 contains a metasymbol B1. , such that (B, k) F Rea( Pj),

for some: d k, anal- ' . ßi1 ý u1B v1 (rig. 4,3.12a). ,., ' ..

Second posibility occurs when ,,

is only a part of a simple

phrase, and a metasymbol is needed in the left part of this phxue,

i. ee there is (B, k) ERes(pj), such that 7Tk: B -ý 1 f3,2, where

contains a meta symbol. In this case, if '= -jAu , the

derivation B= fit 73 2u 13 j23 »1 . 131u{ ... /33 "ä"2,

must be added to S. (fig. 4.3.12. b). /t

,., Third posibility is to find a derivation

C= ßA uB J2,

in which case, the derivation

C V1 AuB. J"2

-r1 17 1u1 ... P3_1 12u 3 ý3'

must be added to S (fig. 4.3.12. c).

Last hypothesis that must be taken into account is to delete

the, string in which case all derivations (4.3.8) are carried

forward. This must be the case when p. is a short string, and does

not contain metasymbols.

ýý

ýý. -'.. 83

§: ,t

ý.

,,

1

ýýý

I

,. 'ý.

ýýr3 2

f3 hü

¶0 p1u1 P2U2

b)

I

Fig. 4.3.12.

2u2 ... ui-2/i-1" ý2

u ýj 13 8}

4

//

7/ M 400,

ßf31 u1 1,2u2 .. "ý -1(2 vý lý

d) .

84

,:

4k '. FA, y, ý.

ýý_ ý,, ̀

r-

z P"

A flowchart of the procedure CONNECT is given in fig. 43.14. It

is called by the procedure LLD which builds all derivations (4.3.7) "

The procedure BUILD can be seen in fig. 4.3.13. _

From these many derivations (4-3-9)9 there must be chosen that on,

that matches the left context in the stack. It was understood that tht

strings ui can be empty, or consist of small terminal strings.

Finally-the continuation PRWIM, of the flowchart of fig. 4.3.2 must

be oompleted. PBP-SE is the procedure that corrects one, or more phrase

errors. This procedure is called when a potential simple phrase ý has

been discovered, but the procedure REDUCE fails to find a production of

the form

11 %A -ý- 'ý

Such an error occurs when a prefix of a right han& side of a production,

and a suffix of another one, merge together. One example can be found

in fig. 4.3.1. Here are some more examples

a) var

b) idddd

c) E--r, it 'pit' in the same language, defined by the productions (4.3.1). Certainly some

phrase errors, as in example c), although they are theoretically possible,

may never happen.

Since there are a finite number of productions, and each one has a

limited number of characters, there are only a finite number of different

phrase errors, and they can be stored in a table. This has already been

suggested (L6 J.

Here will be given a procedure (as opposed to a look up table as

above) that corrects these errors. If contains a phrase error, it

has the form

P2 4

where 13, ß1 is a prefix of a production, and c,. 72 is a suffix of

a right hand side of another production.

85

r 1

s

Fig. 4.3.13

I

ä, e g6 4

`'4 t. t

CONNECT

N t ex pair

or all -- ,

derivations of S(4.3.8), and for all Yes

S : =S(4.3.9) (B, k)CRes(p3 ), execute: = (finish ?)

I

No Exit

Doss the Y03 Put the derivation

& ? A hold

into S(4.3- o

Next pair

Has the production n":

" h Add the derivation

Y r1 15 J ir 2 o B -. 0- iI es B with the propert

AU _ '9 3A u'3ý 2

to x(4.3.9)

Is there Add the derivat ,z a derivation

' Yes C -4 Vý AuB ý'2 Next

CC AuB-ý ON ... u3" pair

to S(4.. 3.9) No

Is the othesis 'Add the derivation is inserted" Yes (4.3.8) to S(4.. 3.9)

acceptable?

No Next pair

4' l

Fig. 4.3.14..

87

If '1 contains more than one phrase error, it has the form

'ý ° %31 CI P2 02 4.3.10)

and cl /3 2c2 must be a substrir g of a right hand side of a production,

02 3'03' "' le 1 -2 1. ' must have the same property, Ao

must be a , prefix of a right hand side of a production, and of ,. r3 1 mat

be a suffix of another one,

Let us consider again the example of fig. 4.3.2, 'ß.. e.

av(i, ar , ar e

AU pairs of consecutive characters are related by , thus 1j is a

potential simple phrase, but it is not a right hand side of any production.

But . v( i is a prefix of two produotions

Tt2 s ar «----> v (i ,i)

Tr3 s ar ---1 v (i )

and &är. is a substring of the right hand side of the production

n: Id -ý. _C, . 7" It is clear that t must be considered in only one of them, and the

production 11 needs this comma, but T[3 does not need it. Thus

131 P2

where '31 =v(i is a substring in n2 and TT3 , and

P2 ar , ar , is a substring in 1nI. . To choose between Yl2 and

r, ' it is enough to compute the cost of changing , 31 into v(i, i)

or v(i). Certainly here v(i) is the choice of minimum cost, but

the chosen reduction must agree with the left and right context.

It follows that PHRASE must have two parts - one that detects the

merging characters ci and the decomposition (4.3.10), and another part,

that connects these parts into a syntax tree, i. e. corrects the errors.

The string bb b2 ... bm must be decomposed as follows. First,

the longest prefix b1 b2 ... b. , of ' is sought, such that 'bl b2 ... bk

is aprefix of a right hand side of a production. Since the last character

bk, is the merging character, it is not known if it is part of the left

phrase or of the right one. Thus bi b2 ... bk i and P2 starts

88

with bk+l. The end of , 32 :. s determined in the sane way in which it

was found for ý3ý . Tip: us the decomposition

17 Pjc 1 ? 202 . o. cm-I J

is obtained. For each Pi the set Res(Pi) is defined as befor'a,

and T must be corrected exactly as '7 was corrected when it contained

errors marked by ' ?',

One now starts all once again with A. view to analysing a strý. ng

into a simple precedence language, leaving open the option of using the

error correcting procedute described above. During the parsing process,

all correct simple phrases will be reduced to metasymbols. Three' `ý.

delimiters 7, and which are not terminals of the languages

are used to mark the beginning of a phrase, the presence of an error,

or the end of a phrase, respectively. ' Let d denote any delimiter.

If the whole input string has been scanned., the parsing process reaches

the state

dOPidiph... PrdrI E ). tý-. 3.11)

Now the whole information avc41£lble from the input string is stored

in the stach.

If the delimiters d, 2 d2 ' ... ' dr`, 2 are all '? ' , then

i the string

i? 72?... ?r

must be a wrong version of a sentence. From all derivations obtained

by BUILD there must be retained that, or those, that have C

t sentence metasynbol 1. If there is more than one, then that one,

which needs less corrections then the others, is choosen.

If do -- d, -- ... = äff, ='[t, we have, probably, a correct

left context that can be used to correct the errors in the stack string

rk+1 ? flk+2 ? "' ?P k+l

as can be seen in [`%6 ],

89

If dl =?, then we can use the right context to choose the

correct derivations constructed for 7 by BUILD. This can be done

in exactly the same manner as using the left context, but proceeding \

from right to left.

The error-correction can be postponed until the end of the scanniipg

phase. Then the whole information is available in the stack. That

is why the error correction is called global. For each substring p3

in (4.3.11), a resolution set Res (p3) , is built. The reliability

of the set Res (ýý) depends heavily on the string , 33, and on the

delimiters dJ_1 and di . If dJ_1 = di = the resolution set

is considered very reliable. If dJ^lj, di the reliability

of Res (j) depends on the length of'3, of. If ý3j is only a terminal

character/ 'a' , the corresponding resolution set cannot be considered

reliable. That is why, when the string r3ý _ 'a' is enclosed within

'? ' marks, it is defined Res ( 'a' )= {( a, o)}.

Still, we have not adhered to the principle of postponing the

corrections until the end of the scanning phase. We have tried to

correct the errors as early as possible. Very probably the string

, enclosed with r], contains only one ? mark. Since Z

marks the beginning, and ,7 marks the end of a phrase, we try to

correct the errors at the level of a phrase, which seems reasonable.

Certainly, we must not forget to use the surrounding context.

This error correction philosophy certainly implies more than

trying different local corrections. The idea of changing a character

around. 'V marks, although a correct one, seems naive now. Although

we are doing-much the same tying, it is done at a higher level, at the

phrase or sentence level.

An implementation of an error correcting parser is given in the

next chapter. ý.

ý

90

4.4 A GLOML TOP-DOWN ERROR CORRECTING PARSER

4.4.1 A global ton--down parser has been presented in 2.4. The problem

faced by that parser at each step is to analyse (parse) a terminal string

OC as an A-phrase. When DC is an A-phrase, the algorithm described

there will give the derivation

But what happens if OC is an erroneous A-phrase? This is the problem 11

faced by an error correcting parser which we shall try to attack in a

top-down manner in the rest of this section.

As has already been said, although the errors happen, their occurrence

is not too probable and this fact is used in the iterative procedure

described below. We expect the input string to be a correct sentence

and try to parse it. If we fail we first assume ,,

that one error has

occurred and. we try to find an A-phrase P such that d( P, oC) = 1.

Here d (P , oC) is the distance between the strings 13 and Oc. , defined

in 3.1. _.

(For simplicity u(e)_ 11 for all edit operations, but

any weight u can be used). If we fail again we assume that two errors

have occurred and try to find an A-phrase P such, that d( cc) = 2.

Note that if the length of the input string a is n= I ml and the

length of the shortest A-phrase is lo , then d5, cC) n+10

i. e. n+ 1o is an upper bound for the number of the errors that have

occurred. This discussion is summarised in the flowchart of the fig.

4.4.1.

The whole problem has been reduced to a simpler one: is there an

A-phrase p such that d (t3 , cC) 4 Ner, for a given number Ner?

if there is one, construct the syntax tree of the A-phrase 73 .

We define

d(A, ' oC) min "{ d (A3 is an A-phrase }; (4.4.1. )

i. e, dtA, oC) is the minimum number, of edit operations needed to

change the string a into an A-phrase,

91

Ner: =o

Is there

No an A-phrase [, Fr-: Her +1 such that

d N) e, Her

Yes

Output Her

end

Fig. 4.4.1.

Now, if d(13 , oc) < Ner, then according to the definition 3.1.3 ' there

exists a trace T, between ,3 and oc auch that u( T< Her. Since

?3 is an A-phrase, there is a derivation A Let

7f :A ul Al. u2 A2 '... uI A1 ul+1. A

be the first production used in this derivation. Here u, are terminal

strings, maybe empty, and Ai''d metºymbbls. It follows that P can

be decomposed as

,3= u1'31 u2 13 2 ... ul /1 ul+1 (4.4.2)

where )3i are Ai-phrases, 1=1,2 1 ... 91 . By the trace T'

to the decomposition (4.4.2) there corresponds a decomposition

LL«=A(te) : o(=v1oc1v2a2... v1alvl+1' (4.4.3)

of the string DC , such that 1A I

d ue d (ui oi) +>d OCi). (4.4.4) iý1 i=x

The decomposition (4.4.3) and the formula (4.4.4) give an insight into

the solution of our problem. We know the string OC and we wish to find

an A-phrase ' such that d (73, oc ) is not greater than Her. Then,

for all decomposition;, (4.4.3) of the string OC , we must find that pro-

duction, Tt , for which +1

d(ITaLa)a d(ui, vi)+td(Ai, OCi), (4.4.5)'t

i=1 10

is'not greater than Her. If we find one, the problem is solved.

92

Note that a procedure DIST (A , CC 'd) which computes

d=d(A, OC) , according to (4.4.5), will have to be defined, recursively,

since it calls itself for other values of the parameters.

The fact that we have a global error correcting parser, reflects,

itself in the sum d (ui , vi) # -'the first part of the sum in

(4.4.5), For a small number Ner , this sum will be greater than Ner

for many productions 1TA , and there is no need to proceed further, but

to reject those productions.

Lot IT (A, 1), TT(... , 1T (A , lA) be all A-

produotions. The procedure DIST (A , oC, d) chooses in order an

A-production , starting with R( A To each A-production all

decompositions (Acc are examined, in a precise order. For each pair

(A-production, D-decomposition), the distance J(production,

decomposition) is computed and DIST (Ak , OCk, dk) is called, for

k2,... ,1. If 'I +dl + d2 + ... + dl became greater than

Ner, the next decomposition aa is chosen. If no other depomýosition

_exists, the next A-production is tc. aiIf no other A-production exists,

then there is not an A-phrase 73 such that d4 Ner.

The description of the procedure DIST can be found in the flowchart

of the fig. 4.4.2.

Something is lacking there. What is meant by the next decomposition

Aa ?" -since there is a need to examine all possible decompositions,

they are order. Let

Lia( t)= ul u2 u3 ... uu

and 11

a(2) = vi v2 v3 ... vM

be two decompositions of the string «C, into the same gnu

nber m of sub-

strings ui ', and vi respectively, Let Jut denote the length of the

string u. Then

if! there is an integer i -dC m. such that ) ut = In , 1u2)=IV 212" ""

1uiº- = jvi`

93

N

_ý,

ý .ý ý.

y ý_. xý

ý»_ . DIST(73, p, d)

k.: ý 11 K2

&A pi

(shortest lengths for

Corres onding to the production g, i); B ... º u1BIu2B2... ulBlul+1

choose the first decomposition

Compute; J1 d'(n(a, ý. ), Aý, ) Yes

d+ ýý Ne No Is there a new decompositio

A for Pf Yes

d: = d+cT, No E3

K1

DIST(ak, pk, dk)

Ptn +ck G Ner Yßß d: =d+dk k: --k+1 K3

` ýrYes

No Exit 'Succes'

j: = min(]. -1, k)

j Yea K1 Yes i: " +1 0

t-1 No

. c. t 'Fajlure'

Is there now decomposition

prvýith aAdud constraint VO that V11ýý.. 0, V3-I2r3ýýIPV

remain unchanged, but pj is longer?

"3+, Fig. 1+. 4.2

9M'

if k >k0 than

d: =d-dk-... -`k

[k: = o

3

but I ui+1 ýL vi+l We say that a(1)

is the next

decomposition after A a, if

a) O«<

b) there is not a decomposition Qa( 2) such that

Li«G Aa(2) .ý

La{1). ýý

Finally, ma, would object to the large number of possible

decompositions of the string CC into m substrings. But there is no

need to examine all possible decompositions. Since there are no more

than Nor errors, we must have IJui) -I vil Nor, and since OCi

must be an Ai-phrase, the substring OCi must satisfy some restrictions.

This is what Unger (t 2J has called ' quick checks' .`

,`

/ 1-

95

4.4.2.

The interest of , this section is to describe a procedure CORRECT

that takes an input string x, and, using the method presented above

gives the syntax tree of the. nearest sentence in the ], fie. 1+1

T+et C r(

nA 11 a) =d ui Qi) (4.4.6 )

fý r

According to, (4.4.5)

d (IT ,

Aa) = J(

TT , Aa) +d (A,

, 0Ci ).

Thus,, when the production TTA is matched against the e tring [X , uSiM ,

the decomposition Qa only the first tern A,

) is

computed, and added to d, which must be initially zero. Since, at

k

}

ti g1VeU STeP, lti 2.0 CWzW W" ;oýl6u% `J0 f^! 410i- % Wo -kQ 4#44V

sentence metasymbol), if d> Nor , then a new decomposition A,, rust

be tried. If there is no other decomposition, then next A-production

is used. If there is no other A-production, but A is not the sentence

metasymbol, then the goal oc of the metasymbol A is incorrect, or

probably the production that has introduced the metasymbol A is not a

correct one. In other words, often there is need to backtrack, to

cbcosýother productions, or other goals (decompositions), and the syntax

tree is constructed dynamically.

Let us first consider an ample. The grs nar

" Gam({A, Bf, {a, b) , P, Ais given

with- P the set of productions

Ttl sA --ý- as

Tit :A *ý ---'- AB&

n3 :B ----+- bb

ry TT4 :B -ý- BB.

The string w= as ab ba as must be analysed. This, evidently, is not

a correct sentence of L( G) , since each sentence of L(G) has

;; ý ý 96

an even number of consecutive a's , and an even number of consecutive

r is sought' b's. Thus, for Ner =1,2,... ' an A-phrase

e A "1 such that

dw tier) Ner

Let, us say_that the syntd 'treealreaäy built is. that. . 9f, ' fä. 9. tß. 4.3

(l A)A

(2), (3) (3) B (4 A (2) A

` j,. (5) B (6) Ilrý`ý (5) B (6) B'

a; ý, \\ 1 aaabbäa aabbäaa

a) b)

Fig. 4,4.3

The goal of the node (3) is the substxing abba. Corresponding to

the production fl4 sB -P*BB , this string has been decomposed as

.1{ and the first substring Is the goal of the node (5), and ba 'ab

ýf . is the: goal of (6). Node (5) has matched its goal with one error,

d (B 'v' ab) >s~ ý. , and d became S, which is not greater than Ner ý..

But analysing the goal of node (6) one finds cr( T[3., ba 1, and d

becomes 2> Ner. No other decomposition of ba (in only one part:. )

is possible, and the use of the production 114 leads again to failure.

Thus a new decomposition for the goal, abba I of node (3) is sought,

It is given in fig. 4.4.3b. Again d will be greater than Ner(= 1)

and no other production for B, at the node (3), is possible. The

. next backtrack must be to the "father" of node (3), i. e. to the node (1),

which must give other goals to its "sons", nodes (2), (3), and '(4); i. e.

a new decomposition of w is sought. But for all possible decompositions

-and produätions d Ner >_= 1. Then Ner is increased by 1. For R

Nor 2, the syntax tree of fig. 4.4.3a, can be completed, since node (6)

97

,f

t` ; &. iý

ý,

Ir

E

r: r

.: ý"r

i.: ' i ý= }ý

ýf-

ýý

ia"

ký it ý' li

match its goal with one error, making d2 and the node (4) xßll,

will. match its goal without errors.

Since there is the possibility of failure, it must be cl9ar wh3ch

part. of the syntax tree has been built, and where to backtrack. Fo

thispurpose each nonterminal node of the syntax tree is represented as

h`; nx a7 -tuple

, node =( name ,f, ob ,fs' pr r goal, , v) s

where-MM is the name (number) of the node, f is its father (or 07

first' ancestor), ob is its elder brother, fs is its first son

(or first descendent) rr is the production used by this node to match

its goa],, jLcLaj is the substring that must be matched " (generated) by

this nodeel and cJ is the computed distance pr ,' Qa) for the

= =. -- current decomposition of the goal oC

.' The syntax tree of the fig. 4.4.3a has the following representation

ilk (the question mark indicates data not yet known):

name f ob fs pr goal,

ý,: ý ýy E>> f. ss 7T2 sw o) ti

ýý"ý. slARi 1 -J'nl KS... ýt, '4` Rl ý°. -y y.

_. T"4 R 4ý ý? cF

0.4 P

A. u'i', L ? _2e _tryýn°F (21 a( 2, TrJ as, o <`jy. "`-. e r `i:.

C, ''}tip

. f'C-p`ý fFc,

; e' ,a[ f`4. ,

2,5,7t3 , abba 'o)

sE° (5)=( 5,3 f. £ ab 74, '1) (6) 6'3,5 ' £, it3 , ba ,I)

now found

0_ Node (4) must correspond to an A-phrase, but A is not present

anywhere in the representation of this node, since the retasyabol is

*1

represented indirectly by the, production. ' Therefore, when a new node

is built,, the production coaýonent cannot be ? -'

but the first_A-pro-

; '< .. `

,°: buct1on ?T(A, 1)

CORRECT (w) is the procedure that analyses the input' string w

and outputs the syntax tree of the nearest sentence in the language,

its-start is given in fig. 4.4.4. It builds the root of the syntax

98

{

7,; s v ri s T, ? .;

tree, initialises d by o and calls the subroutine NODE, for

A-= 'sentence-metasymbol', and OC = w.

CORRECT w

A 'sentence metasymbol' oCs ýw d2a0

Start building the SYNTAX TF Node (N) 10°p

Nersýl

Call NODE

d4 Ner No Ner; =Nor+. ti r" 1

Yes

Exits 'Success' d and

the BYNT, AX TiýEE

MID

Pig,. 4.4.4

The subroutine NODE builds1a very limited part of the. syntax tree:

the branches descending from the current node (M). 'A'- is the metasymbo1

corresponding to this node, and 0C is its goal. Thus the subroutine NODE, rf

lY

. must bhooee an A-production

'1T $A u1 Al u2 A2 ... ul . A

99

.,.. r�x..,. ur"e-ý7. ea. rV. _ ar: .. __. _ .. x+g.,... _ .,.. r. .. Y.... r*r- _ie- ,a... _ . e.,. _rer ., ý-. _., _st°ýPn.. 'rf`iwA "t a^ý

rI

P

F '.

i

Yt

starting with first one, TC( A Corresponding to this production,

the subroutine NODE must initiate 1 new nodes in the syntax tree. Their

father is the current node itself. Also a decomposition Qa of i. ts

goa. 1 oc is sought, and the corresponding goals ai are assigned to the

corresponding, just initiated nodes. Also Jr( TrA ,Zr) is computbd

and, if d+ cr( ITA ,L a) is less than Ner , then cT(TtA M)"

is added to d. The current node is changed by its sony, correspondin

to A, IA becomes AI , and OC becomes OCj. . The subroutine NODE is

called again. If the current node (N) has no sons, i. e. the production

7A has a terminal string in its right hand side then the next current

node must be the younger brother of the father of (M).

If d+ cr( Tt A, a) is greater than Ner , then a new de-

Domposition of c is sought, and new goals are assigned by NODE to

its sons. If there is no new decomposition, then all sons of (M)

are eliminated from the syntax tree, and a new A-production is considered.

If there is no other production then NODE declares its failure to its

father, which must give other goals, S. e. A receives the value Meta-

symbol (F(M)), where F(M) in the father of M, M receives the value

F(M), and CC is the goal of F(M). The procedure NC DE is called again.

In other words the procedure backtracks to a previous node and looks for

another decomposition of the goal of that node.

The procedure NODE is given in fig. 4.4.5.

There (? A) is the current' node, (N) is the lnet initiated node, A is the

metaaymbol correopondir to the current node, i. e. Aa LI ( Pr (M) ),

where Pr (34) ja the current production used, and LIZ (n) mewls loft

hand side of the production rt . P3 (9) is the first eon of M' 013 (M)

is its older brother, and d (MC) Q cr(Pr (M) 9Qa).

100

NODS

lie

i :=t

1

Corresponding to the produotion ]t(A, i): A --a. u1A1u2A2... u1Alul+1

choose the first decomposition:

pa: Oc=v1 Oc 1v2oc 2" *V2' 1'71+1

If 1: ýi+1 do: begin 3S(IZ): =N+1; OB: = E;

for j: =1 until 1 do begin X: z N1.1; add the node Q : =(NsM, OB,?, n(Aj, 1)s 04j o?

)

to the syntax tree; OB: =N, - end

end

i

1'

dlLszcýýYTtAri} Tal d :: d +d�

ys

If M has a on then k: =FS(M; else 9: = the immediate left 'relative' (uncompleted node), if there is one, else go to IOD;

A: = L'HS(PR(M)); c := goal(bý);

NODE

END

nge the goals of AI A2...., A1

Yes

Is

d: = d- dý there other oý decomposition

corresponding to rr(A, i)

No

i: = i+1 Yes

I

1 No

N := M-1

M :=P (Y) A: = LH3(PR(M)}

O: = goa1(M)

Fig. 4.4.5 END

101

NODE

4.5. SUMM

Some algorithms for correcting sentences in three classes 'of,

languages have been presented in this chapter.

The global top-dotim error correcting parser presented in

section 4.1+ is the most general one, valid for any context free

language. Being so general there is a need to improve its efficiency,

and this can be done by combining it with other, more efficient error

correcting parsers. After all, any A-phrase of the grammar

G= (N, To P, S), can be viewed as a sentence of the grammar

G(A) = (N, T, P, A), as has previously been underlined in section

2.1. Thus, the importance of error correction in a regular language

is evident, even if it is laiown that a programming language is not

a regular one.

A simple precedence error correcting parser can also be used to

improve the efficiency of the global top-down error correcting parser.

This will be shown in the next chapter. But the simple precedence

error correcting parser, presented in section 4.3, has its own

, Importance since there are simple precedence pm rc ing lr.. hguae; es

(EULIIR, for example, see Wirth and Weber [w4J ).

4

4

a

102

V. THE DESIGN OF AN 1. ROR CORRECTING

PARSER FOR BASIC-LIKE LANGUAGES. `

"1

In this chapter vie are going to design a global error correoting

parser for a context free language. To do this, the methods of

analysing and correcting strings in a language, described in the

previous chapter, are used.

Then a partial implementation of this parser is described and

discussed. Some results and the programs are given in appendioos.

As often happens, a real implementation is a. trade-off between

the theory and some practical constraints. In trying to implement

an error correcting parser for a programr: d-ng language two important

factors must be taken into account: the speed of analysing strings,

and the memory required for coding the algorithm. In some cases the

available memory does not allow coding of all the parsing methods

'used in our design. Nevertheless, if there is cnourh memory available

for coding, the designed algorithm may be implemented., because it may

offer a speed advantage.

The global error correcting parser designed, in this chcptor has

been partially implemented and this is discussed in the second part

of section 5.2. However, the only practical constraint that prevented

full implementation was the short time available for coding Enc

I debugging the program.

6

1

'.

r

r`

103

4

5.1. THE GENERAL AND PARTICULAR FEATURES OF BASIC

Although the BASIC language is specifically referred to in the1'title

of this chapter, this work could have been applied to many other pro ra ing

languages: -` Nevertheless all examples are taken from BASIC, and the ýitle

expresses- this fact.

The first important characteristic of BASIC is the presence of 11

delimiters at the beginning and at the end of each! otatement. This

fact permits one to analyse the correctneris of each statement.

The syntax of BASIC programs is given in appendix ja. There

are two variants presented and both are very simple for parsing.

The terminals for this 1anguAce are the statements, shown in the

appendix.

The language of all correct statements is described by the syntax

in appendix -. b. The terminals of this language (26 letters, 10 digits,

and the other special characters) are the basic symbols that mty be

corz'qted by the noisy channel. This in the reason that one does not

consider a lower level of analysiat the lexical analysis. Very

often-there is not enough contextual information to correct errors

at the lexical level. That part of this language which is used by

compilers and interpreters in lexical analysis is; given in appendix 1c.

The language in appendix 1a is a very simple ow , ani easy to

parse. This language does not have sufficient redundancy to permit "

, error correction. We can acquire some clues from

a) the dependency between FOR and NEXT statements.

b) the ED statement, which must always be the laut one in the

pr'o .

*o) some redundancy which exists between GOCUB and return atcnmentm.

d) the second variant in appendix I, requires that the DIM an

DEP' otatomentn must be at the boginrjng of the proms+m.

104

But this information is not sufficient to correct errors. \ For

example, although a= -statement can be detected as missing, we"\

do not blow where it must be inserted. However, missing, inserted,

or changed statement are errors that are very improbable, and it i4

almost impossible to correct them, using only the syntax.

The level at which the majority of errors are found and many of,

them can be corrected is the language of the "statements", given in

appendix Lb. This is the language used by an interpreter, and from

what has been said above one notes that the majority of errors

correctable by a compiler are correctable by an interpreter. The

error correction in the language L is discussed in what follows.

The language L is neither a regular one, nor a simple precedence

language. It is not a regular language since it contains arithmetic

expressions which are not regular expressions. It is easy to prove

that the set

L={a ben

is not a regular language. Also L is not a simple precedence

= language since the relations e, and a>e, both holt.

Sometimes it is possible to modify the grammar into a simple precedence

one, but we are not studying this problem hero.

Although L is neither a regular nor a simple precedence

language, it is a finite union of such languages. Note that the set

of all DIM statements is a simple precedence language (this larwuage

was used as an example for section 4.3)

The lexicon of L can be described as in appondix to. The use

of this lexical language permits one to reduce the length of the

string which is analysed. The difficulty in analysing lexical words

using the syntax of appendix Ic, is the absence of any delimiters to

mark the beginning and the end of the strings. An important

105

characteristic of BASIC, although not good from the parsing point

of view, is the free usage of the blank space. Although this

language is used in the lexical analysis phase of compilers, it"is ,

} difficult to use it in error correction. In fact the errors occur

at the ayiabol level, with some missing, inserted or changed symbols,

One believes that the language L must be built on these symbols,

and not on the elements of the le±ical language.

z 'the structure of BA. SSIC, and many other programming lax es

a major role is played by the reserved words, such as DIM, =t READ,

etc. , Always, when one is scanning a program, those are the

words that help to identify immediately the type of statement encoun-

tered. -: Thus an initial top-down error-correcting parser seems

natural.,:

}F

die y 4 ýY

yv

.A

:,

/

106

N

i

5.2. STRUCTURAL DESIGN OF AN ERROR CORRECTING PARSER FOR BASIC

Some algorithms for error-correction in various classes of

languages have been presented or reviewed in previous chapters.

To implement a practical error correcting parser for BASIC, we

have combined some of them, to improve the speed of analyses and

correcting input strings.

In the section 4.4. we have devoloped a pure top-clown error-

correcting parser. It can analyse and correct strings in any

context-free language Nevertheless, being so general, and by

verifying a large number of decompositions of the string, the

algorithm is an impractical one. Therefore it must be improved,

and this can be done by combining it with some special parsers,

for subclasses of languages easier to parse.

1

The most important part of the global top-down error correcting

parser, was the subroutine NODE, that calls itself recursively.

This subroutine was described in section 4.4. and its main task is

to analyse the goal cc of a metasynbol A as an A-phrase. Since,

for several netasyabols 'A' of a grammar G-(N, T, P, 3),

the grammars G (A) =(N, T, P, A) are special ones (regular,

simple precedence), it is suitable to analyze the goal of in this

special-grammar 0 (A) . Therefore a switch from top -down

parsing to otliEr methods of parsing, is indicated.

We must decide first which methods of parsing are to be considered

jD)V our design. Here, the four methods presented in chapter four,

are considered. Thus, for D11 notasymbols A, the type of parser t

required for the grair r G(A) must be knovn. This is given or

computed, when the parser is designed. Let Kind (A) be defined

as follows:

I

107

-, ý ý', "V 1,

Kind (A) =

ý. , if a simple precedence parser'.

is used for analysing strings

in L (G (A))

2, if a parser for the regular

language G (A) is used to

analyse a string"in L (G (A))

3, if a transducer has been built,

for analysing strings in G (A)

4, otherwise.

A program that checks if the gir rG (A) is a simple

precedence grammar, is given in appendix 2a. In fact this prograw

computes all precedence relaticrs between the symbols of G (A) and

gives the precedence matrix, if the grammar G(A) is simple precedence

grammar. The result of running this program when the grammar is the

grammar of appendix lb, and A is the metasymbol corresponding to

arithmetic expressions, is given in appendix 2b.

Let us turn our attention to the algorithm for analysing and

correcting an input string w. The analysis starts in a top-down

manner, and the procedure NE=DD is called., as can be seen in fig. 5.24.

This procedure checks Kind (A) to decide in which way the goal

of the metasymbol A must be analysed. According to the result,

it calls one of those four error-correcting parsers described in the

fourth chapter. This can be seen in fig. 5.2.2.

The PREMENCE subroutine takes the goal oc of the metasymbol A,

and tries to analyse it in the simple precedence grammar G(A) , as

has been described in section 4°. 3.

The REGULAR subroutine analyses the goal of of the meta3yraboa. A,

in the regular grammar G (A) as has been shown in section 4.2.

ýýý

ba w

Cola"ICT 77

A: = 'sentence'

d: = o ýý .

N: = 1 t` M: 1

Start the Syntax tree with node 1 := (1, Of 0, ?, n(A, i), a , ?)

Ner :=I

NEINODE

dN er NO

Ner: = Ner+'!

Yes

t Prind d and the

. Syntax tree

End

Fig-5.2-1

., ý

log

1

\1

Fig. 5.2.2

t

110"

I

f ýNrikb; u

The TRk=DUCER subroutine transforms the input string oC into

a sentence of L (G (A)), as described in section 4, i

Finally, the subroutine NODE, the same as in section 4.4. E _

continues to analyse the goal cx of the metasymbol A, in a top-down

manner.

The global top-down error correcting parser, described above,

has been -partially implemented as a FOPTPM program"1 .. This progrNn

is given in appendices 3 and 1..

The top-down parser must start with the sentence metasymbol jo ,g

and the goal vyr , and it must choose an 9-production. Instead of,,

generating all decompositions of w for each a-production , the

reserved words are used to find the most likely one. The algorithm

for finding the distance between two strings, described in section

3.1., is used for this purpose. The subroutine DISTANT (appendix 3)

implements this algorithm. When the corresponding reserved word

, is misspelled by one or two errors (even more for a longer word

there exists a big chance of suoces2. Certainly if an intended

reserved word is replaced by another reserved word, this method

fails. In a complete implementation these errors may still be

corrected, but the price paid for doing it is much higher, and the

real gain is negligible, since these errors are very improbable.

Moreover, any input string yr can be transformed into a correct

BASIC sentence by adding only three letters, since

REMw

is always a correct sentence of BASIC.

For this reason, the 1

top-down part of the program attempts to

determine the type of statment most similar to the input string (the subroutine MATCH). This has been done, and some results are

given in fig. 5.2.3.

$, r' ý4

ýý ýýt M

vý4ýý F

1^i:

ý'r, ý'. ý

i : 4ý: ýý ý

ý äS'RT

ytý

, ýr hý 'ýý

xlJIM. ""K3000), 02(100)yi"«4<. too)ýu, IM,, $ifºpelinq: probrahl, the sC; "Yitk..! i1("e r1r idit(' I Ir'' : 0;,.

tIEFFNG (Y) = Y*'Y-7.09*'Y+7f-t . sentence produrtjon iii n

11 E. FFN1. f2

00Rý.. Jx3TU34STIP44: IiE spe Iinq prcai: )a bJ. y then ºt T1A. ", e17r. e pr 0rt',. ir.: z nr1 'i 1. ,..

F0R afT 0 tw

4

a

.; ,ý

ý, _.

ýý. ýMý.

r . 'aü

NE.. XT V 31- misspel. ing: probably the svntencxa cirodt. icttt ni�..

NFXTv

RFFURNi rnisspe]. i. ng; prahr. xhly ,

the iintence prciIuc°t. lori ý'.. 4. RETURN

GOTU500 l . t! speling i prohnhl, the sentence prof ', tct: 1. on ii»,.

(3 0T0.

PR1JNT ' ABCDEF: ' , T-04: mibspeling: prahnb1.. the sentence ; 'rf)d. fartArIll Y. -

PRI NT p1 0

fa . ,

RETOREI miss cling! p probably the sentencA prnrli. act: lon '"

RESTORE

`tl

SRO/ 'z

imiesspeling l probcýbý `: they merity nca! Tprvidl.: t inn i n.., .,

2.3, x ra? . 112

RAIº T(I)yU(1y, ))1: mis cling 1 °- probatory, the sentence production is..

READ r].

GOTUB900, misispeli. ng: probnbVI the Sentence production , iri. 00S tlkB i

4, op, I % r;, y ,ý..

1.. ESGS (r, *H+? s ) =F-ß 4t misspaº1ing1, prohah y "tho sentence präduiction At...

in. is pea inq: prohº. xb. ly the sentence prrºr1"e i,: º ors � EN tt

\'

L 1

a

,r

Once that the typo of the statement has been found , the parser

(subroutine DIRSJ , in appendix 3) calls the other procedutes of

correction used in the design.

TRANSDUCER has been used only for DATA-lists 9 as describbd in

section 1.. 1,. This subroutine (called TRANSD in the program of appendix

3 ), transforms the strings folloving the reserved word D1, TA as 'pan

be seen in fig. 5.2.1.

Many parts of the language are regular expressions . Yýoviever ,

since error correction in a regular language , described in sect±on

4.2., does not raise any special implementation problems , it has

not been tested.

Finally the subroutine PRECEDENCE (given in appendix 4) attempts

to implement the global simple precedence error correcting parser

described in section 4-. 3. The recovery part of the error correcting

parser is called when the scanning phase has been completed , and the

whole input string has been analysed and condensed. Unfortunately, this

subroutine has not been competely debugged. The scanning phase ( 1.0.

the implementation of the flowcharts given in fir,. k. 3.3. ans fig. ) 3.4. )

analyse a correct sentence, or condense any input string according to

`, the reduction rules of the grr-=. ar, as can be seen in fle, 5.2.5., and

5.2.6., respectively.

We already know (from chapter ! +) hove the errors must be correcteJ,

and the partial results discussed above confirmed this. however , the

error correcting parser designed in this section still rciiain to be

completely implemented and tested in rin environment of B1'a IC users.

In 3mplementinE; the plgortthm, tho speed of parsing correct sen-

tences remains the same as for the non-error correcting parser ,

which is a very important feature of the error correcting parser . But

a price is paid by having an error correcting parser , because

113 r

"", 7 ý

I'AATA 44.07,0702 3,906N. 45 iri: speling ! prcybabf. the sentence produc. L: i. on . is.,.

DA 1' A du

llr« 44.87 rlr « 8/ tl l" � 23 rlr : 986 ltr: . 45

L'YTA23,981/, #675,221.98, _-98111 miCi5peling! probably the sentence production it..

DA T" A da

Iii M T3

981. Ors 6 T5 0; 221.9EI il T`: _. 98

I: '. ATA11444444. --998E432,89755* i i. i peling prohub]. the sentence production Lyr..

E1 A T" A dr. 1

ltl « 11444444. 1'lr : -99SE43 ltr « 89755

LI3TAA ; Z3 .E -O9L't123, F45611; 1Nisspeling! probsalbI the sent"e1'1ce product: Lon i? s>.

LI ATA da

or" 3. E-09

vi r« 12.

qtr « 456

I: IACA -ß. 7r, . 675E--04 v561 IL ssPe1ing! prob'abLx the sentence pruI. iI. x.. L. Lrorl It,

LI ATAd,. t

or: 8�Jf nr: . 675E-04 11T`w! 6

"

Fig. 5.2.4

_ : plr aJ? ý m LESßß (5* H+1) =R-PO "-: ý'

n sspel. ing! p ro bcibl. y t hiº ', e'nt vcýr K: irortm 1i. ycýn i^.... r

- ̀ ¢"... let f

suck a ýk C. M, stor.. ke ) f_ ý. 8

". stack LtC v (' ýC I = ctnck: 0C v ( I" 'i 0 { t{xck.: 0C v ( { ̀C

., stück: 0C v ( !" n

. stackxz; . 'C v..., (' r ", c .. ,., ,-

, tack a0, C v ( [' Stack a, (C V C , ruf " ._ tor: k: 4C v r H .. Stack :. 0C V. _.. ( C. 'to * C v StockA *C V ( C t0 ' C ar Strack Ot C_ ýY" r .. t0 * r "fa Rtnr.. kit #C v "(,

f ßt0 "* m4' gtRCk. I Ifl. v C f. to

, stacks 0C v ( C +,

stick '# C v ( C {0 + stnckr : 0:.

_ C

,. v. (,. C .0 + C. . i, s"tn ck a\ 4C v ( C e0 + C n sctack-t? ýký ý'. ý: "v'::. ( C 0 + C. c stark: $C v ( C e0 + C FBI '

stack i "* C v r.. " eo + C m"r

17, eo ct, º, ý-k r_ v < C 0 43'r. +)rk 0C v ( M )

C, +, *1 f. k :'C ar ý" C R is-tack: #C gar -" C. 1, ct'ick :* 1' nr = C v -stn ck 4C rar yt. ck. II 0C {a, r C "Fc1 st, ac. ka

_4 f_ ar r, mf

<A. ick: 0C ar ' t. i ck .0C ar 't n r. k: 4C {: i r - 0 -- C P stark: .1C nr C

" ý: ý 0 -- C stack dF C -ar C kx0 -° f. v <. s"t{ac k: 4C rar C eO - C air stack :4C 01r C ký0 - C F, "), is t. ck:. 4C nr = C e0 - C m. r strack :$ f_ ar = C ýa() - rt , cý stick C ,: ir = C 0 - 'l, st. ck.: #C {7r = C t?, 0

<3 tQr_ke 4C ar = e, -, ! stack :*C s

ý- ,. ' .. ', "

t4 ,uiC.

Fie.

: yam .. i "' 'tja +'y, <". _

)

T

"C }'t , 'ýý 9F ' '

}< ! d

(1

w. F

DOM L (20,33+, F' (hi 7) t mic.; speling: proba41 y(�thrx e1')'t ne production i ;.

LI M ld

stack: *C L n to cktC V. _

.(C stack a4C v(C i0 0

,. tack: 0 ., L .k ß vtC %0, . ý -stack: 0t v(i. C' 3

detection point: 12 "::: A'-UAML (2O, 33+ y stick :4C v(i,.. C i0 3 '

C P stock: 4 ý, C vi'I ý 3, Ü"-'i " 'ý' C v ( C 9 : tack :4C v I` .03? ,r v C 10 7

stack: .1.. C v(i, C ' i0 -, I ? ,C v ( r. I 0" stackC v(1. '1 i0 32 'C v ( i ) stack: . .C v<iS. A .3

" LiJIM K3(900). 02/100 )*

IELsspelin g! prob' h1e the sentence pror)ur Lion UI M id. ., dingy .,

stack.: ý 4, C K i. 3 y'tack: 4C v(C9 stack, :*C vtC i0 0 stark: *C v<C i0 Q stack; *C v(Ci, 0

detection point: 1.3 L'MI IMh3 (900).. 0 detection xpo. int: 16. DJ Ih1K'3 (900) . 02/ 1.

stack: tC v(i? 02 stack: 4C v<i)? Q2? )1 0 stack: 0C v(i)? 02 1) 11 () 'I Ö stock: C v( : i. )? a22 ) (ý "ý (+ )

i. ýý

ti

i.

d

l' ., J

. y= 'rgý !ý,

ýý

ýSw

" ate'-

Fig. 5.2.6

. ý"ý 'ý

116

:',

r+':

Al ýý.

y var

much more memory is re ir. for coding the algorithm. The other important

fact that came out from our implementation is the inadequr. cy of the

FORTRAN language fr dealing with sets, strings, lists, and other data

structures. Certainly this fact contributed to the need for looking only

at partial implementations within the time span available for tl is

project.

ý ý.

ýý

ýA

0

1 6

117

cyý

Pý5^

VI CONCLUSION ANT) F3TURE WORK

I possessed the book, for years before I, could 'eke out what it meant. - Iid. ded, I did not understand it until I had myself indb- pendently discovered most of what it contained,

Bertrand Ruasdý1

6.1. WHAT ARE THE RESULTS OF THIS THESIS?

We have investigated in this thesis the problem of error

correction in some classes of languages, Various error correcting

parsers for different classes of languages have been presented. Then

the design and implementation of an . error correcting parser for BASIC,

based on these error correcting parsers, has been described and evaluated.

In dealing with programming languages we have studied their

mathematical model: the class of context-free languriges. This

class is too general, and many subclasses of languages, with more

attractive properties, are known. The simplest one, the class of

regular languages, is not good enough to represent any existing

programming language. But there ßxists a simple precedence

programming language (EULER, for example rW3, W4J). Thus the

problem of error correction in a simple precedence language has its

own importance. Moreover, the algorithm for parsing a sentence in

a simple precedence language is a very simple one.

The main results of this thesis can be found in the fourth

chapter. First is the global error correcting parser for a simple

precedence language. Second is the global top-dov, 'n error

correcting parser presented in section 4.4. and designed in section 5.2.

"A

118

ark: x: _4` ; ý; ý

The problem we attempted to solve is how to use th.

whole information available from an input string in deciding how to,,

correct the errors. Both error correcting parsers presented hera tvo a

solution to this problem. At the same time thW proceed at the same\

speed as the original parsers in analysing correct sentences. This

is so, becmm e both parsers have two modes; a"atanda$ mode" and an

"error correcting mode. " The standard mode contains the original

parser, and analyses-an input string until an error is encountered.

Thus, if no error is detected, the sentence is analysed using only

this mode, in the same way as the original parser.

The global simple precedence error correcting parser has two

phases. A "scanning phase", that scans the input strings, detects

simple phrases, and condenses them to corresponding metasymbols. Also

the errors are detected, reported, and the detection points are marked.

Then a "correcting phase" analyses the information stored in the

stack and decides how to correct the errors. The first phase analyses

any correct sentence and outputs its syntax tree, such that no price

is paid (from the speed point of view) in having an error correcting

parser (see section 4.3., pp. 63) .

The same can be said about the global top-«3own error-correcting

parser. It analyses a correct sentence at the same speed as Unger's

global top-down parser does. The only difference in implementation

is in the size of memory; additional storage is required for coding the

algorithm for error correction. In fact the error correcting paroer includes Unger'3 &, 7. obal top-down ps, rser. ncaao 1Nor=U)(aacs sootion

At the end we can say that the problem of error correction is

not a theoretical problem anymore, from the syntax correctness point

of vievr. Prom work of Aho-Peterson rAIJ, Levy (L7J, Lyon D40 _7v

and in this thesis, it results that there always exists an algorithm

for correcting errors in a context-free lancuage. That is, for any

119

input string vi , there exists a sentence era in the language,

and ö can be found, such that

d(w , wo) = min d(w, u), -

uEL

where d(w, u) is the distance between the strings ww and u. y

It was clear from the beginning that the problem can be solved t

in a finite number of trials (even if this number is very large).

Such a solution is often called "trivial" in mathematics.

Nevertheless the problem is very important from the implementation

point of view, for any error correcting compiler. There the spied of

correction, and often the memory required for the algorithm, are

important in the sense that alternative implementations may be

assessed on the basis of these parameters.

We have not defined what an "optimal" error-correcting parser is.

Interest was confinec° t-

design of an acceptable one. First, a global

simple precedence error correcting parser has been presented in

section 4.3. This parser attempts to analyse the context of the

entire string, and to use it in deciding how to correct the errors.

Nevertheless, the parser tries to correct the errors as early as

possible when no ambiguities arise. Then this parser together with

other methods of error correction are used to improve the global

top-down error-correcting parser for Basic, presented In the fourth

and fifth chapters.

. ý,;:

ý.

'i

7

120

i

6.2. WHAT REMAINS TO B1 DONS'?

As Turing has said: "we can only see a short distance ahead. "

The whole subject of context-free languages and error correction in -

such a language is a relatively recent one. This thesis presents

what is known to date on the subject. Although there still remain

many things that can, and need to be done, now we can see a little t

further.

In trying to implement an error correcting parser for BASIC

(using the FORTRAN language for programming) some very important

problems were encountered.

In mathematics a problem is considered eblved when an algorithm

to solve this problem is found. We can all agree that this is a

very important step. Nevertheless the existence of such an algorithm

does not solve the problem completely. There is a need to write

a program (software) to implement the algorithm. However, the way

of writing software free of bugs is not the main problem. Books

and articles about structured programming exist which attempt to

give an answer to it (for example, Dahi, Dijkatra, and Hoare (D3,7).

Rather if . one is going to implement the work as done in this

thesis, one must underline the need for better high-level languages.

Often one works with sets, lists, or many other data structures.

But it is an unpleasant task to write FORTRAN programs dealing with

sets. An attempt to develop a set-theoretic high-level language in

presently being investigated at Brunel University (see Pollard (P32),

and this might help with the future work in this field.

Certainly there are other 'things that can be done to optimise

and implement different error correcting parser. But it is felt

that it is-worth while to think about other related problems.

These are the so called "Artificial Intelligence" problems. One is

automatic program generation from some acceptable specifications.

121

A second is proving program correctness [B3., N 4Z. Also, studying;

programming languages, and studying natural languages are, soraehovi,

related problems. A result in one can help in the othor. 'Work, op

understanding natural languages has been done by 'idino;; rad C1-15 ], pr

Marcus [III , J.

We have seen that minimum distance error correction is not thq

best technique. Our purpouse was the syntax correctness of the pro&rczi.

Nevertheless a program that is s3nitactically correct is not always, c,

correct program. Man-machine cor: muz icction has been studied, but we

have not used the fact that the inforznation transmitted is r eanjxi ul.

Thus, the natural continuation to our work would be a theory of

semantic communication (see for example, Dais /331 I ).

i 6

122

ý, ,. ý ýý ,. rr,. yý Er_ ,

? 6.3. FINALLY, 17W IS THE REAL NATURE OF THE PROBLM

Cel ce gindeste Singur si scornone lumina

A dat o viata noua si-un om do fier, masina, Fiinta zamislita cu Cindul 31 visarea, Ne-nchipuit mal tare ca bratul si spinaroa.

Tudor Arghezi

(Translated on page 161)

It is known that there are many gr nars for the sane language.

It may be of some interest that a programmer does not think of a

particular grammar when he corrects his program. He has learned the

Language, and he recognises and corrects it almost instantly. Alan,

when V . --child learns a language, he learn, first the meaning of

words, " of-what he hears and says. Later. in school , after many

years,, he is taught "the granmar" of his language.

The problem that arises is how can one describe the process

of learning, and host can one aodel it ? Thinking of these , and

other "artificial intelligence" problems, and how to use computers

to solve them, the questions: "what is intolligenco? ", or "how

does a machine store knowledge? ", arise naturally. If a machine

already can store information and can use it in making decisions

(much more quickly and more precisely than a man can ), one can,

say_ that it has -some

"intelligence".

There is a great deal of research in this diroction. At Brune].

E F .; tti .ý `' 1 :) ,ý : ý; v

University, for example, the "intelligent automaton group" study the

property of adaptive networks (see for example [A., A5, F2, 't7 ).

In [A, 57 Aleksander said: "Machines are now being built which for

the first time exhibit "intelligent" behaviour at an'economical price.

They are considerably different from conventional computers ,

accumulating experience from their environment and scanning it in a

manner analoguous to human thinking" and "concepts such as learning

123

., t, ý.. ý_ ý _ý

of speech, language and music become clearly feasl. ble",

In this work something has been learned about context free'.

languages, the process of sentence recognition in such a langühgq

has been studied, and a global top-doma error correcting parser

for BASIC has been designed and paztially implemented. Many

other interesting problems have been mot, and vie have asked

various other quc3tion3. However., one can say that the piob1cc

of error correction treated in this thesis is not on isolated

problem, and the proee33 of gaining knolud,? e is not a single

problem, but a succesive entering of different related areu3,

at different levels of understanding.

The author's experience has been one of having, his curiosity

aroused by asuccesion of related fields, which, when enterucý ,

generate neig questions and a desire to enter now fields. Thin,

however, is no different from the human curiosity for acquiring

knowledge. How to describe and understand the process of learning,

its arousal and stimulation 2 This is the most general "problem".

124

3' 'ý` C. +IB . I06RAPHY

ýý

I 1 1

Al. A. V. Aho, and T. G. Peter<:; on, A minimum di ataance error cor-

recting purser for context-free languages p SIAM J. OTJ

Computi. ng, l(1972), 305-312.

A2. C. N. Alberg'i, String similarity and mist pe1iingra,

CACM, lO (1967 ), 5,3O2-31;. 5�

! 13M I» A1eksander, rin tF wK Hii lrºiay Automata tl, %oorva ': in ýD1'1(ýJ 1'i itýiTaººý, 1

4ppra'xcrtý Cramp; ýýýýwºr System E: rirjineerinrj Ser 3. es,

u; i

_y, ýT

: ̀ä iý

Crane Rusk. , 1976 .

A4. I. A1eksrarider, Artificial mnt, elligaancep Electronics and Powor .,

: 2221976), 4,242>»' 24.

A5. x. Alekt . antler,, Eloc:: t, rc. nu. cti for tn'l t . llirja nt, mlxc:. h. l. iid ºay No. ýw äc; ß, rat..

"gist Und Science JOur nat. y 11 . 3. T1.1971.

1: 41.. M. Beiis, A theortj or i4emranntic communic: 'atiortp F'rucoodl. ngtº of

the 3r World Congra. >s of C jJ: )ertineti. cs, 1,113 h' refA 197U.

-ý= 1

y r .

ý'

'ýý

ý, t 1

. ýi+

zýý

,ý.

B2. C. R. B1 iir, A program for correcting spelling errors,

Information and Control, 3(1960), 60. -. 67

143. R. M. Burstai1 y Some Technique; for proving curry. *ctm-twa

of Programs which alter LIi ti: x Structures,

'I Machirre Intelligence 0 7( 1972) 7(i972), 23-, O .

ýf

.j

ýi

ýý Y

ý?

Cl.. T. E. Chei tham, iind T. St'mdi. ah, Optimization 'x 'acts of coi piloy-

eoMpilera, ACM Sich 'l': tn blot teýr;,:; t ß, 91U), lü, ], Uý] "l'

C2. N. Chomsktj, Three models for the description of language

IRE Trans.. Dnform. 'Thoory, IT2(19 56) , 113-1'_4 «

C3. N. ChomskV, r111d G. A. Mii: lier, Finite state languages, Informs t: io i

.;

,a a" ýý+ ýý

rý.

and Control, 1(19:, 8), 91-112»

CA. R. W. Cannwsy, ianr1 T. RHW: iico , I'e zicjn and of to diag.

nostic compiler for PL/ I. , CACM, 16 (197Z3) , 3,169.1'79.

A techinque for computer F. Lnmerau te`tection and correction ,

of spelling errors, CACM, 7(1964) , 3, i71-176� ``

1 ýý

>4r ýiiýýý1ý"'ý!

ý`ý4ý ,, ýr" ýýýý?. " ýM ý"' y ýý' f

ii ýFLS'. . ýý-8. ß'"'r ": i' ý(_FO-°C1h: tý . 'G '4ý}ýrN. ý

'` rr $e"ý °'"'ý"`1�ýy nkýn ;.

ý -.

ý ? ý.. yýý: {ýf'(ý, ý , 14. ,. 'd #

n'w4, ý. ý4 ýýJi`

91Vy. ryýý"a'ti ý, t

. 'V$': ýýýý. 'ýýaý,,; y'ýV , M.

'ýiý r ,ýtx. - i

r ý , >M a

{'t'ý' dl `ýk -"y`{v tr, 1 Kýýt '

. ýý t f

k ft ; 4.; hRyý: ýt. ýaq.. 'ý V; .l", 'ýr Rfi

+"

ý, .. . 1L 5'

ý

ý r ''I ý', -'ý/eA' sttý5

. "

02. L. Davidson, Retrieval of misspelled names in un '::. r tin! "s

passenger reservation iiysth*m y CACr1,5(i96. Y)

,. ti, j69" 7. .

U3. O. -J. IIºxh1, E, W. D. 1jksLrºa,. º1nci C. A. R. Hoare, ; Structured progjºanr--

i inn, Academic Press, 1972.

L14. R. K. L$onn 1lj, An overview of º1'. i". iociative processing -For

non-numerical applications, Technical Rep. G/Ft/039,

Erune1 Univ., 19'76«

TJ5. J. Dyke,. in'1 M. Lw.: i, An associative parallel prucennur for local

editing applications, Digital Processes, 1(IM), 2peY--101.

EI. J. Eiarlecj, An efficient context-free parsing 'i orithm, CACM

13(1970)p', ";. 1194-102.

.ý :! t

9j

1 r

l

C i

r z. 2. L"+. E1s p1sýM. V. Grt*uxri, ': nd R. N. Le. vitt, Software re1i.. aib: i. GiLkjv

Camp '. tter , I. (: I9I1. ) va r: '1, ''�

I° I. . J. Fýa cirºa rº, 1.1d L$. (")1 º. & i01 r''; aºº-. u1'; xturr wi'.. t Liº( i: ººJ-,., 1, vAr, i% p C;; ALr),

F2. C. J. Fwrn'; ndt zo Frdl; xp .t vi tüA; rýýý, au rrý.: ~a r"i »uj rr. Atialº W. L Ck Aloolor tj

k)1 muflt, E, Phi! Thevi ? {runnoI UII. LvOr-1-altt, (Lt. ) late Lt, ud, M F 3. f. W. FIoljf

' rtjYl'ta. 1(:: 1, J. (� -1T) 111ytii '1 1.11'1v: L 0pora: l'l', ur 101 (C'id ate, I Ico0 JAL(iy

1Q( 913)

F-4. E1. N. Freom'an' Error correc. tic: yn in C; URC- tt-te Gurººiýll c: onºp'. it.. A. nJ LQY1fýUI CJe, ProC. AEIP$, 26(1964), 1 ; --ýýa(Or in r; ý:: i pp. 233-304).

IF5. M. Frenti. u, Irrar correcting codes, MinLthe i ;, Urui"uol

UnivE rsittJ f 1975 (unpubli head) , 'ýk 01 S. Gins bury, The mat I komat. Lca I th ahovj of co IIt ký.,. "l. +"rok* l 4n gºala(jo%

tc Oriw HiI1 y

ä, 11G:. v 1766

a

ß ß. L. 0rQl" am, ond t. P. ctha wc;, V'r oac�tir: cal wjritucta. L orror rouovor

CAC M, 13(197s) 1.1,639-05O.. , 03. U. Orie ;, 1'1ýe u, u, e of "týrýarý<�;: iý i, cart matrices in G, camý, ý l ýtrý, CFaLM,

1ý, / 11(16t3 ,1 26-34 � -, q yy , P""' '71 , , 1°' °a-.. -

126 ' 'ter. wý ,, ý ý, rýý sý'": "ý .. .., ý

-ý 'ä.. ,,... ,.

04. t'. Grien, Compiler construction for digital computer<s.

W: il. etj, 197 i. .

I-11. F. R. A. Hol-. lgOC) 1, Compiling techniques, MacDon'x1d, 1969.

11. E. T. Irons, A sq tax directed compiler for Algol iO, --

CACM, 4(1961), 51. -55.

12. E. T. Irons, An error correcting paars algorithm, CACM, 6(1963),

1 i., 669-673.

J1. E. G. J'ame , land Li. P. F!. rtridge, Adaptive correction of procarani

Statemeyetay CACMy16(19 3),, 1., 27 37.

1_1. J. E. LaFr'ince, Opti. nU. . 1t30fl of error recoverv , in stj ntax-dirw*c, ted

parsing aaIg rithmac, SIC3FLAN Nat; l.:: rºrä1.9/0) v12,2- 1 %«

L2. J E. LlaFrance, Syntax dirocted orrrar rk%, ccUVÜry 4 or (:; uI piier%,

PhD Thesis, U-Of 111 : illoi , Urbana pComp. : cc.: i. De . v157'1.

L3. R. Lrawr. ncev . -x id RY. an r' An oW. t0 ylsiQQrr ca "r fi. Nt %t. r". i. ncj. - t o.,

string c. orr t-sc: tLon pr obirý. snr, JACM, 22(197"r)p2p 1'7'1-if3ýi.

1_4. J. A. N. Lee, Computer r>em'antics, Van No strand Reinhold Company,

197 2.

L5. J. A. N. Loi:, The formal definition of the BASIC X, anquac ,

The computer Journal , i. (1'972) , 1., 37-41 .

I_6. R. P. Leinius, Error detection and recovertj for i:; yv tia.: rlirt ctecl

' coi p: i 1, er systems, PhD Thesis, Computer Sc i.. Dep M,

Univ. Of Wisconsin, 1970.

(Abstract in Ahr; traar" tp 31(1971) , 5923 -fit )

" L7. J. P. Levy, Aut, om, atic correction o4' syntax errors, FlhD Thii*ssiihy

Cornell Univ,, Comp'. ter

(Abstract in Dissertation Abstract , 3(19*12), 61? 72-B)

L8. II. Lewin, Theory and Dosicjn of Digital Comp,. itt, ýrs, Ne1i on, 1973.

I_9. C. R. Litrecky 'and G. B. Davi ,A stl' ctj of error t v( rr0r prorlee 110 4är

and error di': agno ic> in COBOL, CACM� 19 (1976),, 1 , 33-37.

1'27

y(o «ga 'kc.,

ýý a,

1_10. G. Lyan, 5tjnttix dirx. cterl least-errors an-altjiis for mitext

free langurig s3 as practical approach, CACMyIp3-14.,

Ki. D. E. Knuth, The art of computer pro r'xmming, Ad is h-We<, ley

Pub. Comp., 1968�

MI,. S. MQrcus, Algebraic linguistics; an'x1Vtica1 models, Acarlymic

Press, 1967

M2. M. L. Morg'an, Spelling correction in ºtj tem pro r'zm ,, CACi1,

13(1970) p2r90--94.

M3. P. G. Moulton, 'and M, E. Muiler, Di'tr"Qn - 1: compiler emphasizing

diagnostics, CACM, 10(1967), 1,47--b2.

N1. P. Noulr, (ed. ), Report an algorithmic language ALGOL 60, CACM,

3(1960), 5,299-314.

N2. P N'1ur, (ed. ), Revised report on the algorithmic language ALGOL

60, CACM, 6 (1963) p 1,1--1'7.

N3. A. Newell, sind M. A. Simonp Computer science as Empir"a. cral Inquiry:

Stji bols and i e'arch, CACM, l9(1976), 3,113-i26.

01. A1. O]. ]. angren, Definition of programming languages by interpre--

ting QUtom'at'a, Academic Press, 1974

P1. T. G. Peterson, Syntax error detection, correctx. on and recovery

. in parsers, HAD T'hesis, Steveni Ii t. of Ti3Ch. ' 1972a

P2. W. W. Peterson, E. J. Wt-1'1on, Error Correcting Code 3, MIT' Preti+, . 19"7.?..

P3. B. W. Pol'lack, Compiler Techniques, Auuerb'ach CumputL-r Sci. ser; Lot, y

" 1972.

P4. R. Poll'xrcir Set-theoretic high-level is ngulage'lia, fPPl"W

Brunel University (to he submitted)

Ri. E. M. Eieseman, and A. I°R. Hani on, A contextual pa-ptproces ing asten

for error correction using hinarg n-gramc, IEEE trans.

Comp,. , C-w3 (a. 9i4) , 4OO-493

S1... W. B. Smith, Error detection in formal languages t J. Comp. 3y.; t.

I\Sci. , 4(1970), 385-405.

und ; 3. 'ýv }y 1, eý � : 4. rýre r., '. S 1 tx "'N�.

y! yj r ?., a« �p'.., ý`' i" , r : "� t , "" ý,

ý. ý 4i>ar h? ".: ° :; 1, ý=s s

`ýý ý ýý ` ý 128 "

ý: .. a.. < . Yýa Sý h`M-1+'ý. °i«tiC+YT; 'v" , ur.. ýa; ý, ai ü :. " *', ý. +_..

S'.

Tý . M. G. ThomQson, Error in regular languages, IEEE Tr'ani. on

Camp. , C-23 (1974) , ß, 59l-602 ,.

=-' T2. M. G. Thomason, ' nd R O. Gonza1e , SLJntQctic recognition of imper-

fectly specified patterns, IEEE Tr'in s. on Com i., 24(1975)

1,93-95-.

T3. M. G. Thonn'xson, Stochastic <syntuax-"directed translation schamata

for correction of errors in context fre 1sangurages, IEEE:

Trans-. 'on C1. Comp., EC-24(1975), 1211. -1213..

Ui« J. R. Ullman, A bifJary n-carcinnm technique for u. iutorn tic correc-.

tion of substitution, deletion, inserta. on and reversal,

errors, in words, Division of Cormp. Sci. , N. xtion' l Pkysºicr ].

i_aborua. tory, Teddington, Middlerex, 1976.

U2. S. H. Unger, A global parser for context-free phase structure

grommiar s, CACM, 1. i (196E3) , 4,240.246.

U1. R. A. W'zgner, Ordern correction for regular languages, CAC"M?

: 17(1974), 5p265-268.

U2. R. A. W4gner, 'inrl M. J. Fischer, The string to string correction

problem, JACMp21(1974), I, I6S-I73.

W3. N. Wirth, A programming language for the 360 Computers, JACM, 9i

1""". x(1968), 1,37x'74.

R" WA. N. Wirth, 'ind H. Weber, Euler- as generalisation of Algol and its

formal definition, CALM, 9 (1966) , ý. -2, ý 3~ 'w and 89-99.

W5. T. Wino'griad, Utide rstaanding natural liangu'age, Edinburgh Presst'

.

?` 1972.

end ý.

+4

a 6

RY. w kM

nN^ýYiýý"j

ýgý, ý.

N>, V ý.. 'ý+V, ;ý i'iFýý'ý9;

"Ri }ý, ý

_4

{}ý{, -{,

Q

'V dir

129

ý *'ý, ýý e cT ±t; ý ;ýý Vii.

.gý. ýý ýý, ýi 3;

. ký

S_

' .. ý7 a ý'

/q s: "f

: pragram, :-1.1t, I"Ilo rt, . Lis r. ýý i:: ktl: x

%sºtatrient 1iß t: ta rl 'n t.::.

..: St 11, I1 11t I1... ßt:: mt.. YI

. t: Ll: it> vIoX. L'

,

"h' NN..:

j i, t' "rl l

". 1 ýiI ýI

~' N 11 "`a1. ý" It'..

I Ar ~`.

Hm

1lýý'ýýý " 4"1ILi 'isL

ý dQtº1 11i't+

41

VI: 1T`a. int

00 program 1ý1ruo 1'1: iý C/ýýI'Illt1'Il. 11;: >G. t^111. Lr:

. Ill.; tIa . l. lýal..

º211º . Frt l ý, l. l'týý t: )'l, il. t: >"1 ýýIC: ýaýýl: il. ]ýlil. ýt'º. I . ý, q"t. 11: 11,1i: 'l. i. tiPt^., I. ti`c! Lk t: ýlýp1rý 1°ý'. iº 1.11

illnt.

ý" 130_

f`ý

ýý

(I.

"7 . a; f a 1.

.y

I

1 }

ý ,ý ., ýý 3

,ý,,

9. -. 10-,. 11 , 12 13

: l6 17

19 20 . 21 22

23 24- 25', "

26',

27'. 2B 29 3ü 31' : 3, ") ... 33

. 55'- 6' 3

37 38 39,, 4ü- 41' 42-

" 43 44, 45

46 47 48" 49

51 52 53 34

. 55 36 07 5B

. 59 60 61. 6 M.

APPS DIX 1. b

1!........ ;1EX T V

V., N

"IS

r, T"1.

t Ch t. ýt ««. «. i t, ct

':, Y, «« . «. V

fly, V tj T,

0. Y`

of - ._ "i'ß) 1. fck

t0 ---- ý', º I M_ I, {j , "ýi ý. t0

º_a ««.. « t0 / r, ß. 1

p) ix rl t 0 «. «.. gad t

t. «» . «. .,. ra

131

64 65

67

69 70'

' ;. 73 =f' 74 75 76. 77. 70 79. #3U '. X31'

' X3; 3

87,

"u x. 39

91 9I- 93 94 95 96 97� 98, 99

100' 101` 102 103 104

r 10., ` 1Off-_

107 108 109, x10 111. , 112

"., 4 13.4 1.15

120- 121'

1,23 124

ad ri

{ ý1 ý! 0 r'

1 ". 1 _..... 1 N. A 1! IS

,1 ._... 1. r N I :iN "1'

,1 .... L0 c:; ,1 {. RN Lº .

it .....,: L.

t. - rl ft4.

E d'.

. I. _... C1

132

t

6

-

1

--ý

ý: i. 2 t, i. .. t;

3.27 x 126 Z

129 1: 30 131

133 or.

37 1.. ý4«

1 41 . 17{

.-e.

. .,

A07M.. 2L.. ,

a ýF L.

1 " b S i

ýy s y, S

APPENDIX,, z«C-<

1 a: =s AIHLtxtIk1F IOIN I{JlKll.. cMtrtlq lfjp! l I IIIUIVIWIXIYI`l.

d Mi^'UI1121314"1til6lI1819

addV,

malt, :: - CI . /a .- ,�FY. - y7r

Ch ;, 11 01 1 'add. 1 Inu1'L Ir .1

v :a Idol -J : -a" a -- ,

tý: ýpQnr: t7't,: n=L auu d]is KO WA rl 'I",, E i; 1 d1 1 Ld

f I. i :. m° AS I' . ATN 1 CUS I XP ITI LOU 1 RND I sur I 0W 'Tt

w. ,c :=, DATA I' DEF.. I 01M I FOR 'I TU 1 ßiTEi' I IF I THEN I

<. i t' OlD i GUSUE; ' 1 -NEXT I LET- 1 1NP'U I I READ 1 REM I

PRINT I -RESTORE I RETURN I STOP O''' I EN 1)

"ýý ä Výýký, P

ý,

i

I

IMF:. L. ICýI1 IN 1 i: i: E1t< r r. '°1: ' , f.. `. 7

G "f"

CIl.. A (, ', yiiIty1.11''"ý .

I, y (° 4 PS ý: > y

L. 141 :Y(y 'oi

".. ) yF1y ýý f

.4y ('

`ý.

-

a/IS; i/N1..: (ý1G), tll. ýl..! -ý(ý; yl"... LI:., 1 (-ýG, l, ý. ýý yl.. ý°I; ý'((ý4GyG, ýýý

this prt. )lJr'. ll'i {. l1.1iIU t, {'tt, ' I: iy't`t:: k"dw"il. v 1111,11. C'. 1,.; ti', 1 N ý. i l" t, {t aý t. Jr l. 1 ý ll l l, i r that-Itus 'l. hu mv't, u,., tJml. lt"). l.. a f1 E:: (FI,: ') ,. »., I11w t ('1, rtl» t rl, l) )ý tltr"*

kA-c'rocll. zc"l.. on ': r t*. numbor'el. t N ; J1 (c ), . «» ltd::: 2 .- G. - thare-s re., NK 'PC)IJ, UC'1.: 1ons and NW terminals in the grQUlf al' lä `. the le1'1tJth'af the ) -'I; h : 'rortuctio1'1 i; LU(I )

C NRV , is. the ' number c)fi , ca "term: i.. i1aJ. <.: c

C"' ' "'; ": firsat NRV . hIJmJ: )t: ): f. t ' 1,1ri 1'1l; )11't, ern1i'i1als, last NRT -Lor1'1: 1.1'1ULs

CAL. L. ". AäSIGN(: L, 'hQ'f"fr«leiIL. '', O) WRITE (7,: 500)

s00 FORMAT («. 'X-OU PUT L'{:: VIC: b.? r/) lä(aLl. ASSI (: 'iN (6', IX )' c. AL. t_ ASSI( GN(4, yI)AT»M"IL y y0)

. WRITC(7,10Ö0)ß

1000, != OItMAT (4X, y PROGRAM F60: -PRECED. MATR1X1/)

READ' , 10)NF', LE ii c. 1Ii'J, PlN l"yh F. �'11: 1 WRIT£(7j0)NF'yI.. ENyNRVyhr TyMEli;

170 FORMAT (;. X, "NC' y LEN! y PNRV, NR'I', MET6'. 1. m ' 6IJ )

_: "WRITE(6,7l)

71 i- EU RMAT ( ? X, y'- the g ruInm1). r1 "., X: DO 201.1-a , NF

11-7 REAU(: i, lO)l.. t: i(X), (G1: (I,, J),, J=I, LO(Ii) 201. ' CONTx7ýtaýý 10, ." "' `9 F0RMAT (183I4 ).

J: -! : -"r-0RPSAT(i8(A2, x)) " REAIº(i, ia)NSI READ (1 10) N92 URITE(7,72) WFi; ]: TE(7,73)NSI WRITE(7,73)1`1; 3 P,

72 . :, FORMAT (»X, r NS 1 :. » NS2: '/(13I4)) 73 "FORMAT (6X, 1E3: ['. ß, )

READ(1,1 3) (WS(1) , I: -1, : 100) WRITE(7,74) URITE(7, %', )W;

74 FOrRMAT (5X, yW>;: y) "715 'FORMAT (1U(2X, A2) ) ... WRITE(7,76)"

76, - 'OfiMAT (1ry. X, ' NBC x: y) . -tiEAt'(. 1,10)((iýiý�t1:, J)ý, J- 1, )£I), ß l, 6)

-. z` . UR3: TEC7ý, 10) ((M (ýI, ýJ) yJ=a, 1 i)i 1'-: t, iß)

WRITE(7,233) '22

223""""'', FORMAT( I V-3" ', 6,00a )

., WRITE(7,223)V3 ;-'

-233 VO R ihiº'T(I. l7üNL'/, T,! r")

WI ITL (i'; 10) (:

X35.

1D0 600 1--) i:. r: H` Itü -Woo . )w]., 1_I: td

ItO90 I-ý1. 'Nýýý ,

I`ý L. G(I ) 91, ' Uft(T., J)_uC(Ufý(I, J? ). '

WIýITL(72)£C LO(1)r(Cii'ý: I, J::; I'LC I) 90, CONTINUE

902ýr... ` FORMA (5X, 101A ý19 D=100

NG_L(I) "U 29°.

=` .. NC

LIK=: (1if(META ,I). ... _ xi(] 30 J: =2, (_IM

:.. LID 0 '1,: NC1. (NK1), N. 32(N{'3, ) WRITE (o`,; 31)NK1, I, (V: 5(GR(I, K)K' 1, LO(I))

30"°,... ýwy = CONTINUE FORMAT. (4X, 214,2X, 9A2)

i1ACROScOh, Nl., FIRST) .

". DO -620 J*»M, LO(I).

S20 Cik1( , J) UkiI, INL'º) bý. p 'CONTINUE

,.. "_. CALI. MACROS i CiF<],, NLL, LAST

""... 110 40 NCOUNT=w1,5 UR1' TC(7,229)NCOUNT

229, FORMAT (4X, ' NCOUN'T=-'' , I6 )

l_: Ch0=MC(ME1A, a. ), _, -- - 9_ -c O 45

tK1: 2 LTMO D

°r- K:.:: C: (ML"(ML1(, kl))

C "("' i t. C.

_' i(' Z i: > in I If'iäT(A)

"'and C i's ill t"S1k 'WT(D) then

.C , lcid C to FIRST(A)

i. _t1I-; NL(k) EF(LIM1. CC4.0)00 0,46 JO 50 L=: 1, L 1. Mt'

w ý_. ý. ; "fý" INZ'. FIR: ir(K, L)

- : ft(a. NI: D. 0r. NRV)G. OTQ

i_IH2": NL. (IWD) IF: (LI1i2. EQ«O)G, 0TO 46, "

t52 I 1, LIMf2. AS-F13" 11N '.

1K F COrTINUFL

.. '1.. 1. J IY 1

INU1::. -.

-,!,. ----

136

4fi LIM1' NLL.. tK) II: '(LIM1: EQ. O)GOTO 45

: -. :.. A, rin 4q i ýI I 'tMl ', ý, r-">- A. 'v 'Je. 4.. -a, I. ". a rid.

UI=LAS1 (K, L) A, ý, . . /IF(INLI, GT. NRV)Oa1"O' 62

.., ýý .ýI.: Ir 4L_t_t IN1)) ý. ý

IE(LIM2.1: Q. ü)OOTC) 4'. Y fro J::, 1h: CM2

1a,: I ) W: L. r1gr( EN

. _CAL. I.. (:: I"IELK (Iti' NLl.. 4 LFI: äT, A)

l': UNi tUL

". 4g CONTINUE :. ý�`ý COýJT"INUL:.,

AR LALL SCR1E

w. FOl'«IAr(i. Iii, 4Xryylr"ýji»ýaý. ýý: rill.: ý:: "

.. 'v R17EC6y'; 351)CViC: C1 1, I_I'»N

-': 3 ý. ': ' ..

FORMAT (3X p 18 C Ix, 3A 1) "DO135U I=1, LENS -WRJ: T'EC 3,36U)V (1) p (M(IIJ) yJ4:: 1, I- rWRITEC6r36O)V3CI) '((I, J), J: x, LI )

3606FORMAT(2X, Al, 1C; ClX, 'W1)) A1350A.. CONTINUE , "ý ARY

SAM

?' .. i

-\

\:

!'

ýý

,;

ý, 'ý

x ýý:

1'

ý\ ýý'

°ý r,

ý,

aý, ;

ý_, ý

"yon ; 4..

cux r oU1INC sCrýý: r ., 4, -, 11-IF'LICIT IN1 1L 1"t (A-1: )

L. ocICr'1l. x"), C, Ul(pCi: IrF7f s3'1', Lfi; i', V3jApMI, M , ýý'`

.. "

. COMMON-MC(lU, "U) N; 1(+0), 1J8C4U), Ml: 'IF'i 1/t 1/r1(4U, 4Ef)

°- : 1/'B'2. /Y3(6O), W i(1UU), C(iOU). a/B3/NL(40), NLL(40),, FXRST 40,60), L. ASYt4U, aQ)

a /1'ß'i/ºdr', IJRV, NR 1, LLN

TORMAI (: i: 1., IX, rat na : G": ast''Ii'i ;..

-110 '5584 1: =7., NRV . .., Not, WR :C T1 (cryi t )V (xis, (Vii(F1Fý:: 3'I'(1,1ý)), K.: L, NI.. ii)7

a E34' ;, CONTINUE W1ITE(o, 5%0ý. `.

, 3 7,:

DO 684 ýI: I, NRV r r"ý < rr ý_ rw (: r) EQ. o) ao ,ro 6@4 v w'`= WRITN: 6 13 vw. t. )'p V 3L. A ST I; K> h 1.14.1. I

634tCONTIN111. i' , ... :, s ruf: 1J ý±i NIt- .1 Fyn r

ý.

f wk. 's 'ý"ý

,. ý. ., ý:

40 ', "#h .,

4r" '? r'v.

ý 'ý^"s ! `3x

4.. ', i. Lý: ; r;

ý 'F Lid-

}yM. : SUBROUTINE MACROS ((RAM, NI»G,, ARRAY )

C rt1. «y ': i ß. 1)rT a u, 5ll4' jokes { from oll prl. )l. 1UCtLC)t°1S A ""- BQ `C '_", ;. lilrl Put. 1. h. ' l. n riRi'T(t1,? )

r'

,,. `

.. ((1MON : ME (: (üy:: 'O), N: äa. S40) yl):.; '(40) rME"1Gi

ý ' = /IS SIý1F'ý, r RV" idh"i' y l.. I N ý. ýý ; 1... 0U. I CAL`R 1. C"; I ('iQ l:., U, 1G), AI kAY ('lt), 60)

. : . in,

S

I; K

)(. ) i1) ý I, " Pa ̀.. Y .i tNl\I) yNS2

t1`iI\ý.

't ýlýº -(ä(iFiP'i i) y11. .

} I'ýlXV ý`hll. »C ý lal°i(tilY r l'ý 1 t. t". 1ýh. "C; f (: I; ''' "ý rxt: il, E ý{

, . : TIN '50'. kw

; UMUI'3. NC LI'ILCK IUIä; NLliy('kI(liY, Fii' ,.. . a ý())'y M. . '(40) yMETf'1 CC)MmGt4 MC( `ü, ''Ü)N; (ýI; tt , ,.. ýý.. '- LooICALKI -ARRAY C40111) IA

'., ýa±, X1.1MEN 100 NLG (4Ü)

C, ý_, ", , ;. i f1 -. Lt.. not aý. rý, ºurt j 'z. n ARRAY (1NIi,? ) put it Lhýýýr V "hýýrAfRAY FIRST o'r LA T 'respective t( t .

, _ M:.; "ýNL. O (: I: NI! ) ý _uüýrC) aae : trý(M . rQ. 0 ) -

, , Y''. "-' 1)0 1.00 1I11 , e15 : f: F'(FlRRAY(1: NLl, X)IEO: E1)Ci9TÜ 13.0

. '<° CONTINUE «.; 200 . . ARRAYt: ttNLU, N1_(itINLI))z(i

0. `. ;. RL"-: 'TURiý! - .., END,

" (. 1UkÜUTIiJF MATRIX. . l'tINCý'ry) put it therm (:

"if A i.; iiot rllT"a: ýaý1tý 1,1'1. rilýkri , : (; ARPAY in I'= TI. 261 OT'. i. _(',

S { "-T-es'. ' »t' 1.. i. VCe: 1 t; J :. ) IMPLICIT INTEGER . _'Ai rý` ' LUC)3cCt I

, C.

y(7ýý, ý7ý1{.

y1" ý. I'i: Yý, ý«ft: iI, ý. ay1ý'1y! 'ºý., ýi ý`

, N;. 3a(4q"), td ;. ". '. i4U) yM! ":; '1(I COMMUk i11".: (: 10, «=. '. ü} , I%BlI LVi 1 AQ4t. 3)

... "'

,_ 1/E2 Vä(60), W%(: LÜÜ); C(1 0) : L/B3/NL(40), NLL. t40), FIRST(QÜ, 60), L. AS"'('(40,60

/]: SU/NP_yNI V, Ni(T, LI 1 .

_, V, LzM-MC(META, 1. Ws. n r , 40 , t- F "= ý`, _ K14D0 33() JMa2,1_1. h

' ., ; NK1-ý . (META, J2)17

. ý. --' : ý''WA0C. )'33O 1C=Pßä1(NK1, ), N32(Nk1), + r . 4" . M,. * I(= CLG(1C), CC). 2). 0OTU : 310 : GtIC) I. DO 340 01=3 I t .. . , &Ann

4Y. ýo!

M " ßä: t ö Sr

ry

3 tký: ' "W , 5'

r , rý 1

ea Owl.,

w*ue C 7. I1 this Gý1ýit' K. L an ý ý1i lU in 1 IFi; ii(L '')`, `x,

tF(1...

.GTN I[ RYNOINN L( L)

NEUN 4)

G OO 340

Da 340 J -t., U(L. I ý ý( ii''º1 (I. I ,,. I)

: 340

330 (: (JWT I(4LIL

-. = . LID . 37 02 "2, L L(1

._ i1Na. mME tM E1('i , .. L2) '0 72 -ICyNHI(NN1), Nw3 (Nt 1)

ýJGCJ 372 .. 1). » 3, LO(IC)

ItX -lS 0 C' -since! K is at'ti<iymbua. fur - all- Win LA$'t(I,?.

ýý : ýýI... N L. ": a Ad l2)LK ': r Ljfar`allLJ :ý 1'1 C

W DD : 31i4 J=3, t&L(1CI) LK=LFG äT (K9. ,J CALL.. VERIF(h, LK, L, 3)

2 ,. ` If"(L. CyT. NRV)GOT0 Z84

"AO 386 J94: L, NL(L)' t! Týi LJ-FIRST(L, J9)

CALL VERIF(M, LK, LJ, 3) . 386 . CONTINUE

` 384 CONTINUE:

,, ""372. '. CUNTN

Ink RETURN 7

SUBROUTINE VL: RI (M, ML, MC, ff 7: Cc, rri(mI, m c : i. <s made, it i., if it, is G

IMPLICIT INTEGER (A-Z) 1_(aGICAL"MI M(48; 48) MI, UU, C, V::;

. COMMON art2/v3(60), wS(100;, C: (. vti) : al°'(M(ML, Mc). Ec . 0)G0TO '400

I[' (11(t'1L, Mc) "1::

u. 11I

) Vo 141

4iyU

r,. WRITE(6 410)V3(ML) V3(MU) NI M(ML Mtn) R410 e FORMAT( X, Idoubl. 'relation , "f"' or M( 1 pA1,2X, A), r') ,

-Qv 11-"', x4) -- 400 M(ML, MC) =tail ýbý°TUrýrý

ENü

- Of

}ýö'_- r: y' ; ". , iiC' 'ice k~ý:. r ý, 's:. w� ý<, ýý ,`-_ý' ; ýr ,

`"°,

�. < rý `1Ný y', t : ý4 :k rY3Týik ýrv'. M"v

, +ýwrýY ý, t.

ýý

. r". nraýnrv )k

y "t a.

¢h1 r"P'c. rtL1d. A

trýtý ýýr"ýanrnýý: ar °,

49

12 1.2 39 c ti 1,2 40 { r' 12 4

y y

/ 4ý .n

"^ sJ S

". t

t4_ i ' ý '

ý; "

Ry '' wFrýks'

F ý . ýiC ,

ar 7 ' .

. I)

77 '7 B

i 10

10 4: 3

6 27 rv 6 rý v

'32` 56 v

26 130 C tº 1ý 26 cY

27- Ik n. *. 7,,, -. 07 º't i ý» 'ý

w ;l 56 - , "44 w ºu

t,, 4., ww -X M XMI 46 ýy ww * ýýº ,

! 59 , <S j 11

'; 3 3'l . 04. V r. ' = -105 1 fi ..

106 33 1t " i0% 1b

36108, fi. r. ' S3 º 09 1 1. -

= ;S; 'l a ;ä i rý 114 at! '' "

=3'3: ' 11 .) IU

`rd Y-71.. x,. 1. .4f U

1.8 '

a , fir

ý 'l19 - lx ýf :s 120

33 ,, l 2. ku 1X

140'

_. .. .. .' Mkt ýýý<. ... !. r. 4L

4

"

(( C _

Lt E h {) .i l., AN

_'( rAh-t 1+)

,«7 LL

. 1' l SI h1 1, .

i.. I"' 1. » I'. 'r º1 J 1 s

Lý LI L7 s1i1.1

. . 4" AL lz. 11ý 11 Lk

ý.?. w... uJ T Iii C "ý'

Iý V, I1 I. 1 r lt j. t (! 1'1 t4 V ('

1 ý

rc 1' r1 G E. 1 J L» I v rti lir LI DUIS 'Nl(: ' Cý iý ', ý ºý

a Y"ý`DI W "ýý +. 1_ ( rc ST JA C E I' I L R v 11 l. ýi ý1 (3 1

m t1 Fs (a x j 1. i C in .1j to 11 M3w

:l., _jU

No .ý` v .-:.. 1AI: t(:: (: I EI" 011.. M N (: l .

P Ci I S T X : l' 4wABCL. I f F' (: i x, LM N o CP' (: a N i '1 X,

only f, SOON

ý! C .. `r T: W I+1 7V CVI B C. 1.1 L':: I' u1t,

» M

w r)v1.1.1 A BC xl LE L) IL 11 N li F U t2 NI 4., ) i' C vII t'1 ( d

r

P fd It, `3 "1. x 1.1 .«frI. V 1't II a

.A:. w (i kt L", 1.1 I :. I° ti t I. rINU V' U 4! ,

1! ICI i! I( (: i v A 1., 5 C E I^ L 1'I 0 U R

twr. cv Pº n : I, '. 1 t. . ,A 1ft C L I F Cr I L.. t00IGI: -

Srx w 1.1 I v lk I'1 j +1 I. r

h. 'i 0 N0

. 111 fvc. Y it ;iJ. 1( 1 A Xs G D Pw F 6 J: hS NÜ

1: 1 kä1X j (I

11 wwjFrJ r'^

V. ": .1U 14 1:: LI 1 F. 0 x L MN 0 I 0 Ii :i TX

doubt ` r61+ tion for M (N ') , 1411 1 M 2 double rejI: itiCir, 'F`oT' M (N `' Ii)

y m1 t I No 1 :

cto1. &b Le 'r1r. ><t. lan Par M (I N) , MIS 3 M- 1.

Wo .:. . ... .: .

äe v.. k ; '. v ý_ '^ . a:

. ý. .

z;

': '°. ýý.. APPENUIX, ý 2. b.

Fýrýceºdelice "Pi' tr ix

'so I. . '. 1'1 it f t, w ". i .. 11 ) -1. ̀d J. ! ") A !. 4.1

ý 000 ' 00(, 000, 000 o00 O('(' ' 01 (1 I () ir 000 000 00Q 00') 0Q0 °. uuu ')QO o00

cý 000 000 000, - 000 000. 000 000 000 r 000 000 030. 003. 000, 000 033 300 x 000 000-- 000 001 000 000. 030 300

m 000'. 000 030 003 . 000 , 000 033 300

' Ul 000 000 000 : 000 , 000 - LL 000" 100 000

f 000, 000 030-' 003, 000 000 033 ,

300 "x. °0001

000 030" 003 000.. 000 030 300 w 000 , 000 030' 003' 000, 000, 031 -900 "; 000, 000 000, 000 000 000 000 000

+. 000, 202 221 '2M '22.2,, =2, -20Q- . 022 000, 000 030- 00.3-7 000. 000

"033 1300 -000, 000 030 003 000 000 033 400J j -1000 000 030; 00; 3 000 , ()00 033 43X. i. 000

, 000 030' , 00-3 000

. 000 033 31,0

v t'. 000 ' 000 030 '0 03 000 , 000 Ö0

x, - . 000" °000 030 - 00- ' °000 000 . . 333 30 1. t 100 020 002 ` 002 - 000, 000 000 "000 ), "Ooo 000 030 003 000 000 033 300

000 01 220 "000, -- 2'-12- '.!. 2,2 00 .s' 100' 0 20 002' 002 000 000 ()0() - 000 000 000 030 -00',: ') 002 100 033 302

d 000 000 030 v03 000 A 000 000 0130. 003, 000 C100 333 '30'. 5

c ' 000. . 000 030 0 OAS` 000 000 .: >2; 3 ; its LI 000 000 030 00% . 000 000 333 03

, t: . 000 000 030 "00:; 000 000 33 303

1='=1000 000 030 o v- 00 000 33, 3()3 ý'6 000 000 030 003 ý: )Cý0 000 33) 3 30 ý

1 ". 000 1i o .I . 1_. 33) .,.. .. t 4J

. -1 11 41 4% 4__

'.. 1 'w: 4. ý _y_ WI 4I 'w% .....,.. Y V.

J . 4/

L 000 000 030 003 000 000 333 ill 000 000 0 30 '070% 000 000 i33i : Ä0'ä N 000. 000 030 003 . (: 00() 001 33 71 ; ßi3

:0 , 000 00C' 0 i0 00:.; 000 000. %J 33 30 1D 000 000, 030 00 , .

0()U 000 Z: 513) iä03 Q 000 000 0.10 000 000 000 333 303 11 000 000 030 003 000 000 33 3 30 3 S 000 000 030 '00. ";;, 000 000 333 3 03 "T 000 000 030 00 000 000 337, 303 X 000 000 030 003 ' 000 000 333 3 03

000 000 ()()0 000 000 , 000 000 000 4 , 000 000 000 00. ) 000± 000 000 000

"? 000 000 000 , 000 000 0000 000 000 k

"000 . 000 030 . 00 z 000 000 033 No

.7 000 " 00 ' 21,0 000 222 200 02

' ý= ý ". 000 , 000 000 `- 000 000. 000 000 000

ýi13 c fit7F" t'1. ß L

%WO ! )QQ. i lwj 00(: 0 0(ß(i 0v(> 000 000 000 000 00(' 000 000 000 (00 000 000 000 000 QQ() 000 000 000 000 000 000 000 222 222 000"000 000 000 000 000 000 000 000 030 000 000 000 000 000 000 222 222 000 000 000 000 0üß) 000 010 000 000 000 000.000 000 00() 000 000 000 000 000 000 Z33 33Z

000 000 000 (iü0

. 1. M 4.. 222

000 000 000 000 000 000 000 000 000 000 100 000 000 000 000 000 000 000 000 OVu 000 000 222

a- 22,

000 000

000 (>00 000. .:. a ... 000 000 000 000 000 00 0

222 000 000

. 000 000 000

00(i 0ät7

00() . ", 221

100 000 000

a. 1.0 000

rust.: ) : 'I

000

000 000

000 000

000 000 000 000

2.22 U0U 000 ON) 000 000

000 000 000 221-1 000 000 coo 01(, 000 00.1. 000 000 ü ; f. ü

M 4.0*

000 000 00vß 010

U',! t) 1Q")

0() ()

00(> 000 000 000 000 000 000 w

2'r

000 000 000 000 000 000 000 000 222 000 000 000 000 000 000 000 00() 000

'J00 000 2212 000 000 000 000 000 000

(,;:,

000 Dub 00o 000

000 000 000 000 Ä. M. W

000 000 üüG 00c; 000 (A)Q 000 000

000 000

0G

0 j. 1

000 000 000 000 000 000 000 000 000

000 000, 000 000 000 000 000 0(0

000 000 000 000 000 00(!

t/ 0) 00(

000 0(1(1 "00 000 000 000 000 000 000 000 000 000 000 000

000 004v £00 vv0 000 00 000 000 000 000 000 000 '000 000 000 00v 000 OQO uQO 000 GGU 000 000 000 000 000 000 000 000 tö. 30 M ... ... ý.. ý.. I: w : 222

ý.. ý. M

000 000) 000 000 000 000

5�ý'S,.: k, + i. ''F ^ �'"t ýo-`; s. ' ., t. ý, _a' 'fir., , mot is 1. , ký. i, : t±g.! "reG . `', 'ß`3,: 'a"' ` ýý y 't; r^` _ ý" ̀ "S ü: '"'ý! +sro+ ai-zc

yýtY+ 'gl v"t . ý's~'" .

tia. '`tcý v. `"".; 'ý ̂x; '. '. ros1 e-g t

*.., , yCýi� k v'+ý. g,. ý

, fi

ti «5 `f"<v,.,, x, r

Y`{3; ý`x: t, v; ýýý, p x^ r: a, ''' ,., ý.

ý,: s.

fi-. yrc,,

dRý't. ýý+"'ýý. t`r sx

', x

ý'g Li , ti:

"a .. 4'y_. ý, . x. ý"

r dry'.

Aj, _"ßr1 �; ",, -'`£, 5 w- . A"'ýý? « . -; >= ,ý

°"f; .t

"4. ¬ý°ýa1., 'a'Sd ýt -"6 n'. s.

6`taraý, .. ý,

-, y. i ý+iýrr ýiýtr,, ä -ý, "tý ,, r'={

r . a*,.

-------------

A F'F'CNEl IX "-"ý'rt`,

A". 'ý"; ý-,

`. `'aýAq, ýý"a"j"'°ý,;, rv ý'äg

sý7vr°"::: r". 1

'fi°`''

1MPLICIT INTEGER (A "Z ) LOGTCAi. 1CiR,; iii. zN >i, PAFiýi{ RZ Nlifr, W(TI'il, 1,; ä'PiºCKVäyWCWF\

=: lUIJ M,, W ýfiT', r11º, (: Ifi yNHX, W, WL". 1: "'7'. v r'a+fä'', WL: t; Il: ýG., Ay ýt p1'1: li; i t COMMON STf IN(. -Jt 30) , LUN6 /B0/i1F', fih't1S(1L, 0), ÜR(; OO)'NF'1.: 1., 't: 0), t41ý'I. ":

ý( lQ), r`'lwi'i'(2O, f7$ -[ /Bl IýF', 1~'At SE (100) NF'S p STAf: 1" (täO > 1/ 2/WOfi ý(10), l: tiZ(20)

Y' JIr3/NCZt, NRP (12. , .1 2) y W. L'. L t'1( J, 00) ; 'l : L/103,4/Ut1A'r(100), iiiLL, NC, AI)(st'ytr)�iIlII(9, f? )

W6 ( 0-), Nl_., WR t10LLL., Z: t

i /B9/NEX NRk: `. 'X (48 3) , JL.. ,{ ss C» (3.00) X/B1,0/V3 C; Ü) ;., ] /BTX /NRV, F1R (40) , FIRST (200 ) i/B12/NN(20), NNN(20) DIMENSION WCODE: (100 )' CALL-. ASSIGN(X, 'DATI. MIL, y'rr0):.

`-; z`-CALL' 'ASäIGN (2y" TºAT2. MIL.: ``l', 0) y 1- "

CALL, ASSIGN (47, rLIAT3.1IL y' `i)

r,. w r' "'

CALL ASSIGN(4, 't'AT4. MtL' ', 0) i. _.

777" 'F0RMAT(S? C, y CIUTF'UT ClEV SCE. - 'CALL. : A9SIUN(6, 'X y, -1 )

WRITE(6,9? 9) ... 999 `ý TM" -FORMAT( 110,: 3X, I DATE T1 lvt ; .: 10 FORMAT(1814 )

12 F0RM ºT'(5X, 'RZ. y, 1;: 114)" ýý ' x>«3 ;, 4 ýý FORMAT (: X, «'0I2) ý. ý.

20. FORMAT (72A I) " ... , . ý., .. 22 FORMAT

_(xi3 (2A1, , 2X), )

: 'Jw.. ý; w`.. FORMAT('36T2)' ti ...., , , '.

60 FORMAT (10X, 4()A1) -. s .. 11MAT CI OX/ ) )`70'

FORMAT(16 I. n, 3T. J.? _. i Y, -: :.. ,; r%EAD C7 " 20 )ST . rar:,

I. RlTF`(6, -'70> ',. UFiITE(6,70)

fi 'r1V0. p': 1.0)idT', N2vW , NCilyNC, NG:; X 11 0 19,1=1 , N(:: Zt

19 '1: 1ýADC1,2; )(NRtý'(ý,, 1), J=).; ýlCSý) -Izk.: AI:, 0, 'v'25)WDlM READ (1 '25) WILIA'(' -READD(. x10)WLET

° READ0'P'2 )( (ALI(K, L) pL: 41, NC), K=`7" yNLL) i, F. AD, 0.,: '; )C(OIi(K, tW), L 1., C), li"I NLL) ý.... ý:. READ (1', 20) V3

110', 327. qJ 1, N .X ö_. 321 f%EAt'c4 322_ G4REX(1, J), j 1, NEX)

RE41i(2; Q)lC3C3 ̀ (CFk(C Mý'C1ý3(. i)-M'Clä(J)tLCýC3-)" 9 '�MPOSS, (J±1).: M1p'O: i(J)4. L(O .

=. rREA

ki"F D ', 0> º 3Y Jh) rý! Il 11.1 vK1 v> REAL 3ý1.0) N1"iV a ýý. .. _ K ..... _ y, ýr { o.,,

ýa yý^IPF3y 'ýý` ý! ý`{ý, ýi 5 . dxs .e",

. ýr. 4 . "n,, t .. k.. r,

r*. " . R, a .* awl .. a., r.. 4

.' ,ý VFzýýýk js,

'" ;; `' .., Fý", a`ý .

ýý %} ' 4i. ý'

ýv,,

w"' ýý# `

, ý* 'ý "'ýi`?

"k. iý'"", fit,

--, `. tt t' p. -xx xs":: .:

', j} "q'xi., iý''

Most '" !' ý+"'. ý-týýýýä Yx

ýr: + qý s. i-. d a

, +i 'fi .l.: i'"r;.

yý, ýýS; d? ý ,,. *ý. 'Sj; -'' ,ýa . y'a:. ý'h

; ý'.: 45ýr? w

`'°. W^. '. ý? 5xý '+...

; ý;. a_:; ý`

,.. . a.. "; *`` yi"fý- .ax

}1ýä.,; *: +ti:. 4!., ý-'^',

a. ý .. t. y' a ý; ' ä,,, ý. . s, y, sr__ ^ý `_"; +ý"

ýý `'ý. 'ý. ýýýy '*. ' y#ý"ä `$`7ý., +, j, t' : 'ýý aP! ýý'ý` "ýý. ý5,, ý;

"k, ýe"" ý. i i'k. 7_, . e,, ý : k4. , ý. f,,, :. pýj;

"ýý*+P: q`, ý1'ý; ý "ký; f`ý'ýw

'RE A I: i (, 3 i' l p) i.. UN (J y (I"' INcifJ: JfI I-i , i) 't I.. UN i=xr; tJ )°ý: F' IýtJ? ýL, U ! t. º ýý , 446

«tt; °C ,; ` CALL.: SCF. IE'I)

444 ''110 449"., ý. ý1 2Q

NNN(I)=0 y

.. 449, 'NN(I)O

ý<<100NCOUNT1 ''. i WRITE(6,70) y:.

NPSC- ý... aa

ýURITC(_6ýp lß)NCOUNT

WR ITE(: fa-60) (S'T'R INO(I ),

ý"' , . "JG O9 01 K=ly ,5U .....

` IF(STRING(K). h: Ci, 32)GOT'0 9,03. I. UNG=LUNG*l TRI '(tUWG) "ST R'x NG'( K) ;. 7

(GTR ING(K) EU. 35) ; )CGOT0 902 901 'CCINT I NUE

ý; ý. 9O2 Wül'r'C, {ýiý`lU)L, UN(3, TR3: 14G Iý), ý, Iý yLUNO . )DO 903". K=x r'3.0 1Q3,, '9 03

, WQF(D(K : STRZNG(K) ý.. ý ;, -..

`L. UNG;,: I; º', Lliýs', ýtýrýy iti ra"i' LIt6' : carfrlt-MShr, d Str CaIw Without Sl1. lul»N! 1: i11, A1'ý1ý» t. kl1,

k}`' NL 7, CAL MATCH2(WCOt'E;, 5",,

,. f.

t4R1=rar (I ' .. ýý .,. IF(NFVi E-: n. o)oo'ru 23

CALL Ll, XAGNO(24 ) ; -. ý.. 4i30 T0' I V; » .

N ER ` NLyr

CALL MATCH2(WCODE:, '5 ,; CALL. i AGND(2«i)

'102 ý. '.:., WRSTE(6i"y.. 6Q. )(W(CR(. )y1. )yWMR (I)'2)yI"MPOC(NR1)'+"]. yi,! ''CS4Ni'i), +'I

FARSE(, U=NR1 -CALL DIRIJ(NF1, L3) ý. ä.. ý.

.. ` WRITE(Fý-ýT4) 100 ' CAýNTINUE.

. yyl" ii: wb vý, :. k:,.. ý' ý+Rrx. CAL L1,4, "'ýM . t, '" ýx e_. a. k -',:,, -a

-.. ,. _" t. .... t^ý, ýýryýýý,

) " ..:. Aý, ýýSýrý`tierk'ýý. MýfY ýl'. p ý. ,:, ý ýý ý,

ý Gonti »rý . _ýan the ° iýtýx parp.

-ý. býf ä 4" . r'

'" ýw, 'i °ý°. i w', "; ý:, ̀, l.. <<' i5ýý yä

.- _v. 'ýtýt-ý rý'

f `ýrz

ý-b. is : '. ý. - ,. t`. . ̂ �'rfq.,;

'4 ^ýai. , n',. r"y; y ýe . `; k., , '? ̀yx`�'f ;. mx+a"ý,,.; iS'

,. *. 4 ý'q. ý: 5 a"rýe;:: r;: ä. ̂ .!. 'a sF4fi ý'n, x,

x`yjä9,5"v., h;. ý. P<d. 'ý -. '+,. '

;+,. ý%":

4 4, - t- ; t`k. ý. t.. ". 'K

Li:

`', ' t,, ý, '. ti +. '°' k-a : R+-. (;: ±: +,..

'a

. äPa{, �. ý, st'"p w. gý : 5, ý. r`jiýi o. 0 ý^n"y ^dý', 'g »r . hiK`P.. ` a, 3, ar., -r., ýý a'4' f "; e

-,.. ý? - xis ". ý ,- "'' r'ý> ý.... ýý_ __

4S (, ý! PS! ik7 s',

5"y+»; "�ý irýin, hf^". c,, `"'+`, yt. l. 't"',, "R! r"izý9; yW, ý ' . Mýr *. ro, ý 'ý-,,

>sýy, ýiä k5 Y. »'` `s 1ý

1. t Pa,,;, t4MN "i` st', i`i. ' X11 Mý vis+, GYP jr. v, f 3 '. +fi, #f 1 P;. ez. +° .r .

ýý]ýat+,; ý"'"`', ý: ý'Sý.

ýy'ýýk. f. *>ýs; tý. jýa", ý, ý,

�ý`^'ýý'r 1 , "K sý, "ý 1... ýx'.

-+,. ý. "ý, Y, < d''N";, '. °ý tS ý.. *ýý

'1 '"'ý. f" ý `t a'.

,. ýý, ýý"ý... "wý.: "tr ", w. . "rTý ý fi:: ýý p Fktý , ýýRýkd.,, ý, g; tý , ý, S ý, "+ý.

,4ý,, ^. �u "Ja" f; g ýý., f. ýýa, ý g `r.,

ao t' ý ýs. ".

!,. iý, ,, ýý. tilr, ^ýt ý;. f,. q;

ýp, l7t:

rS. 4 grxtit ý, i.. X n1'ýý e7

ý ti'i ý

ý'(ý";. týýr'ý^ýý., ý,

x'ý; ' t ?^ ý5+' t? ýa i

ýrý, r"x: tý

'Y "': 'ýi;

3X,... +a, "*tPT [nl s 'di y. ,.

ýirý'T"º'`.: `ý, 'aý`ý ,-., t ýP. ýi x: ß,. (s4�s. 4', " ; ̀,

r, ý . ýýýývt ý", ýýrýý';

''in ''T'"'S'a; ký, ý+"ý'ý', tr

i"ý, ýýý, 'N, i'ý'3'ý, ya ný'ý , ä. "ýý' - ,.

{-:. .`P, f_ 'ý, w

e. iýý'.

t', ̀. it: ý¢

ýa'ýxi''n : '+t .,? 'ý. lrx r,,,.,

d, ý, J;.

ý', ýFµý};;

ýTt., n. $ý!, 'ýix4ý, ýýb.

-i �e ý .. ýý. ý

...., ý. ý, __, ý. s`"7.3 ¢-e , ,_ �pa- .-

ýý,

_, t?

"-SUBROUTINE -1 FhA1NSI)(LJ(; n1, i,, Art, or,, ) LLXiICAL*I. GKL, TFýSNv, i-'iii 1(, Tc

' :. ý, WÜFtLý, S'rACIý, iil: Ufº, Fý. Cý y tlCi, 'ý. ýi ". COMMON 'STRING (30) , LUNG 1/B1/NP, F'ARSi-(10O), iý ii'. 39STACK(60), 1/B2/WORZ'(10), RZ(40) `"

iJjIMENSI, OH. WCUD(100AD(NL NC)ODt L. NC) STATE=1 WRITE. (6,325)

,, -325 `, FORMAT(3X/-),

L=0 =.. _°.. a NO=RZ(3)4-1

='_"äD0:. 300ý_Z=NO, LUNG INP=WCOIt(STRING (I)) AtG=OID(STATE, INP) STATE=AII(STATE, INP) °..: ̀". ,.: °. ..... ', ' ý.

'. -". 11, F (STATE-. EO. O)GOTO 310

a:: GOTO(31.1; 312,313,31.4,315,316,300,315)N(ä 311 L`L+I. 312 WORD(L)=STRING(I)

.. I, " "GOTO `300`; 313 L=2

WORD(1)=STRING(I) -

ý-: ` WORD (2) =STRING 1-1

-314 L=L±1, _.:.: WORD (0=48

317 FORMAT (5X,,! III-. 9,2X, 1: 2; 1 ) -31,5 WRITE(6,317)(W0RLt(J), j . 1, L) : 316 L=0 R. "..

GOTO 300' 318 WRI`TE(6.317) (WORLI(J) yJ =. 1 7L)', ''

:.;: W0Rt (L)=STRING(1)

300 'CONTINUE 310 - , t4RITE(6, "320)STATE, I, STRING('I), INp, L` 320 -.. FORMAT, (5X, 15I4 )

-ý RETURN =-

SUBROUTINE `DIAGNU (NUM ) ; "LOGICAL'*I: -OR, STRINGvP iiiSEvRZ, NRPyGi"<r"X, WORU

X, STACK, WIt, WrtAT, All, 0I1, N1: EX, iJ, WLET, NS' COMMON STRING (30) , LUN

., '1/RO/i`iP MPOS(150), GR('ZiO)), NPL1(4,0 l fP'4... '(40), NSY(20, ()) 1/E{I/NP, PARSE (]. "Oü) , ýfi'S G)Tý iiýý (fa (i I/B2/WQRD, (10>, fzz(20) 1, /S3/MCZi, -NR P(12, aw), Wl11M(100) 1-/B4/WItAT-(100), NL, NC, ALI(916) yOIl(9,6) 1Al6W(g1,00 2 1 /S9/NEX, NREX(48,4 8 ), WI-LT(-10 0 )

. _* , GOTQt'1p2. y3, ßp : ý,. ä, iýý, ýi, 1U, rt. ä.: ': l. '. ý.: i 16 ! L'3., 21,; ti

ail - ý, JiiITE °7 O'll 2F. 0KMAr3

RETURtS. Ä. ;ä> ýWRITE(6' 102) 102 'ýFO`k tA7( )C', 7. et

; ;. eý.. 'RETURN. 3ý' "ý .. ý. WRITE (W 103) .:. '.: runt 'i mica MV. - t hrs 1ý . "i r. 0%..,

e-ýs3?

ri'ý, 7. A" `"`i^4 Yd! `! '"ý, $. '. ý �p, t .x.,. ti. r, . ý, " s..; . +x>�s ` }tti` $'i S. F7i! K ,. r':,, "fi_, ý' ß. "rzt,

*ý" `a _ .aýý;: ; ̀, -x k;

rý.. '_: ýý ',

.- . tr ,ý �a!: ý',, $""`ý'r'ýn ", r-a" ''Y k. 'ý': crF ':. `. ̀. i " ', z*ý'? ä'ýýs Pi a'''r. °tx : )ir'ý'i. x . ý'?: 1

.? ': 1"�r :. "vq. "ý""` ý1

.5 r�M. t;,. t >ý 2. 'ac ýk a. j ,y -" 4=: '.

ý; ý HM. ý. 'a'C. ýq i^ý,, ' , ti a3 - .; r -t. , '. n ý. r.,.: n-t i s'ü3tý"`"s. nX't}' +, 5, ̂ niw "4n i. i t34dý+ 3(_ -tieF- fit- .:,., "'"4;: +,..,,; u'`.

.: r ,4 : Y'i y ýýaý'xt', -. s. " .: - -

äa. n... a" ýy 2,

Wit'' _ Mt''. ' -i. " sn ; ̂ . w -: _"d, k

103' FORMAT (5X; ''lif :t) Stu°t ^ -'ý RETURN

4ý* WR'LT. E(6,104) ý`l04 K. -, FORMAT, (1OX, ' ºt, art- precedenct* ' ra>r*r'`/)

_ RETURN WRITE(6,105i),...;

0ý'- FORMAT( X', 'cýatiii c'C: RETURN r,.,. ' 6 WRITE'(6, {06) ý

f l0ä FORMAT(5X', ''dete: ') - RETURN

7 WRITE (6,107) . , -'. ° FORMAT (5X, 'ht, ý ck. r) RETURt1 WRITE(6,107)

108 F(. )RMAT( Xy'di t, Y:: ') 1 + RETURN_".. WF: XTE(6 109) ,

109 , FORMAT (10X ? el .

nt r/) RETURN- WR I TE'( I ü7)

1.10 E. UFMAT(;. )X, 'tr'uºisducer r7 RETURN t; .

I II s . '. Y

F"1. F`be, f.

_ I- Ri A`T`(V; '' ) RETURN _. ,.... r. WRITE (6,112') `t >..

112_, I URMAT (5X, ß' ga-st' i) ...:, n RETURN

14 ° WRITE (6 11 0 114- , 1 FORMAT ( aX, ' old der iv º)

Its»TUUN at5i WrýXTE(6, I0%) ). 15 ä'0RMAT ( X, ' new de r: Lv ")

RI. TUF<N ,, - 16 WI I1'E(6,110,1 116, FORMAT( X, 'roc; ovr, r

F, o n. I ETU RN ;l WRITE (6p 117)"'! " 7.17,, f0 R11AT, (5X'µ'. t t, r. ck 1.1t LIu und of, , 5CQ V1 V) 9 ph'. 1ý: >4ar _ s. ... " Rl TUýýýrý ,ay. "I WRITE(6,12113TFiImi 123. 1"UY? MAT(10X, l%, rx wj a ': OAa.

RETURN- 2ý »-ý. WRITE(6,122) 3. Z, FORMAT (10X, '. raý, , 3ür, 7, )

RETURN WI I TE (6,12«S ).. , - 123 " FORMAT( loX, r'%i. j(.; ' : 'jorj: i I I(E. T'URN WRITE(6, i24)

ýf F UIt1'iA T(). OX p v'the

L wt. i'YE(6,, 125) 2 U... {- Of i"iAT (nx,. ritxý ý; sýýý. i. ,.. ýýtý : }! º .,?, ; xf: r l.: º LI<<x ºýýri 1.: *itc. ý: n ;, r ý, l ý : ýý ýa: t ; ý 'i»

:;. 26

i . . . . RETURN . »�

WRITE(6,126)-lER ($T'Fi, CNG(J) yJ )., 1ER) 126 _ F0RMAT( X'''r1etect: it: >i"t , taiill, '

. n, q ..; d; . '.

RETURN

1 WRITE(6,127)

127- FORMAT, -( . UX, "; tkhe. - reis aI, 1.1tit:, n ¶ et ins'v3QA1. ) Cyýa. "r' W RETURN

ENDJ ...

-tol 'TF1ý:. ý''. ,. k5: `t. p. 'ý°ýý+m.

'ý; tl' qaý ýk r, , 't' r. " ý q?

ß3; r . +il, y , ý,,.

! "k iV+. 7i" f, Y.. .k µi x..

R , ýSý"

. ý5

" ý '`"

±n`p }. zh il ý{

f ý'n

,' t j , ýj , y$, y{Y'i. "

}'`Ry'rkq ý,

ý 9`" , Y{, . , i . I... .ý qi ,.!.

't. . S'` ytý, N

ý"rý{, "ds "t t if }

ýý

,3 "C fA 3"J' ýý..

y s?,; 'X`""yý^+iwý^ý4! C; ý; yiµ ' . ýýt D

T k

"¬ ý ý_'i

`1ýý.

ýý'4ýyi

C ) ", SUBRQUT. IYE= jCRlED_,

-u1MF, LICIT INTI CJEN (A-Z

! _OG. tCAL3'17OR,: 3TiiINOä F'AiSE, RZ, INRP, WORIJ, STACK, V3yWO, WF(, 1WDIM, WDAT, AL', UD, NREX, W, WLr T �NiY, W(äoui::: r A, i, r.: l: R:: i {' CQMM0N -. 3TRINCi (30) , !., UNU 1/E0/MF', AMPUä(1.:, i0), (i' (000) yNPL1(40), NIt'I_'(40), NSY(20,6)

..: 1/B1/NF'., PARSE (l0ü) , NH' ä, ; ä'TAC K (6(} )

1 x32/Wo t' (10) , ýR ! 20) 1/B3/NCLI, NRP(12,12) gWL'IM(100) . l/B4/WDAT(i00), NLL, NC, rtLf (9, o) yOtl(9,6) 0),

rt*ii., WFi(10) yLLL, A, D

R. / 67U(100,2)

: a'1/I39/NEX, NFtEX(48,. 48), ULk:. T(x. 00).,

a/B] 0IV3( ,0.. .

DIMENSIO I'Wl: [)O (,: 100), iSu Mt10) h t)RMAT (1814)

~ FoRMAT*(SX; '2. (4, u x, 1ü(2A192X) ) F'(JRMAT, (XH QOX,

_"., LIiw

. vc: rc. ub'. 41ar yaf the gramm& P) FORMAT( ]OX, ' thr.

. pr: 'c: rr. de"ce-muthiI for DIM 1) ,F

GRMAT (). OX, l Sj), - F ORMAT(//10X, ' t, I t productions KAM tI e cJre: xmi :rF)

ýý. FORMAT(3X! /s)''10(4X,

jA1))

FORMAT(a. X, Al, 2X, 10(511,1X) ) WRITE (6,10) MFF', N; ', NCI: ], NLL, wc, NE:: X

, UR TE('6, y. i )_ DO 17 1=1, NCI) WRXTE(6,18) (NRF'(X, J),, J"l, NcD> WRITE(6, i S) 00 16 WI ITE(6 7? )I, ((W(J, R) yl<; '.. ty 2), JmZ, tOO, 20) UkITI (6,24).,. DU, 12 I 1, tII' 5; i_IM2. =MPOS(Z ) L. TM2=MIPS (I+]. ) °.: I. WRITE(6, ll)X, 1. JM1, (W(Oi<(. J), 1)'W(GR(J), 9), J nLEf1)., I.. EM2) WR T'i (6,112 ) WRlTEC6jXl2)

ýýI Ik . 1. T L« (ýx , ), q) Cf "l l'{.,. a. (t w) -ý hý i. , ,ý.. ý) .

WRX1'E(6, u' )

. Wf ITW(6, ), 0)((NSY(,. 1yW),,,! - ; I, l8), Kw; I,,,, i) URXTE(6,1l2) 00 %ll. I +1, NL WWI il:; ifi"lf, l)(1)1ißI+. y1.,.

WRITE(64112) WRlTE(6, a, 8)Wz'Al

, WRITE(6, ý11 ) . WRITE(6,18)WLET WRITE (6; 112) ID0 446 ;J 1', NRV

WPM, 1U)f: IN(J), (FIR. 3Y CI<), Is FIR(J) pFIR(Jfl )-I. WRJ. TE(6,1-12)

x,. WRITE(6, j2j )V; 3 FOR MAT, (, 4X, 1O( , A)., 1X)) DO 119 I, m J. °, NE; X WRITE (ä; týj )V3(I: )., (rvREX(: r, yA? jJmlj E; )

a.

R4w,

.w.. `

.. f .

'1 0 x :3 I. 8 wa, '72, "l 12

117

`t'om "='. ýiý ,Xý,

12 t r

f;: r

.? J I. xr v At ý. ...

ýxý ý Yqt, +

., .r ýýý ; ý,: °, 'ý R:: } ý, r ý,

jk r

446

r ý, 1

,4

I- III AO

. F-

*, ;. fhy., klýý? "-{. +:, ., 3,, ß';. t

ýT º:. ýs. 7' ,

R,, '' . z'?,. :. a'y. e;; výý*.. v, 'ý, i... ý'", . '$' t; ý.. f ir. 't ii. '; yý+

nt{ h,

*3 O a ýýý"i

, rte ,k 6ý - '', ýý. ̀" a

; ý: . ýý" _ y-ý, nr, ' .: ýý. _ý ý. . ý, eýý'ýx

,. ý3 5i o-ýs"ß. C4 ý. k, °" $'; ä x"! 'art'ý. i'ý` 4ý'^ý. "�r:

ý; . ý.., ý' ,. gyp ,. rn, ';; ý e±°ý'ti

, °) , k.. ̀., ýioxý r. ý: '"''ý ,. ''4` ',. i\ý"'ýý'' rý('` +4;,.. a,, 47 101 'ý#Sý:

ýx'`ýäa15 wý *aýý. ýý'ý 1 ý"ý6i ý; 'ý', w, r ý

... ,ýý .ý

ýý. ýTý,

ýý ý ý'ýýý 1. +;. . , '; kv ý-.. 'kti"

ý! ýY

? '' °. iä "',

. ''. >..; ý'. d . r; %3, ý' `f `t, ý \j'`.., ä "'SS: "F z, , ",, ' ýý. :. fit.. `ý

Y. k, , ý;. J'yk

7L (NRI, L3) 7I_OG ICANl 'T ST R : f. No ý4 tI T, AD , OD Wq Rr. 1

WU, UR META, A, X; ;, .t -`'COMMON STRING (3ü) , LUNG

liZ (20) \ti

, 1/83/NCit, NkI-'(]«, "i;? ), WEAN( 100)

"]. /I 4/UIiAT, (l00), NLL.., NCcaY, y} 1/Tt:, l1'I, WCit7G),,, f'lL., 411 t7tt), 1... Lk., a"i, k{ ,

: t/B9/NEXtt kl.: X t G, 4E1 , Ui.. i, i" ( : 1.00

WHITE{67' 12)NR 1., L.;, i :. q 12 FORMAT (2X, ' i)IRIJ: 1 , 1O3 A4

Ä30.3

1,133,1,337-133,13 W"', 1 ý. ,. 121 ý NM L 1ýý

yv3 f' .,. CF(ST1tiING. ( NM) ý«E. 39)GOTQ 'lr 142 NHNN+]

IF(NH. GE. LUNG)001'0 14; ýIFCSTRING( NH). NE. 39)G0T0 142 xF'(STRrNo(iýM).. Eo 44)ýlhi-ýNN4"; ý..

141 ,., CALL' F'ARSI'F{(a, NH, NLX, NRLX, WLE''T) r'xc 143 =.

, RETURN

CALL: 'ßRsP ('. ý, L3, NCX, ýtht~. X, ULI RETURN'

123 CALL LIIAGNO(3) = CALL PARSPR(3, L3, NEX, NREX, WLE1')

RETURN 124 CALL EI IAGNQ (1)

roý n. RETURN,,

.5 CALL ý, ýLJIAGNO (]. ) RETURN °w"..,.,..... :,,: ' .,.

., 126 CALL, iiIAGNQ{b) 14 ., CALL ' F'ARGF'R (6, L3, NCX, Nk WL E T )

: CF(L3., LT. LUN(, )h0TO a4.; RETURN

1«7 CALL ` OIAGNO (1) ". t' RETURN

<, 1«8 GALL FTkANS1(WLI, "t', tJLI. y (lC , rA Iy Li") iýETUkt'N ý...

«9 C f) LL1)1A0N0(9) 1 CAL1 1-'AKSP1i: C4, L3, NCJJ, i" RF WEith)

-y_ mex. -..,,,, ý i. 3o CALL UxAGNo 00 .

131 CALL DIAGNO t 11) RETURN

132 CALL ` DIAGNO(12) y

r; RETURN 133CALL DIAGNO(13)

RETUfiN 134 CALL'DIAGNO(14) ý "zý ý-" iýý.. TUrýN " 135 CALL ' DIAGNO (t ) ,... .. RETURN> y5 'i36 'CAL°L't"DIAG0 1e, ')

RETURN 137 .. ý_ý CACLý1'1 DIAGNU (17)

.,. 2.. RET URN 1.

$- -CALL"'

ý-ýýä'ei'; nsiý'. Yy, -Pqýs6 m{ oi;: -x8'{ Hý. 7ný.: r7 r ý,

ýrý ýi i: w'i ý; [ý'.? h' . , "+,.

'p'-t ,.. ý , n. ý, ý AYfh,, ýeg G"yý - a. ý1 ý, r ý .. u' "w' , #f yý, 6, 'ý: AN .i . ý"; ý? -i, v ,,

`i `, y {' ý, ̀ ? 3

ýy aY, .., fir(.. -e; , ý, ý ýý`t, ̀ . �M . ý.,

Fý" y 3wr`. m^. fi; i i. $9 ,; h ti ý.

y tee, 4C T ß' i« `'. ý, ý'ir4('ý, ý., T

+R: ý,

+E'i.

' ýzýýk; ý^ý-; _. ý: '-"`- ce +

ý, N., r iiý. ' t,. ntý , ý? ýýýý° ýa": . ": "ei

ý

. at< i . ý: ý. jc:

ý'e ; ýý

i

RETURN 4''

ýýý',. ". ü-'',; ý. S" ti` r 1ýý ä.

ý : ýuý. e. ,ýý..,., ,z, `. n'. ý; a

ý ý`` a .,., .. Ra, ý, x: ti . 'a`ýi, ý;; ý ', *Y, 3"; rý "ýaý

, ii .a k'M ýIl. FT"

. ü' ä ý.. i'e''L. ýA�iý "3wýýý "{ %, +n ý, 'sy�ý:, r.

$ß$9-.

r4-kZ ý -! `a. yRgr^n. ` ,, a. rý!.. R: "ý9''ý'*"'*;, rv

., "'a. : ý`q..

i"Rý"ý ý3 . J, ,. ý,., fl' ýrct-,., l nw y'ý': i re} ý' z, ý"rý,,

ýd. "s{iýiy;;. 'ý,;; ý .ký,

ýr.., i, ý: ý, ý>: ýýý, i, rýý yý`. i., zy_ý:,, <ýý ý:; ý. a.

ýa}. Cl., s,

ý+, ý"ý` ý

. ä, 'et, . t, Ký,. ý`t,,,,: ý;.

"eýi^. ̀rt. ý; ýrýt ýrs.

yý., e'a, krý''ý'ýýýtýý

.. 1, »; Y^z"JG. ýI

;, y, y,

5 ý. S`r'

'. M ;S A+µ,. ß: ýk",

"

brr M*, '. Y; 'ýdý 1t

",

.'"7, vAf-- "^. ý 'y' r*

57

^t "a' 'C'. 'rý'ý 'ýý;

ý'ýýb, ^�ý`. 'jig: Yir. 4'Cý, '>ý; °.. ><: qý;., k . a^ i. ýý., ;,

iý . ý, `ý. a e.: +'. 'p y'3 "^. ý; +^^e. i.; t ý :.. .. " "

-ü. SUBROUTINE �, LIISTAN (M, CUVG y NL, C, UVG, NtILi,, D v NFW ) ý-ý a ^kv

0CiICFLX14 CUVO10), CUVb(: t0), L{t. I, o 1, o).

t, -CONTI M

«iýr"ý ýýýý ., v. tý;. Y`ýýýý:

ýýv, n yl., ý. ýLlý"ý..

,. _ am. 7ý «'. ý`ýrý. _.

>ý"'ý. ýýrý r, ", ý"

°i ,. wý , a.

ý'ýý' ý�tý

. as r ,.

DO 53' J-?, N1_+].,

V. J `VM

V (Y.

k 'ý" r4) "

F. , cl N 4ý V

i. 7 \ 'ý : l7 V1of. l hrI

MA, M I+ :,..

t. J. " t' : ') GQTU 57

'p 2, kl F{U(T j) : hE, N13) GGTO ;.; '3

_ ,r .

k, ý-. y

`.. "ý

IF(NCAZ. . ýý. )

UTý 6'

NN 1

y4i. ý»+! `, ̀'7ý-;: R'rý '"'n`_'":, ee, i^s . "'; 'p:; ' `C' -..... h' .. ý. ýý. ty, 1. ''"ý': ̂ a. 34'i'+ "'ý"'%'ýv zii,: - .;.. .,

tI(M, +, lj) ,. GT. ýNN )GOTO "A', °Y,. v'T'" . NN I _S7, `.. " ý.. .. ýýý59

CONTINU '-sly

1'tEW =N

ETURN', ý.! 'ý'. rvý;

^4 "^j

*+{{j xa"ýi,..: V"ýý^n-#N" w. .S r`f4 .. li. ýi ̀ a ....,.. s .! r--r

IRETURN, -', .t" Y' yyafdyt, h'. xý'ýE ýý

+w.,,: r, ' ,wý. .. w . ý.. r- e .

ta.. v..

ýr. 'I_ý: ý

. .. d''

..... ' <ý

.x,

"= ý"'ý ;ý . "3UBROUTXNE TRACE (M, NL, D1, TR, NT) ý. °ý,

... � �^ _OUICAL%I. Dl 10v1O), TR(2,0 )'

:- N'T qiA:, '+r ' -Ykr, P. ýti _ý,,. +. ý' i� .' ii,: tr. ý, ra ýý aaeaý, ,. _

t'O 67 . K+J.

j4' -,. .x WFII T (ýb, Ei9) (I1 1 (ý , ýJ)

, J::. V NL+i J` '69

: ý. M. 1 Vj

"_ ý" " ý4 N! s'. ý2ý -. : oß. ß,

`«, r .a..

ý{ '. ii 1. .... -yi.

Gol

IF (1.! 1( . 1.

ý, j)-. 1`1 w

It (, 1, . 4)

ý'; d.

G 6J 1V(.; ,.

WRITE (6163. ) x'r 1 -' 65 73

a+ýiry: i

. q. a.. ý, Lr., ý: ý. ýý +ý3�'k.: iý+M "t,:;.

'ti.;

"..,..,, ý -.... " ^,., . ., '', ý,. t. ",;

ý - ..... - ... .., ..

w

, '4YJ;, ;}

. I..

b, ''ý:, s"`. Y:

WI,.. a j 1ý .: ys;

t . ý'^ý

ý! ýýý" ý, "

ärtý: w ýý.. ý'ý, y r t,

'a ýýI''. ý',. ýý,. : ''ý ,, ýqý. ý.. .

ý.. i. ý-, 'ýa: 4 :ä ýýi, a

ýýý

.. .

'x''°` ý ..

`. " ,.

C. - :x .r r'

44,

.., .,

I (NT++'w),: -- j. n;.

r

vZ,:.. ;x '' ý, i .s... .

ýti.. -

5`ý 4 ri"

t'

ý': r; ", ý .x

rya .4r

ý ý.. ý j.. k . -. z ,. _ 'xý'ýrý , 'ýý, 3- yes�t' x, t ý. " ý4 ±ýt.. a

(3010 6.., infOFiMflT' iX, 'r

al=r 14 4X rJ="'=`. 14) ;f

b. xb ýs RETURO, t ý5

,.

i.

, '. 7iý1S

,a h4.. r, ý4 w.. "w#r. a_'ý+b

. M'9 LN IJ

' R. a ..... ..

t.. N 1'.. - ýw Ä'ý iycy ýr Y.

i+ `:, y} ry'Y;

ý4ýýMýý41 ý'AXý

n

w'i'Pa -ýwrr9.

ry"ný i, ý Vk t'kl ýý- . "1"ýý

^-`-ýýý

r"ýýý

ýblh:. YÜ Y'ß. 1 xý' p'.

T'ývY"+' ^ýrý F , yyqý. F

ýr

"

, '" . ne w"ý.

. k'' .Vn: -

ýrJe

ýq- ; ý` -

, ý.,, �iý, a: "; ý,,. jý`r «a ý"'` ý" ýýk.. , ý'rt,

ýs rY ýýrtxý yýý>^ýt'A; ý"r. e, ýi

. týr.., w`^"mnr,, ±; i"ý. ýý , ti ; ̂ t , +ýý! *, R»ý. w `.:..

ý., ^. ýýa: "aýa+,. `; ' ý^KL!

ýaxn-. ý; ýý.

qý yýý, pý v.. s. M.: n ., u,.

ý. "d,., ý ." ; iv c. gýw.. t r. ýs' r. a' aýý .,, rý°., t81. rý ", t.;:, ý^-_tsý, ýr '°'1 ý? ".

. tW r ? v3 ýr ýý ý_ ýaý +,

ý, ýýr `.; ýa >,

ý, ý i ý, "4, ýr'Rf. °^tl ,3 ''"rr ý` 4' 'z tc;, ýsýiý; i; }. ý. ý.. ý ý%! _:.. yý° t` ýCý'ý v x.. `d t`yý4` . '^'-', T , ý"i., .: c;

_, ý . ýr'- .

Jý. "r <� , 9'" ý"ýC4. ý}.,. r': +. t. ý; a. t "; 'S., h.

yýý ., ' `ý{ 7` v'ý - v" ý yN

ý; r- r: F:: ' ''xrý 't arF !+ , dtv-a B, . "'', ý'S ý.

Yýý w t, ` ý. r 7ý _ '. ý, ýi ,ý mý'., ýý. ý 'ýnýý t`. Q"'ýý8,. "'i `; Y': 'z, r';: .t ýý ;ks: +rý

,.,. iß

.5 rý``., 'ýF ? ý' YrJ-.,? ý., s4.: _,

rn .,. ýy,, nl t: wý'xý / ^ýr1 Rti w"'. ý St,.

.,., t. __ , r_'. . ýiwý'9: ý e.. ". i:, ýýý°°. ''i

.^

ýý.. `

._r+,.. ýi'.

ý. aVk

x 'ý'ý: % ýkti "4« °^` e, ßä . ý.: k ! �'. 'ýv, ̀y"ä' . ý"+ý�i"`s' eýr, °1Mýk' s+^?; y'

ý. " i', ý " '1'^'; rýý+flý "U "ý ý". ,,, 1 a Y, t'- '' '

k. s1

rSU ýSOü. ý'INE'' MFýrc~+ 2(WCOD, MI-. 1'A, "N+CAI�> r_- y ,. JIMF LICIT',,, TNTEGER (A-Z) vtiNIS` yK , D1,1, )1 '( RES'W L; l. lD Wf: aVCDvWRF: Týy, l1, G`IJ

r f' l( !) I\} r 'COMMON 1Iý 4) fi Cl ;i t': In ",. ý {)) , ti R00 PS i'I» 4'r yL'. (ýr {)) , 14 S (2t} ,r)

/'B W(3( 1O) ,Nt,, i. 0) , i... i�i.., 1%B6/t. J(100 , '-2 )

a_4 ßJM1<, R1 ; i(a. t), sI't1.0), i"4LG(3.0J "'TA(10#: "3), HkTBt U, a)\ -°X ..

DIMENSI0NILIt1.0,: 1011i : 10),, Y'R(ß4 0WLWI(100, ý--

ý'ý C

" --tries' %. R _'r

Dl ý1 ý. t; I'L 1"a lýa Sä 'h. Y` .1 1'1 iý !ä ý1 C} 1'1 ýs'ý i i` f Pl ltil x: 11'

jai STS NS META,

333' FORMAT ( 5X', n'itch, 12M) N5=ßN1_"' '. ý". 1 N LU N-0 =0 DO 109. x=: l NL 'ý, "

109' WR(K) WCOtitWORD(K) ) rt.. - UlRlTE(7i333) (WR(K), KK= l, NL)

U"-.. NUI ST= I

i. M= N$Y"t 1" META) ä ßn110 100 NhýZ, L1M

illKlFNSY, (NK-"? 1hiA) .. a: f

110 100 ° ,t ä`! F? L» 1rt ýl 1ý 3) yN'L Ml >ý...

.^ CALL RHSF'RtIC, NL, M , WG)

ý' ".

110 116 , L=1 M 11fß ,` WG(L')=WCOh( WG(L)) .'

4"I ý"ý,

p <.

dYý i

GOTO(118,120, l. w2,123,124,1.2 )NCr1Z Cc: Lii f erentk ýu)'aut . 11es NL. r' Z I. 4

Cc HEAL-6 i.:. Ff a SUFF] X 1 , i" CALL }ý "'rü. % ýeý -

IF. ( LL NE ..

NL ) (40 0 -100

BFTS(MK, PiK')htF'Cllo(I+1) ' GOTO -104"`

Cc ýC: AZ=3 i<. .. d'0 r not fixed : i. c. nq tlA; r"(, NEW 22 122 NL=M+2: -s --, cc rs., NCAZ: =3 : as rärý' fixed ttr, g r. It N t11)y

, ̀ý.,.. x 3''ý. CALL tlISTAi! (if, WCi, nth, Wfti, NtI l, I: I NEW) ' °_a ; "ýý "' IF (NDU. GT`: NLIIST) GOTO 100

: (f (NDLI«EQ., NLITST. ANLI. NS«Gfw�NL)GOTO 3.00 NBIST=NLID} ... , r-'

ý. s. NI-L)NG=M

}, ý- - -NS=NEW': NI =I JO 128 J=i, M"+"x. DO, 126 'L=l; NL+1

t'. 126 , tii(J; i~)=Iº. t.; t: >.. ý.,

.ý3 CONTINUE

ýP, H" .. IF(NCAZ EO ßr3 NL:::. NEW

ý.:

(3UT0 10t? 1*Ä' Cct": ('119"x. 'is-'rä"r°no i'i: ": ri lc6'1 t NL ?

Cc match'wj, thout errors (NGA := "') (120) ./ ýý

ýw x"3'44 . Pw .ý:,

"/ "n

x

-i

-; ý 1 : F, (M. NE N'UGOTQ 1t)U ýý r ýý A. r` ý:

COLL'" F'I. EFtX , _. .. " al IF(LLL1LT^. o)UOTO y (ý/ ýsý ,. ýýý"'. ",,

ý, j

N' T Vii: "ý ,' : b. s:.

ý ý .. -,.

}. " .,

As. '

(3 0T 0 ýL. `7ýý

. k°"t -"».. ., . ý.,. ., a.. ,t.. ---.

", .ý

rý" dt'fi6 iý.;, P ý,

+ý, y/'ýM'ý1lx fi'Sr". n ! K, ̂ r9F e ýý .ý ý"I. r('r. °ýit. N4ia5. ̀ ,, . tra Tipi. ýý,....

y. °`

Y' .. ly ; 7kt:,, z

". ý'tiý'`°'. M-C ;: ý "^i. ý. {ý .

rýý y' ý4 "f-tf, yy ý.

I#'^- '. Jr. 'rý, -r. fý "'; "ýý ;,.. t ý. MF rýt -" eý

ýAd

o ., %r. ýný"Mýýb . 7_i 'v'ýý 'r w, 1 :S ý^ . .

'ý" ..... d. q{

'', .e

ýa .y rr "r-"ýaý

I" p r, gdo, xC: t . LC. iý 124--l'

-111- CALL SUrtSTF

J, ̀, - "': F(LLL. LT 'o)CQTo 100

. 'B TA (MK, MK I : =M 'L3 t z) +1 +M tiEtI (MIyMKI)LM1--'OS. (I)+LLL--?. GOTO: 1'0 .... y_,.. _ ..

,. ý`

. '>. "a: _4 f_ , 9f. "rfi : ý{7

Cc NCAZ='4 i, s-. for `prefix of o. production :i 1231 CALL. -PREEIX IF(LLL. NE»NL)GOTO 100

B TA(MN_, MI' 1)=t1POS('T)+1' BETB (MK MK1; ) =MPOS (I) +LLI , .. 104 NI

" '... RES t ý'iK, MI' 1 i" CR (MF'0S (I) ) _ MRESP (MK, Mhd. ') =ý

.'.. MLG(MK)=hKi RZ(3)=M : '°ý" ý.

C }r= WRITC(u, 93)GR(MI°OS( )),: lMK rMLC(MK), L+F'TA(hiK, MK1. ) rX11M(MltiyMK a. ) ., 93 FORMAT 1014 ) (2X" r - ,y MK1=Ml<i+ nu 41r^, '

100 CONTINUE '

ý#ý '`i. u_

-., rye. wärt, `, "., _ A= - ýr

l- ...

- 6,

ý .., ý"r" ýp v" "-N, i-. '4ý"iT"..

__ 'ýý-ý µ r ". . C x ýr au. r., r ni d äf' gr

7. IF(NCAZ. EO 2)UO

1U 12

4Yý y ,.

A

, ... .... _ .. s

.... A.

tN hei {ý w 4'1

) ý7 tJ

'1251

.. :f f= (NCAi CGE. 4 GO 1U '3.2'" CALL 'rf<AC 64L NGN: i L1t, T'li N7 , , F0RMAT2Xtv aceý' y LBI: WFiI 1"k; 6; 75)1("TRKK

.1 INI z; n,. RZ(3) TFi(2)'ý `'

132 . 'FORMAT(2t'x;. AI.; rr -' 29A1) 29A , 127

+'t" ht ' K1=MPOS(NI)ý :. ýýý .. ;ýý...

a. ýr_

WRITE(6,132). (W(Ciro(J) p 1, W(OR(J)2),: J=I<l Kl+"M) "RZ(l')=GR(MPOS(NI) ) RZ(2)=NLUNCi RETURN rw,.

129 RZ (1) ýa -ý:. ,.... . RZ (2) ýý ¬ ... I"cZt ä)

:. RETURN

:t SUBROUTINE r SUFFIX LOGICAL*1 '-WU, WR WCIRDp il, P"11: IA1 vAv 14

i -COMMON /B2IWORtI (10) RZ (20) ý a.... , , X/B5/M, WG(j. 0) NL WR(i0) I A }: LL r_. , , , M , , ' "rIO J37 'uJ»ýYý,

'M. 13T RZ(M+t-J) -WcI .; t) , "TJO 139r"JMý, NL ." ýýÄ'

. ,' 19 -'R ý. t, " Z (1 ,1 +NL. J )-Uh(J3

. ý y . .

^"1 b

ý+ ]f . (y,

ýj. rr" "y. <i "-.. m . .... tM-.

w} -. _

t

^ ý ' ýý^ý 13 ; ý ,.. , ;` t11 (J) : RZ (J )ý'". ". -; ýý -vom: "ti.. rý _ ` --CALL

RETURN x1a. EN LI ; a. Cäntfhil on "th iº ine: k ''ý ýý `f; ;'.. " ýF'ý ý'k iF'+"ý

ý

't `ý3Y .

iý`ý�lý, aK. ý,. ý;. 5 ?ý 8{. ' r3.

'vt. "' _ ri.

ýa; r ýä

1. ý; 'ý" ie, A, -y ýF 1. c+"'e

. {V- i ', ,

f` l'}Y ^'ay .. i4; Nl:? Ff. 4äýý}. `H4, q jý. K+., T ý! e"r , y'`C .

{` ýý ý. :! ý 6a{>' .7

! w"ý C" , yi"f

r ' '" ` ", P i " ' " ''rY " ' '

y " �'. .ý tt " Yr 5 .,, . . yý . f i ., yý. .. ai. Ka - i"Y1.. r - . "y', 'yr äN t; ýL"e

r, ý. ', in'J, iai Fi FF.

r. n, "Q(lY. «, sn "rJl "Ti R. r `°'ý 'X" y>pYy ; 1ý,?, pg

-�d%. t;. i6'.. '<" i"I"k, 2"uX. . ý''--"IV , ä''tt V itwyA"

"ý^i ! '? ': ^ :, r''s".: y, l Y 'jy: r_,

ý: 'y: lri:.: f yiµ'cgi' a-'r,:. x"rý'"i. 1k';: wr, N`>4 t. ', `ý ; g. l f, "' >

", + ' " 4: ^h ,

%«'iy E ! : y " - ' ' ý ° 9 t" ' , a )OW .

.. 2". r F ý: t ,. , F, , ,r

ru 1 K, . .y e ii,.

° . <. kS , e.. ,s ý 1" 5:

. 'P.; . , ; vt! r, dF dd""

. 'ý ^ý, týS

wý-ý4 , -l `"1 , ý. x, ysý 'jý. ' ýt : °'.

ýYr ý{y ". 4:. ý ýýY Yý.

r `

' ~ ý

ý y ý , ).

) rS 'ý"_ .. 51 d''hfr S('vY°:

.. ý' i. 4, < i.

y'fý "'Cz'. i{ , t'ýc ,: t]Y f,. T'. 'a:, \

i6y J"p. R'ý''ýiR

?" i"i ý"ýy'r 'ý, : P. $.. s". t5: yý°,

'i1 r. M s

` ýý

h lý 3ý Z ý

sýrý

'i ý+ 1 ý 'ý`

ý' ~ ý

ý r

' ý : "°} .. i , {u t ý'

. P_'r

- ý, ý ' ý

- ` }t t"< F. :

.. ý, sY^. ttf ''gip {a .. .Y-"

rt. _ : E° ý. ý _z> i i" üx t,. a.,...: r4". s >it .ZrA. ,""-

11 ° y`56_.. " n`ä 4 ý' CÄ": y., y:. 4+. `ý',,, : "'. v ,.: ýt

,, tn

, "rN

1"rM 1-tr

"i-ýýn+i ý`ýrl"y`ý M1..

! `Xý, t}Tc rF

, y1r NV-

 

tdgl

ýS`

I'!.

s, r. TrrW

1 ý,

V 1 'F <

t 1: 1 1P r', i:

, COMMON ýr'"'"; /M1. tf1(. i. 0 ANI tJR(1(? ý �týl I., is MTN: -%M -TF(M. GT°Nº... )MTN NL nth-10 1': 1 Ni7Ua TFMG(T-) NF. Ql. (T))00 TO

'ý! `` 1Q ua' _! C; QNTTNt1r' " ýý sý ýý ý, ' ýý

, ýý ý. :.: ý ' , 1... x. 1..; -ý r4 T' ýý ý_. ý. ý'. x ý ýzl-TURN

" .,. 12 r.. i_i_ RFTUF'N ý

1 < r Nei . j: "ý,

. ¢ýýI1rcrýT 1X; if)IITTtdý' IriAý rl M . ww ýTi, fir, t: 'r. irl4n Wt Ur"rrTA A

M rarrrrti; u1 '"!

y'*' ýt 'ý

, f - 3`..

. . . 0) NI ri0 MM CaN Pýý, M, t4(1 1

" 1 , , .. , ,; t

, !

#_: X to 1 ý1 ý, . U (

lfwý ! `{.. 2; M . w0(r) ), 0nTO ; ¶. c 1(I) . r", , IF(

IF(1't rM)(rnrr) 1 :! , -RETURN

/

. DDO 1.4 J, I,

., . r,, r+, " TFIWro Mr, ", LIP'(.. 1) )110Tr1 a. ft

a,, ̀ , f>4 ' ýr

X51 n`,

i'M^ CO JT, TýJIJ'"ý .

L_LL-.. >T V iii-TIiPN1 as, ý,. ," Y s`-b :; '*ýý°', _'` t..; ° I" Nil

'3r. JtrOU. IT*r. NF Rl-I 1F'R(I J l,, M li(7) j )mr; ". I 0 1a1'r, ýta''1 i, ir. 1t10) r; P NS ,Y Ur _ .

`f

;:

, ý.. ý. ' ý.. Lt7MMON /PQIMI::, t, Mrýt. ) t7. (7} yrý1ý, ýtý fýOý. 'ºI"ýl.. ",. r'.. O , i"d1°ý1 'ý(4O) ý'ý^Ytýh /T't'PAI0 rI l 't r P7 t 20

cc. r; tf "t', 11r"* t-th prrnfliir, h, i, rin r

M- o

. vX' { 4 t

LC , �

Ir(rsR' /ý r} ý+'1 )Cr)T lot 1 M=: N. }. 1

ý$ .ýý 02 f; OiýTxiýl1(" `. . RETURN °

03 "= Ml=ýQ 1 .

%1 Ml=M'1. +1' r; 7(MI-) rPK)

.. ýý, ý. rat«: e", 7':, '«; ý1,0$ 1FEGF' 1iN 93}I3OTO . 4w

-M /Ml '°. P'Y1 }C h" t-+ý /:

ý} i. y`ýM".,.,

' ' ..

it. f�Y rr kýl "t /*

' euf°#

" F'

ý, IF << Tw r. F "O 4 Q) ri 0T0 11 4 . 116 , j---t., ; rNfl _ ` º ; , ý,, .,.... .: f ý: «ý ýr' o 1.16 1.4. MI

( fit, *ý a w.. ,` "e"' ý'; ý fit'. t* ikiýtl rr

, `'

,

WGtMrnxl.. y

152 ý~

ýOýI.. ý. ý.

G ýYYýl it h"ifty Yr , ý.

', c ,. k

L.., ý, ý. Ä

c s-. ý.

.. p

- 'ý if . ýýw " 1ýý.

'`w /ý

}"ý"$r aIr R. "a,

a, '-ý". wýý., ý. ;. -w'. *rý: 'L-7ý. h' `5 APP END IX i. '"Y 4

ter, soy k )StsN$s�:

r ý�

y ý. ý "7rß

_ f...., rG

'ýý, 'w

kx.

aiý. yF 3'7J

_i

ý', '; 'r"

"6 ü`. ß: `e'=, 's, ̀x. S. ' 'ksý ýn_ý .. . x, N, r.

CCCCC SIMPLE`- PRECEDENCE vAr 3ER CCC: : `'-f:

`- SUBROUTINE P ARSPRMETANP OINT r NLI Ir MA T'k r WCOEI) INTEGER (A-R)

LOGICAL 1 STR I. NG' GR p NSY F' 16; äl°;: W013 I STACK MATR iLWCCITt'WrRES rBETA rWO It WR rfiltIThpAy)" ý..

".. . t` COMMON" STRING (30) , l_UNti °i. /BO/MP, ýrf Fl'UE (1: iO }'r G1i (. iOO )r NF'L ). (4(3) r Nt'i., 2(ý4t)) x NSY ('U r P))

I/BI/NP., PARSE 100 NPSySTACl< 0) . I(T2/W, OFýII,

_( ... 1 /Ei al t: WýGt-1oNLrWf tý. O}ý, �t.. fnºýiAýkýý.., "v.,

fiÄ T371II JUEFtiý. ()}mtll; il 10 ) rFtt ! C: (¬3'(J} I1(fS(r}Y; uc( C}} r1: Fýt I(}rt3)' tAs , .. _.,,. mý. x, ý. ̀ . , ETA(' O, 8)`'uhR(10), 1INL.. ('1. f}} rilXaFt r. `. f" ý`Y ''.. _ ., k' 1,8 lil'R ,S I0 87'rv, 1i 1-"(1 t)'rFeh}'p'm1ýtxt (? lt : TA'Ib i} 1-. 1 Ei'TBi 15t? 3)

yIfIMENS*ION "fiSA't'ly<N1: 1, t:, NXýI), rWt:, Gfl(; 100)`, '" nb+.

'P'ý; a.: ý+t; _ +ý.. ý «bsg tý-r, ý .. - tV w `a^. ýr. -. ý .. ' . t- r. .., y wv ttE a5 ? 4.,, `+'

,_<m . [�e E . 1.; ...

- ; ýýýýa . rii '"_ýýi'' iý+ }ýir. º }ýrrýý ýýý rýnLe r', ýniinºarý, ` , ýha ý.,, ý ý ..

ýr, vý cc

n". is : äpointor in the 4: ring,,. >>;,. <.,. r. Cc lu

.rEC is ia pointer in tho s> K. Cc . . I1 i t, hý.. tu mir ºt.. ý. ýý k,.. týnita<ýa . `Cc x, 12' "i º' hrýý riý: a"nºni . ýýýý rtirýýýý; ' ianih a'1 .. ,_

ýCC" º tai Tk,. is',, ' thtI. rda; Qf- 1, nw ti nNx, f I

t ýýät4ýýý "",

ý, <"ýýr -ý.

r.. ýSTEiCK1 )435f

g} (ýf[y .

ý; ̂ r: ', ü'q. Y

Aer9. ýý

, 7y M PyM

d. C "i. ý`",.

v

'kt .,,. !_

..,, ý.! ( Sý}""Sýobýýs, ayý., ýý. .. ýý.

'LIM ; ý. Ii""("MAT t. UCUD t 11) r Wt 01: 1 (12)) pý14r::. > 0O"10 1-, j 0"

_ 'ß. 4'". Y,

ä . -ýý - ".

,.,

k'- - %. ',. N/ýi+, 'ý-q! `,., ý,, - gw'{: ý ,ý , ", ' -_ .'y-

. I44 - 11=1 2

. 244$'rIUNO } Wt. lJU(12') «1:. tý. t' U )ý.. ýt. ltýt :: 014

14 t tll2tIA F(12 r 214 C1C Xrr{. 1. r : t. 4 r1 : I,. r Ix 1'. L r : 1. '*. rrrr ''`. ' sr 13G_ LAS=i"ihTk (WCta1. kj jrr Wt., 'C)t) WRITE'(7, ` : 14) f lJt: C)Xr (a. 1) yUC lXt t') )rLA DN PS, Nf'tä r l'

tI,. GOTOti. 06 11: _', 11 , r: l 1U)l fýZ. ý .

=r=. a s `Fýy`x

; fi Cc 'a "*ýi. ln p1a been ,

ý. pýlT' ti t; t? ý It'' been t'I tý' 't C iý: l, 'J

Cc. r C�r .

'marks., t, <ä beg : r7nx. rtiýa CC ý. 'i IF, I1<I2 t 1-tt nrtY und = 12 uarr put i. n 't, i'lk: ý; tuc. k t) xý3> Cc-' ° ß_r. if not. °relrit d w. Lt1A '12` 1x1I 06)4 Cc , i. fi... w; 12 u ýýlýY« < 1A 1 .t oI'r, do, tiýc tt.: 1 m tftir* '4 ý, ýx c It. (I 10)

<. :` Cc" ". ý nd='; 'the; `ý Barout » RL DUCI,. i. cr: t l rycl <<t14ý ý; ; zýfWRIT bla. )ý(W(: äTACiý( lý) ]-). ýW. ( STACK tl: yy (0 I rNiý i)

IF( STACt`, (14tý$) , ECG. M1~Tfý) GUTO ý. eý I ü; >r; F'ARSE(A00) r

7',.,, 'ý' ,.., . 7»°ECÜ rI MATR WCgD MG: TA'rx 2 N P, OlN. Tli '?, L( ýa .

NO)GOTO "ý'. ,ý-.

#+,

\` . - PS) , .4y

i': ý;

V

±Y" -ý

Gaib

:' ffjý2'"k4t +w' , ýA u výk, f. xr Y ü+. 4ý. ý.. ý

F°P'1

, Y`t! 'te' 'iý"I; ', d, 7"

ý'f i:. ýý A'ý ýýi '. ýA

": 5 V'. .: ýý,,

", 't`. "ý; "`;. ý' "ý; T. ̂ 'ý~x.? "nF w,,. � . rýs'ý , ýS7c+%aý; i fa#+ý ý',! ýä+, ",

m!,. t". ýe : 'i'ý iýý'rý'... u. ksb +, ä ý', i.. u '^ 4ý'". i ' n, ýd 1t;. , ýk ý

m' t"0ý5" `-f, " 4±' "3 °N r5""� F. v, apt

ýýu.

4ý " "5ý-, it a S'ax-

. Y. `; i" .;.. 'ý" 'i'=, %''e:, 'ý 'y., -" {tý. 'r y `" rr. rvu.: '"n k ; k.. "t, i `i?: 'a 2t- `"g 4;;. '

, ý`k. ',.:: s>w ýti, '. c. ýý �ý "t, . 51iYý Wh"F'e. . º.

_ ý. ,., :.,

.ý i`ý, 'i: .: i: d-, a , I:. ice: " , '. f, ti. ý. 1 t'y; M. e

`- S". v, aý. -a'Sýý '. ý'- k.. "ýýý: a" `: rý. ,

Yýy p t`iT7-., ý"'ýý'. c'" . tr. ý -, .

r, s"q, "5 ý< r` .:

ý. - , iý. s ýs ^ý+, 'rt ,, 5 ., ý., ý'_, +.

'"

t"ü . iý'ý. 4'Pi7;: ",

ým., k:. i m. `'t" -ýb^, raý-W,

ý,. a-_.., t', '. h, ý ý. . _.

ýý. ýJ ..

*', ... ,, ý �'ý ý .... ý"aý

CG'x..: s d11' ror'i rl l. ee i da scoy rt d

I IS . . Fo. R AT(1'2X, I3,2X, A3. )

IP6 S- TA CK('NPS1"'=6

Pt: . RZ (3) 22 1 6i A CALL t1IAGNO (26 )

(30T4 112

113

3a - Y; ý 11

111 r:. 146 ýK ý`3

iJ :.

X

i' r ,

}

156

4

1 32

t

NPS=NPS+x.:. STACK (NPS) =91 NP$=NO'S±j.;, , ;. S1ACK(NPS)'-2 I-0I*IAT(2Xý'gäLýºýIc.: 17(: IX, 2A1)) ) WRITE(6,11 )(W(SIACK(K), 1. ), ºýI( tF(X. LT. LUNG)C, o'ro 14'i :tF (N PS LE : ': l i. 10 TO1.1-: 1 I 2=35 CALL"``RECOV (NDI MATF? WC. 0liMF"TA t;? } RCTURP F. . >. NPOINTrztI IT1; »TW(N z:, °,

hT4

$UER©UTXNCý RE. UUCE NIºI MA º'(,. WCC7S: º ME: ''T F1 : t: > IMPLICIT INTEGER (A... I )

. LOGICAL*1 üTý l NC;, ii(i y NSY , F'tý1"yS y WQfýTº, >'T'A <C MA'1'ý2

SAE COMMON $TRXtaiG (;; 3()) , I. _UNt., 1/EO/MP, ýiPOS(1.50), GR( 500), WCLi(4O), ill: -'I,,, 2(4O), N! iY( Q, 6) 1/Eil/NP, PARSE(100) , NPS,;. "i fACK(o() ) 1 /B2/WORU (10) ,RZ ('20 )

ý. l Cý3/i"'ih, I'tilü: ýi i ý. Q, i: i id Fil'tl,.. ' il"' lIOy1; 3 }r º'il,.. l"; c 1. (1 iy1, '1: ': ýl'i (I. !1y fý) r rºý,. �l, rý ý7 ý) y ('i ) DIMENSION MA7f((t I. Iri. i I) , W(.. 1.1Sr t 1(iýr , Nrr &o

110 i 11~(UiACK(J? RL: U e",, it: f('. º'tºf f i!: S: F($1ACK(J. ). ý:: t3. i1)6010 i'. rtr CONTINUE. NO J+I XF(NE R. NNE. 0)(3UTU 1/o K; 0 DO 150 L'NQ, NPti (t;; FK+ 1. WURD(1 ll3TACK(L) NL=K CALL MA'rCH2(WCUCf, Mr r'A, Nf<9, r-RZ (I) fF"(NRloL0,. 0)U0TU 14). l. If"(MAT'li(WCÜI)(! <3Tr"i(;, 'Iv(J, -, I. ) )MWCOrl(NfZl, )? �ftýý? 7CCl'1fý

NP£=J+i: z. STACK (NP$)#»NRj,

PAR8C(Nr4) Rr : 4,. ) LETUP N

ý .. r". +( ý ý^w «. ti M'bý

ýrrsnýR,.,; SiYýMw.

rh^ýE w, ü

ýab3 M1 n, r>, rýg:.. 3 r ýi: a,. bL ä i's ?, ý. ý r= , ueK; ýý; Rý ? rý. g. 4s

zý. ý?. li; ýý'S, ".

ýiý1y3'ä rý, ý. ýýý, '`:, ý;,; ýXP'rýýt,

ýjtýýý'... tý4°. 9r ý

Fý" ^

: ý"j; ý: `?, y*y

+54-

I

'.. F, r y ýF`Ft

yý qvý}

shy. jT

ý. ýý

ýiýy ý1: ý

ýiý, _ý r3ýý'ý7ý

" k;, y : ßf;. 7 -v

. t,;. ' ýy .. ý yu'Y',

ý'o ý

r, ý1vý rr

. ý; '

Krk Fr

47

IýK

: s'

r: ý'ý'. y

:. ' , ýy�a. -; a: 9,

7

ti'; ä: ar4!

Yt

ýtq

'»'

rp 'r

._ý ý'

.ý ý'ýý. ý ,,,

in

ý fi*y

pý _a4 . ý,

t+1'isi.

ýý

4

Cc ýx -'p1ýr*zý", ý :; irr ur" ttý <.: > been ý¢: i <ýý c, v r +. l 162 GALL -PHRASE A

-RETURN ,:

Cc. errors.;. "an 4. fiv ": aL': xc 1: 170 NPS=NPS+i

STACK( NPä) =93 C CALL I ECüVi i NL' .y i"iAI'K�WCUDn i°1i;:: "('l": i

RETURN E=ND

SUBROUTINE PHI"RASE(ill']:, i"IATR, W(, OZº, tlr. "TA ) IMPLICIT INTEGER (A---Z) LOGICAL*1 MA'1R(ltII, NL'7: ), i�WCOtº(1.0O), S'TIi1: NC, RZ, WORD x, META, WG, WFG, A, B COMMON STRING(30), (. _UiNt:; 1/Ei1/NP, 'PARSE (3. oU) , NNV'S, , ä'TACIti (6() ) 1/B2/WORTº(1ö), RZ (2() ) 1/E{5/M, WG(10), NL, JR(: 1. O) LLL, A, L CALL MATCH2(WCOo, ME'r,: ),, e4) NFP'S =NO STACK(DIE'S)=RZ(1. ) RETURN END

-

SUBROUTINE REC0VE(N0!, MATR, WCODpMETQ : UIPLIC IT IN VI. --GER LOGICAL. '1 s"1" : 1NB, [: il"t, Nf"i'º,! 'AI"::: IE, WORD,,::; 'lilt': K: yMA1Iii 1 'RZ WGOL''MEiA, t yIzi::. r, L. 1f'i, 1;:: iLtyWbyWhiyr: i, )"+ COMMON 5TRIN(; (30) , I... UN(. ý 1/ fO/M , 11 1JS(). ýO)., (: ii''; ". i00), NF'I_.: L("4U)yNl I. '. ('dO)yý! "; iY(::: Uy, 1/E'1/NP, PARSI . (00) y NI"'::: y'"; 1'Fii,: h; (t: >() , - 1/B2/WORD (10) y RL (2() ) 1/ßf5/M, WG(`10) , NI.., Wii (i. C)) , I... LI_., (ý Y 7'; 1/B6/W("iQQ, 2) 1/B7/IIR, Zºl":: F'J. O), XII_>(. LQ) ynNC: ( o), tn.; i(3o) yw3ýC: (£iU) yL:. T'faý'i0, c; ) :L , E. TB( 10,8), DI1R(: 1.0) yDNL.. (: I. 0) , NUk, NCý'.; 1/B$/MK, RES(10,8) yM1": 1::: 13P(10,8) , iI.,. O(LO) ,, x: 'l:: r'A(7. ß, 8) y riETI:, (', i), cl) : l/E12/NN(20), NNN(20), EL., DEi_.: l. DIMENSION MATR (ND y NJ: '.;: y Li ors (: I. oo )

79

1 25

110 79 J-1 , 1() ETA(J, 8) 33 MLG(J)=() MK=O CALL DIAGNO (1 I) WRITE(o, l25)N1='S, (W(`ä'r'AcIR(. J). 7. ), J; *l, NPP'S) F'ORMATT(5X, 32A2) " DEL=STACK(2)

NCCý=O

NL-0

:3 .ý

y, w$ f ýýY ý. F

to

. ý. ii

"l

ý'ýý1 it ý1 jý. ýýýiif .,

lý _

rV ýN av

.°_# Y- ' "_. (; t: "< InIT, 10i i tj 1.1tKIv-hr.:. F

S. rYy1F

. ýi C-ý-.

"S Y . -t'a,

Uý , -, ý1 ' ..

DR

ALV('. 4*ý:

c ii e '.

-ý, , »

_ . li' ý{": f*ýý:.

'i. ýf . -1

. r-v- r , "ß t 4"f,

C* Lt YDZAGNO (a. 4 )

4CC=NCC+ 1 . .

ANCCJ) -0" -DPR<J)=MRESP(I,, J) DLS (J) =J LIM=BETB(1, J)+1. LM=MPOS(DPR(J)+1) -1. ,. -

,- . K. L=x WRITE"(7,41)L1M, u1, r'Ps(J)J

41 -FORM

AT(1OI4) ," pIF(LIM GT. LM)G0TO 1.4

.,. _ ý;. vETA(J, L.: )=GR(K) yt 12

- t

l"' t ei- i 14 E p l A

WRITE(6,3ß)J, NCC, DEk(J), D1.. S(, J), (W(1=*rA(JyJ... a. I. )I... 1,: 10 k=-. CONTINUE ., ý

URITE(6 37)

30" WRITE(6il36)ANC (t\), SUC(I<), orEi(K) ä;; =°: =1, <WEGk>CL°2), . ), L7. -lil'tJ: iC MPOs(. l"1F'Ri(K 3. i--1. i

154

z. S

ý: 4V N" 1Q0.:: ?

A-Z, 1.24

123 st rJ a

"a"( e"ý

78

y- Rý "

4-1

6 s C prefia' :, 'x F 77 CALL 01AGNQ t7

¢. .. CALL M4TCH2(WCOD,, 4ETA. 4) -, v4 I F(t1'ß. EU.

- 1. -)OO 1O -2-

s

G- su£fat x5 I2 , tAt A DtRGhiO (2 7 ) . .

: CAW. - ATCH2 UmLL: IA ý> ) Y .. , ++ x "ýýij, 'tj. : yý.

i=ýý ý'ý7Sýi`ý,

ý, ýt 3ýwYý^y-°''ý+'k .. d`ý'ýi"""'ý^? d it tom' ý ýe f1º1ý ^, ' ý yy .. J . -` kýýrýC N

ý`: s R <. ýý 7 " j+ý$ i ý".

+` . ý i C

a°ý x

34 . P

ý L. { . ý YJrý ý. ý}ý

"A

"r ý . 31 p Y r- Y aj . ̀. 5 i

156

NL= NL+1 : WORD (NO =STACK (: I:

I F( STA CKti )" NEN63N AN DYSI1

"1

C K( 1)

11

NEM i/

.

1.11 A1YJ. IY 31 AC

1\ (

.')NE. Y, ( )MOT1

iEL1. =S1TACK (I )

MK=rin+15. ". WRITE(6; i23)MK, (W(WOlwti(K), 1. ), K=7. yß! (... )

'FORMAT (5X", r bet': ' y�. L2, v 10A2) IF(tiEL. EC. 91. OR. M1:. EQ. i. )c:; OTO r. '

. substri' g,, "`'rF(NL". Eo 1 )G0T0 7

. CALL- LIIAßNO(27 ) , tA

.L HATCH2 (WCOD, META15)

GOT0 x, 33

MK=MK+i.,; BETA (MK; 'J); =10 BE. TEC(Mlt, J)==499 RES (MK, 'x) =WO D (1 MRE: SP(MK, l) -o MLG (MK)t; -I. ' GOTO 1 s3

\

J

`k

"s'R"; " . ra; xý F.

r ý"

;- -' 32

Q$>.. 37" . `{ _r" -36.. x,

ýs

j. ý

jI

K

�,

yJ

r jýý

:Y M' aÄý

K ý.

{

f:

"

42

43

48 46

1 56

CALL. CONECT (META, r1Lº1, MATR) DEL= DELI' WRXTE(, o,, 3a)PR, NDR FORMAT (4OK, 8I4 ) FORMA, T(3OX; ''J., ncc, etii ' , 414,5X, 12AJ. ) FORMAT(3OX. ''arc, s1.1 r_:, prt) '. I: FORt1AT ( 8X-, 3I4, X, 1 OA 1.

CALL =-t'IAGNO (15 ) 710 42 J=1, NDR WRITE(6,4)-J,, NCC, NCC, NC(;, (J(ETB(J, L1), 1), L: tu: i., 4 ) WRITE(6,37) .' D0 43 tC-1,, NCC WRITE(6,36)ANC(k), SUC(IR), L'Prý (Is) 1, (W(GR(L1') }, l) , L1-MPoa(z: HA(K) DR=NDR 110 46 J=1, I'R. DER (J)=DRR'(J)' ILLS (J)-ONL, (, J) D0 48"L=1-; P LTA(J, L)=-ETB(J, L ) CONTINUE GOTO alp:

\ETURN `. Ellýl

SUBROUTINE, AFLA (META, AA, . 8! (3 ) IMPLICIT INTEGER (A-Z.. '

-\

CC. finds a pr'od'uction Sr' :... u IA v . CJ:, w such 1, i"ß.. 1, Cr A is in FIRST (I A) and Jac is in FIk 31' (1 D) Cc there -ure" N14(1) such productions denoted by NN (2 )' .� LOGICAL*1 -U$, WR , RE S, IA, : I: I, ok, NSY, t"EETA, A, B, AA, F.. i: {

COMMON /RO/M ', M1~'OS(1` 0) y lä12 ( 500) , N1°'I... ). ( ßb0) p N! 'I...: ' , 40) y NI: iY (;. '. () g F> ) 1/; ßt5/MpWO( 10. ), NL, UR 10) yL_LL, A, )E.; 1/B12/NN(20)', NNN(24), DEL, LE'I...: I. A=AA

.? L_IM=NSY(1, i1ETA) ,z NN(1)=1.

£10 100 NK=2, LTM rI i'4K1=NSY (NK, 14FTA )

U0 1O0ý i =NF'L1(NK1), NF'I_ (Nk1 CALL RHSPR'( I", NL, M, WG ) J=1

15 I1= (METASY(WG(J)) . E0.1. )i3ÜT'O 1.0 IF(J. GE. M)GOT0 100 J= J+x

Iti 4 10 : CA=WG(J)

1.3 I (J w0E.

(1) t3 QTT U

EF METASY (: WCý, (J)) " Pic .aý; O Y'ta 1.1. '. t : IE WG(J)... _. .,;

Wh17k(6, "2(? )A, b , iA, IB, I, j' ti ý92O FORMAT (YX p! 'a, ki, : L,.,, 8.1.4

W. ' CALL i^_fiST. (1 A; A, NV ) Ii`(NV. NE. 1)GOTO 30 CALLS ST(xi7, B, NV) [F ZW�EQ. Ö)GtJTG ': 3()

-1 Y NN(NN( I, 30 -, ZA=IE{ -

OOTO 11 ý,. " ._.

"r. r, A

`^R , ý1;

'jr KY-+t : 4Y' 'k h

"'it S` 'z e ': lÄ . ßi4"', h'.. ; f..

rl

'isý'ý . '' . 1' . sykib'

"1' ;'+. n _ý'.

ßs.. 5 ýý. si_Iý1±'^s.: { J

3't'ß -. _

, 't°. '"j X,

z, ýý

b' S,

t^ý'TMy+

1 1- in-, I

Woo

WIT

7Y '

- Icy

{

tµ ýxi{'

YiT: dý

'" YSy

3aß ý tv-y-

ý

" `fir yý

_ i.

MAW

:w o#`*, IF'thNfil, ). E0. )GýT: J 20 PACLL, %PIAGNO(23)

ý,;, r. WRITE(6,901) (NN(J) j-1, NN(1) 905 "FOMMAT ( ;X 1014

_RETURN`: ti; - 20 0WRITE(-6,919) 919 ;:; `: ORMA :tr; `. fail')

ENit 2

'SUBROUTINE WH1CH(FA, kIfs) ,... , ; rIMPLIMOINTEGER t A-7 f

LOGICAL*.: '-UK p-NsY, h Ar GA y�St, WG., WFR iJt°i%it7iý[r. f .Ü `iM r i{POE t 1.: _ýQ) r

(31 i0(} S y5N 'i.. ( X30) . Pdi° L. 2 t Mý/13JýAfäUGt10) rNL, WR(IO), LLLrlayr! T! 7B12/NNj20) pNNN(20) , DG: 1. _yDlll.. I C>findý_, g`, ri rivat 7ý tart hA- ýa iA

NKi =EA DU-, 10 x=FI IF('F"IRSt, ' "l'ý. EU. OA) GUTO 104 CONT NV=U

v 'I

NF'LI (NtU) p NF'L (NKI) .'k: ' raint. all I~ A-pr ocluctiu n,.: > "". D( 1O2 KS=MPOS( I )+1,1'1F'OE (I+ )- . ýf: ktýrJ ': i rne, t,,: Aý. ºý1m1: >c;, l. : ý. rr f'tHSC

.1 IF(METASY. (Ghcl<1)). NE. i)ci(j, 'fj 102 . '"CALL - FRST'(OR ( K1) , 0A, NV )

. ý. IF(GR(tc . ). EQ. GA)(30rO 104

'IF(NV. EQ. MO)GOTO 100 WRITE(b, 921){ A, , NV,: I:

92i. 'F0RMAT(12X, 'f"lth&r G'i, tjr «', ý3ý°º)

. IF(GR(Kl),. Eo. 1-A)GOTO : 100 "1ÄQ# NNN(1)'=SINN(1. )+1

NNN(NNNt111. )=1

-6010' 10(

°102 CONTINUEI- "":: 100 '`CONTINUE-

ý_WRITE(b,,? 1 )(iA, r-A, (NNN(,. )), JY1, NNN(: L) 912 "FCIRMAT(3ýCý'r ýº1L .. (l, i fi, t1r11't«',: 1 14/2X, 101'4?

r. ETURHsx. t .. a

SUBROUTINE- FWS i (FA, GA ý I`4 J)

LOGICAL*1. (3A 9 COMMON ! 1' ýTlhv' F .I&. at1: I IR ,i (200)

10 106

, +aw-aa }: ý'4 r

:a

rye' 104

4- '

401' ylýý�ý i ýf)y

I w+

WON +""<i'c i.:.. ., t. ý, ý `qy FFiý& fir:

. y'a'y, , #.. ,: AVOW,

ý ! iI "" 3 rx ' -+ýse

G ":! qlý :, y>,. �"

"(IF ' ; r^ý.. 'p' .K: ý,,;. týý M«, nr . x; at. . ýpý +9ý', ý.,: t''ý <; . býP .C '1 lr° Iýb `< ý

r , , ;, ; ýý' ý`ý "f }: ^ aa ýr " ý1' .ý T , at t.

ý" ýý' , . . ý ý ý ,

ýw d" .. K k ý-'5=ý; ýý; k .ý , , + , r 7r bad3fi..:

ý+ýt'e ; r.

ý4'"ý t ? ý. -ý"'ýiý-ý`-"y; ý " '` : . , , .

.. ý <- 'tiý., <, `iý ý". ;r

,

:1 58t

-s "J

f ya . -ý.

_ Y .

ý,, rAt

1ý',

SYLR

sf

""S i

, Mop

QMT

A4

, '17

-44

"1 ", {` }ý. " -fir, .

_ mal,

ftt r "i

Aso

Mý ý1

r. .. si

Not

"' f.. UIlROUTXNE CUNECT (? 1l: TA, NUXIAAT ) -Z) iM*'LSCIT. ' IFNTEGER (t

Wl"" 1_OG1CAL*i ; ßTF )NU, Gh; 9NSY, h'AFZSE , W(: ltEir;: i'1t' . IS, Mt ;r :A4 %_RZ; WCdV MET(, WpRES, ETA, L': TP,, WG, WR, A, J,

-; ýCGMMON; WPINU(30), LuN1 NiF' i`'POS(1:: 0)yGR(500), NF'LI(iO), NPE2(4i))yN Y(;. 0rfir)

ý1ý/E1`/NP, F'AFiß iiOO). NFb, : ý'EF\t, IvtoC)) %B2/WÜbTº(1.0), RZ(20,

,.. "ýli :, /M; *t . 0)., NLyWry: (1(; ), 4.. LL, A, B

4l/B6/W(100,2) ýtIER(XO), 0L: 5(10) rAWC; (ßO)� I1-'k(i3O, 5UC(£3O), W'rA(1. ', '3)

., ETB(1Ü, 8) ý, )1Rhi 10) Y1fNL. .

0? , NtIhý ,r CC; i -S lFßj K"R SA 10, £3)yMliE W( 10 ,8 i'51.., 0 (10 ETA 10,8(, tE ,Tt: l()r8

'M11/B1 /Nib(20), iýNN 2t)), Xýr.:: i,.,, L1EL: i IE lß OýC,

nt`iA'Chtýl WCOJ(100)

CALL. DIAGNgtý; I NUR-4 Fv; ý:.

DO''135`K 1; DR There are R possible derivations MP LIPR(L'ER(K) ) fý=GFG (MPOS CHP) ) IH(ETA M;, I'). EQ. 35)COTO 135' ný

IF`-(ETA(iC; 1: )t. 'EQ. 3 )G0T0 1.2

, %F. (METASY(ETACK, L)). EQ� I. AND�C: l «ED. 0)C I=ETACK, L)

10 WG"(L. )=ETA (l<, L) 1'�' M=L* j.

C.

" k;

Ca

Cat 137

20 cn1 159 92

16. =r

9r

ý" ýf S 1. +P t ?. +! 'A

V t"

" : ß'3'L Lýý`ý-' zs'- o k: #.. "Yý±. _-'yý:.

ý,

There are" MUG(MK) elements in Lhe ýaý=t, Reis(MK) 'DO -135 'J=i; MLG(MK) MQ=MRESP(Mt, J) B=GR (MPOS(1MQ) )

`check 4t"4' = >3 gal hit'a rI

. IF(EETA(th' J) 6'1 BE' '11: (Mi-, J)

iiR«Nz. 11zi='D'ER (K ) NCC=NCC4 2 °. ANC CNCC 3 =NCC-1. flPR(t4CC)=MC4 BNL(NDR)= NCC DO 20 -I L, 8 ETB(NtR', I+I-L) -ETF, (K, L) IF(TJEL. EQ. 91)GUT0 a. *, t'..,

NL

=O . t.

WRITE (6,92) Miß, J, BETA (MK, J) , BE*rB (MK, J) FOR MAT (2X, v MK, J, laE trx' ,(J. 4 ) DO. 16 L ETA(MK, J), BETB(MK, J) ill.. --NL. +1. WR(NL)=GF(L) CALL SUB$TR WRSTE(6,91)NL, LLL FORMAT( OX'r"n"1,1: ii: = , 416) iF(t. tl: -. LT-:, )'GOTO 157 tlllF NE'R+3.

Jp, 18 L=i9, ý.. l. L '7E'TB (NDF L+1--M) =ETA (.. 1, L.

6

"rý'ý, e'ýi" '. ý

PHý*' ýýý . ate, Irv zn °xon 't; ek v , irw .. q#f zr"n+5 vnuP+wrýaglr'qlf s"qýýý 'ham,

. E., ,'

(301 0 : 1.4 i_nr ion''

-br

{t

fýýY

ýY

<V

`

.y

{

.i

i

,i 4ý

3. '. 34 14?

Cd 139

903

Ct t Lk. 9 A. `., it I"t-" u n7i,. WskjObUL Waded

It (j. -USi. WI. -; uf .

HE i PiQKpW WL) fli I.: i`>'

I(-1 1. ý- ý.:.... ; i},?; 'st. i! ý .. vJ: l (t=r'... i"�.. i`

. . . ý. k;. IF( HE (fiý: 7 I'i: l' ý. t : ̀,.:. l. d.. `.. 'S ,.: iL. J Ti. ) L

Ci. '1L1.. LiHiChi4fi. i oii1 NCO=NCC±: i. NLifi=Ni R-" 1 NCC=NCC+1. ANC(NCO)JCL OPR (NC: C) : =MU SUC (NCC) =NCO DRR(NLIR)=Nc(:, IDNL (NY'R) =NCC--1 LIM= BETi(MKyM LM=MPC)S(MO+1. )"-1.

Ii= (LIM, GGT"�I_. i-'M30TO (8; 1, DU 132 L LJ. M, I... sit I:. TA(J, L)=(ähiii\ L=L+"i

COW 3 Nu"::

check C 1' i. fý 11 t:? . ': ' NL- !

--! UR !. 1 tom. i b, M! i-+Q

CALL. h11-LAMiH, A, H)

LF(NNl. i). L.. L�: L? UOTO (. ý; 'º

Wo-NOCH

N(., G.: NCC"*''i.

UFR(NC; C) =1f--'

SUC i NC 1 ;'::: r' I..; Ie-, - i. CALL uHIC; °i(. 1r'ipAI) CALL UH i0H (. Q. B)

insertion

CUNT l: NUIL RETI_JRIi\' END

s`', z_ 0 -4

7 74

C14 tv,

'i 135 "1

1

a}ks'"

,.

suety'

bLýFyýý, }

10

ýy

- .. ýG

._ , 1. ti

..,. _'4

ýNýS� ,..

ýý : ti . j@ý`ý; =ý ý. ýý'ýd^ý, ýt`ý`'. 'ý, ý" f7,: ä, » ýlqýklý.

"C+

,"' 960 1''ý 17uß:

He, who is thinking alone, and is scratching the light,

Has given a new life and an iron man, the machine,

A being invented by dream and vision

Unbelivable stronger than his arm and shoulder.

Tudor Arghezi

(from "He, who is thinking alone")

161