Content deleted Content added
Jerryobject (talk | contribs) WP:LINKs: updates, adds, fix-cut needless WP:PIPEs (WP:NOPIPEs). Small WP:EoS WP:TERSE WP:COPYEDITs: clarify. MOS:FIRSTABBReviations define before WP:ABBRs. Nonlead-word nonproper noun MOS:CAPS MOS:HEADings-MOS:HEADCAPS, nonacronym proper noun WP:ALLCAPS > sentence case. Plain text list > WP:CITation Template:Cite journals, parameters: add, fill. WP:NAVBOX add. |
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags |
||
Line 41:
Basically, the syntax statement is an augmented BNF production with associated [[Semantics (computer science)|semantics]] added on the right:
<
<class> ::= syntax-part ::= semantic-part
</syntaxhighlight>
For example, to add the construct described by the following BNF:
<
<EXP> ::= INCREMENT <VBL>
</syntaxhighlight>
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'':
<
<EXP> ::= INCREMENT <VBL,A> ::= "A←A+1"
</syntaxhighlight>
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)
</syntaxhighlight>
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 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>.
|