Jump to content

IMP (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Danakil (talk | contribs) at 22:13, 28 August 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

IMP is a defunct family of programming languages intended primarily for systems programming, although at least one IMP was extended enough to be a general-purpose programming language. Expressively, IMP is similar to FORTRAN II, while syntactically it looks more like ALGOL, although it lacks block structure, reserved keywords, and datatypes (it does support both integer and floating-point numbers). IMP allows the programmer to embed machine language instructions into the IMP source code.

IMP is expression-oriented: there is no distinction between common expressions and statements, even though sometimes an expression is only needed for its [[side-effect(programming)|]]s. For example, a read statement's value indicates whether and EOL (end-of-line) or an EOF (end-of-file) was encountered, although what's typically used is the expression's side effect of performing input.

IMP compilers were developed for the CDC-6600, PDP-10 and PDP-11 computers. Important IMP versions were IMP65, IMP70, and IMP72. IMP was used to implement the EMAS operating system.

Extensible syntax in IMP72

Being an extensible syntax programming language, IMP it allows the programmer to extend its syntax, although no specific means are provided to add new datatypes or structures to it. To achieve its syntax-extensibility, IMP uses a powerful parse algorithm based on a syntax graph and several connectivity matrices. The programmer may add new BNF productions to the graph.

IMP72's syntax is extended by means of extended-BNF syntax statements included in a source program. The mechanism is so powerful, that it allowed the implementation of the language by itself, i.e., by an IMP72 source file consisting entirely of syntax statements, which was input to a trivial compiler which was initially able to translate the simplest case of the syntax statement. There is also a simple form of the syntax statement which looks like a macro to the casual user.

Basically, the syntax statement is an augmented BNF production with associated semantics added on the right:

<class> ::= syntax-part ::= semantic-part

For example, to add the construct described by the following BNF:

<EXP> ::= INCREMENT <VBL>

with the semantics that INCREMENT V should translate to V ← V + 1, the programmer would only need to insert the following IMP statement:

<EXP> ::= INCREMENT <VBL,A> ::= "A←A+1"

The semantic-part can also contain calls to semantic routines, as in the following syntax statement:

<ATOM> ::= ABS ( <ATOM,A> ) ::= DEWOP(214B,AREG1(1,13),A)

The semantic part of this statement consists of a call on the semantic routine DEWOP. The arguments are the octal constant 214B, the semantic routine call AREG1(1,13), and A, which is the object on top of the stack at the moment this production is invoked. DEWOP is a semantic routine which respectively takes as its arguments a PDP-10 machine language opcode, a register object, and any other object, and produces an object whose value is the result of executing the designated machine instruction using as address field the object which is its last argument. In this specific example, the opcode 214B designates the Load Magnitude instruction, and thus the result of the above syntax statement will be to compile code to compute the absolute value of A.

References

  • Syntax Extension and the IMP72 Programming Language, Walter Bilofsky, Yale University, SIGPLAN Notices, May 1974.