3
I INFORMATION PROCESSIbrG LETTERS I(19721 97-99. NORTH-HOLLAND PUBLISHING COMPANY 1 i 4 1 4 i * 6 ECT - AN EXTE~SIBLE-CONTRACTABLE TRANSLATOR SYSTE 0 . 9 ,. N. SOLNTSEFF Departmentof Applkd Mathematics, M&aster L%riwrsity, Hamilton, Ontario, Cow& and A. YEZERSKI IP Computer Consultants, Sydney, N.S. W., Australia Received 1OJ~ly 1971 extenable semantics language contractible program-restructuring 1. Ontmduction The ECT system is a tool for the provision of variability in programminglanguages. It has been de- signed on the assumption that a single base language is insGkient tc provide all conceivable extensions bemuse any given base language wiil in general be too complicated for some directions of extension and, at the same time, too simple for others. Thus, the amount of effort required to introduce an extension may be large if the base &nguage i 5 unsuited to sup- port the extension, while the “overhead” of the ex- tended language Tay be prohibitively high because of the presence of unwanted features. The ECT ex- tension mechanism is independent of any particular base IanGuage and can be used with any number of base languages provided that their translators are written in the language of the ECT system ~QCI have a b mmar that can be handled by the system analyzer. The basis of the ECT system is that the syntax of a *This! work was supported in part by Grant No. F69116059 of the Australian Reaeareh Grants Committee and was per formed while the aut@ars were in the Department of I&c- tronic $‘omputation, The University of N.S.W. +Revised version of paper presented at the International Syin- gosium on ExtensibIe Languages,September 3-5, II 97 1 F Grenoble. programming languageo compilercompger syntax language translator-description ianguage language is defined by a BNF-type grammar and the semantics by an e>itensibiecontractibie translator. me ECT concept is a development and in a sense, a syn- thesis of the compiler-compiler and extensibie-icn- guage concepts. The system incorporates a set of %se’- language translators of graded complexity, for example, processors for a FORTRAN-like language, an Algo’ like language, an APL-like language, etc., and an ex- tension mechanism for modifying these translators or even creating a new one from scratch. The user speci- fies changes to ihe syntax and semantics of a partic- ular language by describing the changes to be made in its tr&iator by means of statements in a transiator- description language METALANG. The METALAMG statements modify the translator sables or alter its structure. METALANG has the f&lowing three com- ponent s: 1. A program restructuring language (PRL) used to direct the alteration of the translator tables and structure; 2. _4syntax-description ianguabe (SXL) used to de- scribe the syntax of a base language and also to introduce changes in syntax; 3. A semantics-description language (SML) used to specify the meaning of constructs in the base language and any extensions.

ECT — an extensible contractable translator system

Embed Size (px)

Citation preview

Page 1: ECT — an extensible contractable translator system

I INFORMATION PROCESSIbrG LETTERS I(19721 97-99. NORTH-HOLLAND PUBLISHING COMPANY

‘ 1 i 4

1 4 i *

6 ECT - AN EXTE~SIBLE-CONTRACTABLE TRANSLATOR SYSTE 0 . 9 ,.

N. SOLNTSEFF Department of Applkd Mathematics, M&aster L%riwrsity, Hamilton, Ontario, Cow&

and

A. YEZERSKI IP Computer Consultants, Sydney, N.S. W., Australia

Received 1OJ~ly 1971

extenable semantics language

contractible program-restructuring

1. Ontmduction

The ECT system is a tool for the provision of variability in programming languages. It has been de- signed on the assumption that a single base language is insGkient tc provide all conceivable extensions bemuse any given base language wiil in general be too complicated for some directions of extension and, at the same time, too simple for others. Thus, the amount of effort required to introduce an extension may be large if the base &nguage i 5 unsuited to sup- port the extension, while the “overhead” of the ex- tended language Tay be prohibitively high because

’ of the presence of unwanted features. The ECT ex- tension mechanism is independent of any particular base IanGuage and can be used with any number of base languages provided that their translators are written in the language of the ECT system ~QCI have a b mmar that can be handled by the system analyzer.

The basis of the ECT system is that the syntax of a

*This! work was supported in part by Grant No. F69116059 of the Australian Reaeareh Grants Committee and was per formed while the aut@ars were in the Department of I&c- tronic $‘omputation, The University of N.S.W.

+Revised version of paper presented at the International Syin- gosium on ExtensibIe Languages, September 3-5, II 97 1 F Grenoble.

programming languageo compilercompger

syntax language translator-description ianguage

language is defined by a BNF-type grammar and the semantics by an e>itensibiecontractibie translator. me ECT concept is a development and in a sense, a syn- thesis of the compiler-compiler and extensibie-icn- guage concepts. The system incorporates a set of %se’- language translators of graded complexity, for example, processors for a FORTRAN-like language, an Algo’ like language, an APL-like language, etc., and an ex- tension mechanism for modifying these translators or even creating a new one from scratch. The user speci- fies changes to ihe syntax and semantics of a partic- ular language by describing the changes to be made in its tr&iator by means of statements in a transiator- description language METALANG. The METALAMG statements modify the translator sables or alter its structure. METALANG has the f&lowing three com- ponent s:

1. A program restructuring language (PRL) used to direct the alteration of the translator tables and structure;

2. _4 syntax-description ianguabe (SXL) used to de- scribe the syntax of a base language and also to introduce changes in syntax;

3. A semantics-description language (SML) used to

specify the meaning of constructs in the base language and any extensions.

Page 2: ECT — an extensible contractable translator system

# j, :’ ;; it@ rim ttrlrtoucttiing language

’ I_ ,gp “‘$& , i ‘a The prcg.ram restructuring language is the compo-

Ei”ALAldG which is provided to accomplish m&ifi&tion. By means of PRL statements,

user can select one of the base-language processors, new features into it, or delete features tl&

not required and thus produce a translator for P language. An impxtant feature of tie

of the ECT system is that the parts of’ uage trarulator which do not need mc-di-

e form and do not teed . The fact that modifications can be recompilation greatly reduces the cost

tion by comparison with translator . PRL bears a superficial rt:sembiance fariiity, but operates on object-lan- pening statement of a tratislator-

I j ,,if W! S%bthg tiguage processor is to be modified, ‘or compfier name i

age processor is to be created from z .I

’ Thrryntax of a base language or of any changes to in the syntax-description language SXL.

ed form of BNF notation [3] in which n the nonterminal

atena$ion is indicated by a of a prodtition- is indi-

: r ’

0

ate exei;uted, the translator

AE =T IAE,"t9',PI. z&. ? s: F 1 "f y", F, I; = P i t,,“Y’, P. F-VIC.

:

4. Semmtics-description language

The semantics-description language SML is the lan- guitge in which the trar&tors of the base-language set of the ECT system are written. It is an extended ver- sion of XPL [4], the main difference being thst a pro- cedure-definition body is a single SML statement and that a single procedure may have several definition bodies, a particular one being selectable by an integer ,index. These procedure-array elements must have iden- tical attribute sets, i.e., they must all return a value of thesame type and the attributes and number of their formal urguments must be identical. Currently; 8 single syntti analyzer is provided within’ the BCT sys- tem and this imposss the restriction that all base late- guages must be of the McICeemancxtended-prece- denee type [4] . This restriction will be removed in future ver&ons of the system.

A language translator written in Z&IL consists of a set oi’ declarations of global variables followed by a sequerkce of declarations of ,procedures, one of which must be a main procedure. There is no block structure and no recursion. Rach procedure can &ve its own set of lo& variables. Yhe names of procedures and global u%riables are kept in a symbol table which remains in core during elxecutionso that alterations to the vmbol table can be: r&e at any time by means of <uitable PRL %atemgnts; for example, the statements

add (A&C) FIXED. ’ add B:FRW.(A=B+C) .>I

deiete X,Y,Z. . result in the addition & the global identifies of type HXED and the procedure identifier D with the defi- nition body (A s B + c) to the symbol table and the deletion of the identifiers X, Y, 2 together with their attribute entries. The statement

mphI# D:FROC. (A = B - C) r&kWn thedefinition of procedure D in the symbol table beinQlian@d to (A = B - C); ’

Changes to the semantics of a base language are madp by the addition or ,replacemerrt ‘of prcrcedures. Thus, the syntax changes illustrated in section 2 .w&ld

Page 3: ECT — an extensible contractable translator system

NSolntspfs, A. Yezerski, E%I’ - An ex;.ensible-contractoble tr4n :btor system 99

be accompanied by a set of PRL statements effecting the corresponding changes to the semantic routines of the translator. Only the procedures that are a.dded or replaced need compikion, the unaltered proce- dures remaining in object-language form. In its overall strategy the ECT system behaves as a compilercom- piler if a new base-language processor is being created or as a compiler-modifier if an existing base-language processor is beicg altered.

The ECT systejm has bec.!lr in use at the University of New South Wales (since January 1970. Experience has shown that it CZUI be used ::o make substantial changes to a progmmming language, induding changes not anticipated by the language designer. The system can be used to produce efficient translators at a reasonable cost in computer time, a typical factor by comparison with the X.FL system beins h [l] . Finally, the system

maintains tight CU~IUU,~ over the translator expansion and -contraction process, detecting and preventing operations that could give ris3 tc, an erroneously structured translator.

References

A. Yezerski, Extensible Contractable Translators, Doc- toral Dissertation, The University of New South WaI,?s, Kensington, N.S.W. (1971). N. Solntseff, A classification of extensible prcgrai&ning language& July 1971, Inform. Rot. Letters I i1972) 9?. J.S. Rob?, A note or! Ritckus Naut Form, The Computer Journal ’ 0 (1968) 336. WM. McXeeman, J.J. Horning, and D.B. Wortman, A Compiler Generator (prentic4-M Inc., Englewood Cliffs, ‘rJ.3 .) 1970.