perm filename SYNTAX.DOC[SIM,SYS] blob sn#460316 filedate 1979-07-20 generic text, type T, neo UTF8


II.4.5		IC1  Intermediate code from pass 1.
		----------------------------------

FILE:	nnnIC1.TMP

PURPOSE:	The intermediate code file IC1 contains information
	about executable constructions in the source text.

OPEN:	The file will stay in core if it not exceeds 5 disk
OUTPUT:	buffers in size. When this limit is reached, O1IC1
	is called and a file is opened on channel QCHIC1
	in buffered binary mode (.IOBIN) at O1OPIC.
CLOSE:	The file is closed in O1ICCL called from T1.

REOPEN:	A LOOKUP on the file is performed in O2OP if the
	file not already resides in core.
INPUT:	O2IS is called to read a symbol and O2IV to read a 
	constant value.
DELETE:	The file is deleted in O2EX.

RECORD LAYOUT:	IC1 is, with a few exceptions, a reverse
	Polish string in which the elements are symbols represented
	in the syntax description below by upper case letters.
	For example PLUS is the symbol for the binary operator + .
	Some symbols are followed by parameters (e.g. CONR(v1)(v2)
	represents a real constant whose value is the actual
	parameters that follows in the next two halfwords). Each
	symbol and parameter occupy one halfword.

	In the description the special symbol ID is used as a 
	generic symbol representing an identifier. Each
	differently spelt identifier is allocated a number by the
	Lexical scanner which is equivalent to its index in the
	symbol table. This lexical identifier number is used in
	the intermediate files to specify the identifiers. Strictly
	there should be a symbol ID(identifier) but in practice 
	there is no single ID symbol. The identifier appears 
	alone acting as both symbol and parameter.
	This is possible because the lexical identifier number
	occupy a range disjoint from the range of all oter
	symbol values (i.e. 1025-4095).


SYNTAX DESCRIPTION:

;		The first characters of lines have the following
;		meaning:
;	;	comment line
;	I	syntax production for IC1
;	D	syntax for corresponding construct in DF1
;	F	follows a line tagged with I and shows fixup
;		locations for a construction
;		The second character of a line could be a + sign.
;	 +	Then the line is a continuation of the last line
;		with the same first character and this line should
;		be ended with a + sign.



;Program:

I<program>::=		BPROG <class declaration> EPROG |
D							ZHE
I			BPROG <procedure declaration> EPROG |
D							   ZHE
I			BPROG <statements> EPROG
D						ZHE

;Declarations:

I<declare>::=		|
I			<declaration> <declare>

I<declaration>::=	<array declaration> |
I			<procedure declaration> |
I			<class declaration> |
I			<switch declaration> |
I			<line> |
I			ERROR |
I			PURGE
I			DEBUG (cp)
;
; ERROR may occur anywhere in a declaration or statement where
; a symbol may otherwise occur, and does not affect the syntax of
; remaining symbols.
; PURGE may occur anywhere where ERROR might otherwise occur but
; this symbol terminates the currently innermost statement
; (i.e. symbols that could otherwise have followed are suppressed).
; DEBUG is used to control compiler testing and is allowed always
; where a symbol can occur. The (cp) halfword following is the
; component name (two sixbit characters) and an action code in the
; remaining bits.




I<class declaration>::=	ID BEGCL <declare> EDCL <statements> +
F				f+2	       f+3

I+			 <classend>

; The fixup number is obtained from ZHEFIX in the ZHB record
; for the class

I<classend>::=		INNER <statements> ENDCL |
F			     f+4		f+5
I			IENDC
F			f+4 f+5

I<procedure declaration>::=ID BEGPR <declare> <statements> ENDPR
F				   f+2			     f+3
D				ZHE
; The fixup number above is obtained from the ZQU entry of the
; procedure in pass 2

I<array declaration>::=	<bounds> ADEC |
I			ID <array declaration>

I<bounds>::=		<expression> <expression> BOUND |
I			<bounds> <bounds>

I<switch declaration>::=ID SWITCH <swlist>SWEND
F					       f+1

I<swlist>::=		|
I			<expression> SWEL <swlist>

I<line>::=		LINE (sc) (li)
; LINE is a generic symbol consisting of the current line number
; and with the high order bit set. The literals following are a
; semicolon count and the last line number.
; Last line number <= current line number.


;Statements:

I<statements>::=	|
I			<statement> <statements>

I<statement>::=		<line> |
I			ERROR |
I			PURGE |
I			DEBUG (cp)
I			<conditional> |
I			<assignment statement> |
I			<denotes statement> |
I			<goto statement> |
I			<if-goto> |
I			<activation> |
I			<for statement> |
I			<while statement> |
I			<connection> |
I			<prefixed block> |
I			<block> |
I			<label definition> |
I			<procedure call>

I<conditional>::=	<expression> IFST (f) <statements> FIX (f) |
F								f
I			<expression> IFST (f) <statements> JUMP (g) +

I+			 FIX (f) <statements> FIX (g)
F			      f			   g

I<assignment statement>::=<expression> <expression> BECOM |
I			<expression> <assignment statement>

I<denotes statement>::=	<expression> <expression> DENOT |
I			<expression> <denotes statement>

I<goto statement>::=	<expression> GOTO
I<if-goto>::=		<expression> <expression> IFTRU |
I			<expression> <expression> IFTRE (g) +

I+			 <statements> FIX (g)


I<activation>::=	<expression> <expression> ACTIV (code) |
I			<expression> ACTIV (code)
; The code following ACTIV is a bit mask
; describing the activation clause:
;	bit	meaning
;	17	reactivate
;	16	before
;	15	after
;	14	at
;	13	delay
;	12	prior

I<for statement>::=	<controlled variable> <for list> FORDO	+
F	   						   f	+

I+			 <statement> ENDFO
F+				      f+1

; The fixup number is obtained from the ZHE entry of the for statement

I<controlled variable>::=ID CVBE |
D			   ZHE
I			ID CVDE
D			   ZHE

I<for list>::=		<for list element> |
I			<for list> <for list element>

I<for list element>::=	<expression>  FORSI |
I			<expression> <expression>  FORWH |
I			<expression> <expression> <expression> FORST

I<while statement>::=	<expression> WHILE (f)<statements> JUMP (f) +
F			f					    +

I+			 FIX (f+1)
F+			      f+1

I<connection>::=	<expression> INSPE (f) <dolist> <otherw>

I<dolist>::=		DO <statements> ENDDO |
D			ZHB
I			<whendo>

I<whendo>::=		|
I			<whendo> ID WHEDO <statements> ENDDO
F							f+2
D					ZHB


I<otherw>::=		OTHER <statement> FIX (f+3) |
F			f		       f+3
I			NOTHR
F			f  f+3

I<prefixed block>::=	<reference> BEGPB <declare> EDPB	+
F					f+2	       f+3	+
D				     ZHB

I+			 <statements> PBEND
F+					  f+4
; The fixups for prefixed blocks are obtained
; from the ZHB entry of the block

I<block>::=		BBLK <declare> <statements> EBLK
D			ZHE

I<label definition>::=	FIX (f)
F			  f

I<procedure call>::=	<expression> <line>



;Expressions:

I<expression>::=	<simple> |
I			<expression> <unop> |
I			<expression> <expression> <binop> |
I			<expression> <expression> <expression> IFEX

I<simple>::=		<constant> |
I			<reference>

I<unop>::=		PAREN |
I			UMIN |
I			UPLUS |
I			NOT |
I			THIS |
I			NEW |
I			DELOP
; DELOP is used for error recovery


I<binop>::=		PLUS |
I			MINUS |
I			DIV |
I			MULT |
I			IDIV |
I			POW
I			LESS |
I			NLESS 
I			GRT |
I			NGRT |
I			EQ |
I			NEQ |
I			DEQ |
I			NDEQ |
I			IS |
I			IN |
I			QUA |
I			AND |
I			OR |
I			IMP |
I			EQV


I<reference>::=		<id1> |
I			<id1> <alist>

I<id1>::=		ID |
I			<expression> ID DOT

I<alist>::=		LB  <tail> |
I			LP  <tail>

I<tail>::=		RP |
I			<expression> <tail>

I<constant>::=		TRUE |
I			FALSE |
I			NONE |
I			NOTEXT |
I			CONC (v1) |
I			CONI (v1) (v2) |
I			CONR (v1) (v2) |
I			CONLR (v1) (v2) (v3) (v4) |
I			CONT (ra) (le) |
I			UDEF
; The text constant is of length le and starts
; at ra from the programbreak at run time
; UDEF is used for error recovery