Content deleted Content added
m Change Irons link. |
m →Extensible syntax in IMP72: <source lang="abnf"> |
||
Line 14:
Basically, the syntax statement is an augmented BNF production with associated semantics added on the right:
<source lang="abnf">
<class> ::= syntax-part ::= semantic-part
</source>
For example, to add the construct described by the following BNF:
<source lang="abnf">
<EXP> ::= INCREMENT <VBL>
</source>
with the semantics that <code>INCREMENT V</code> should translate to <code>V ← V + 1</code>, the programmer would only need to insert the following ''IMP statement'':
<source lang="abnf">
<EXP> ::= INCREMENT <VBL,A> ::= "
</source>
The semantic-part can also contain calls to ''semantic routines'', as in the following syntax statement:
<source lang="abnf">
<ATOM> ::= ABS ( <ATOM,A> ) ::= DEWOP(214B,AREG1(1,13),A)
</source>
The semantic part of this statement consists of a call on the semantic routine <code>DEWOP</code>. The arguments are the octal constant <code>214B</code>, the semantic routine call <code>AREG1(1,13)</code>, and <code>A</code>, which is the object on top of the stack at the moment this production is invoked. <code>DEWOP</code> 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 <code>214B</code> designates the <code>Load Magnitude</code> instruction, and thus the result of the above syntax statement will be to compile code to compute the absolute value of <code>A</code>.
|