Skip to content

Instantly share code, notes, and snippets.

@krodelin krodelin/ops5-syntax.md
Last active Jul 30, 2016

Embed
What would you like to do?

Syntax of OPS5

The following is a simplified BNF description of the syntax of OPS5. Terminals are printed in a Roman type face, and non-terminals are printed in italics. The only nonstandard meta symbol used is the star (*). The star indicates that the preceding item is to be repeated zero or more times.

production				::=		( p constant-symbolic atom Ihs --> rhs )

lhs						::=		positive-ce ce*

ce						::=		positive-ce
						::=		negative-ce
			
positive-ce				::=		form
						::=		{ element-variable form }
						::=		{ form element-variable }

negative-ce				::=		- form

form					::=		( lhs-term* )

lhs-term				::=		^ constant-symbolic-atom Ihs-value
						::=		^ number Ihs-value
						::=		lhs-value

lhs-value				::=		{ restriction* }
						::=		restriction

restriction 			::=		<< any-atom* >>
						::=		predicate atomic-value
						::= 	atomic-value

atomic-value			::=		// any-atom
						::=		var-or-constant	

var-or-constant			::=		constant-symbolic-atom
						::=		number
						::=		variable

predicate				::=		=
						::=		<>
						::=		<
						::=		<=
						::=		>=
						::=		>
						::=		<=>

rhs						::=		action*

action					::=		( make rhs-term* )
						::=		( remove element-designator* )
						::=		( modify element-designator rhs-term*)
						::=		( halt )
						::=		( bind variable )
						::=		( bind variable rhs-term* )
						::=		( cbind element-variable )
						::=		( call constant-symbolic-atom rhs-term* )
						::=		( write rhs-tenn* )
						::=		( openfile rhs-term* )
						::=		( closefile rhs-term* )
						::=		( default rhs-term* )
						::=		( build quoted-form* )

element-designator		::=		number
						::=		element-variable

rhs-term				::=		^ var-or-constant rhs-value
						::=		rhs-value

rhs-value				::=		atomic-value
						::=		function

function				::=		( litval var-or-constant )
						::=		( substr element-designator var-or-constant var-or-constant )
						::=		( genatom )
						::=		( crlf )
						::=		( rjust var-or-constant )
						::=		( tabto var-or-constant )
						::=		( accept )
						::=		( accept var-or-constant )
						::=		( acceptline var-or-constant* )
						::=		( compute expression )
						::=		user-defined-function

user-defined-function	::=		( constant-symbolic-atom var-or-constant* )

expression				::=		number
						::=		variable
						::=		expression operator expression
						::=		( expression )

operator							::=		+
						::=		-
						::=		*
						::=		//
						::=		\\

quoted-form				::=		\\ rhs-value
						::=		any-atom
						::=		( quoted-form* )

Several terms have been left undefined: variable, element-variable, constant-symbolic-atom, any-atom, and number. Symbolic atoms and numbers are described in Section 2. The two kinds of variables are described in Sections 4 and 5. The only thing that needs to be explained here is the difference between any-atom and constant-symbolic-atom. The former is an atom that is treated as a constant because it is quoted (with // or << >> usually). The latter is an atom that is. treated as a constant because it does not have the form of a variable or operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.