Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap2_198111 - decus/20-0028/syntax.sno
There are 2 other files named syntax.sno in the archive. Click here to see a list.
* This program is a syntatic recognizer for snobol4
* statements. The syntax used is for Version 3 with
* the PDP-10 graphics.
*
* L.P. Wade at TYMSHARE 5-9-70

* A series of patterns is built, culminating
* a pattern that matches SNOBOL4 statements.


* Card images are then read in and processed.

	DEFINE('opt(pattern)')

	OPSYN('^','opt',1)
	OPSYN('%','SPAN',1)
	OPSYN('@','ANY',1)
	leftbr _ @'<['
	rightbr _ @'>]'
	lower _ 'abcdefghijklmnopqrstuvwxyz'
	UPPER _ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	letters _ UPPER lower
	digits _ '0123456789'
	alphanumerics _ letters digits
	blanks _ %'	 '
	integer _ %digits
	real _ integer '.' ^integer
	identifier _ @letters ^%(alphanumerics '.')
	opsyms _ '+-/*$%#@^\!'
	unary _ @opsyms
	binary _ unary ! '**'
	binaryop _ blanks ^(binary blanks)
	unqalpha _ &ALPHABET
	unqalpha '"' _
	unqalpha "'" _
	dliteral _ '"' ^%(unqalpha "'") '"'
	sliteral _ "'" ^%(unqalpha '"') "'"
	literal _ sliteral ! dliteral ! integer ! real
	element _ ^unary (identifier ! literal ! *function.call
+	! '(' *expression ')' ! *array.ref)
	operation _ *element binaryop (*element
+	! *expression)
	expression _ ^blanks (*element ! *operation
+	! null) ^blanks
	arglist _ *expression ^(',' *arglist)
	function.call _ identifier '(' *arglist ')'
	array.ref _ identifier leftbr *arglist rightbr
	label _ @alphanumerics (BREAK(' ;')
+	! REM)
	label.field _ ^label
	goto _ '(' expression ')' ! leftbr expression
+	rightbr
	goto.field _  ^(blanks ':'
+	FENCE ^blanks (goto ! 'S' goto
+	! 'F' goto ! 'S' goto ^blanks 'F'
+	 goto ! 'F' goto ^blanks 'S' goto)
+	^blanks)
	eql _ @'=_'
	rule _ ^(blanks element (blanks eql ^(blanks
+	 expression) ! ^(blanks expression ^(blanks eql
+	^(blanks expression)) )))
	eos _ RPOS(0) ! ';'
	statement _ label.field rule goto.field eos


* The recognizing program follows. Comment and continue
* cards are not processed. If an erroneous statement
* is encountered in a string of statemtns separated by
* semicolons, subsequent statements in that string are
* not processed.
*

	INPUT(.input,5,72)
	&ANCHOR _ 1
	&TRIM _ 1
	&FULLSCAN _ 1
	eof _
	space _ DUPL(' ',5)
	line _
	comment _ @'*-'
	continue _ @'+.' . cc
readi	image _ input	:F(END)
	OUTPUT _ space line
	image comment		:F(readc)S(readi)
nextst	IDENT(eof)		:F(END)
	OUTPUT _ space line
	image _ line
readc	line _ input	:F(endgam)
	line comment		:S(print)
	line continue _ 	:F(anlyz)
	OUTPUT _ space cc line
	image _ image line	:(readc)
anlyz	image statement _ 	:F(error)
	DIFFER(image)	:S(anlyz)F(nextst)
error	OUTPUT _ '<<< syntatic error >>>'	:(nextst)
print	OUTPUT _ space line	:(readc)
endgam	eof _ 1	:(anlyz)

*
opt	opt _ null ! pattern	:(RETURN)
END
    
	X  Y+Z
	ELEMENT<I,J>_ ELEMENT<I,-J> + ELEMENT<-I,J>
	A<X,Y,Z + 1> _ F(X,STRUCTURE.BUILD(TYPE,LENGHT + 1))
SETUP	PAT1 _ (BREAK(',:') $ FIRST ! SPAN(' .) $ SECOND
.	. VALUE ARBNO(BAL ! LEN(1)) :($SWITCH)
	DEFINE('F(X,Y))
	L _ LT(N,B<J> L + 1
NEWONE.TRIAL	X _ \COORD<1,K> X * X
	TRIM(INPUT) PAT1 :S(OK) :F(BAD)
	X _ 3.01; Y = 2.   ; Z = X * -Y
	RANDOM _ (RAN.VAR * N) / 10000
	OUTPUT = ''
	F('',"",)	=
	F('',"",) = "'