Difference between revisions of "The Script Programming Language"

From SCI Wiki
Jump to navigationJump to search
Line 24: Line 24:
  
 
 
 
 
−
 
−
==<br /> Introduction ==
 
−
 
−
The Script adventure game language is an object-oriented language with a Lisp-like syntax. It is compiled by the sc compiler into the pseudo-code which is used by the interpreter, sci.
 
−
 
−
We will begin our discussion of the language with its basic Lisp-like characteristics, then go on to the object-oriented parts of the language.
 
−
 
−
As is Lisp, Script is based on parenthesized expressions which return values. An expression is of the form
 
−
 
−
<blockquote>
 
−
<div class="CodeBlockHeader">Code:</div>
 
−
<syntaxhighlight lang="sci">
 
−
(procedure [parameter parameter ...]).
 
−
</syntaxhighlight>
 
−
</blockquote>
 
−
 
−
The parameters to a procedure may themselves be expressions to be evaluated, and may be nested until you lose track of the parentheses.
 
−
 
−
Unlike Lisp, the procedure itself may NOT be the result of an evaluation. An example of an expression is
 
−
 
−
<blockquote>
 
−
<div class="CodeBlockHeader">Code:</div>
 
−
<syntaxhighlight lang="sci">
 
−
(+ (- y 2) (/ x 3))
 
−
</syntaxhighlight>
 
−
</blockquote>
 
−
 
−
which would be written in infix notation as
 
−
 
−
<blockquote>
 
−
<div class="CodeBlockHeader">Code:</div>
 
−
<syntaxhighlight lang="sci">
 
−
      (y - 2) + (x / 3).
 
−
</syntaxhighlight>
 
−
</blockquote>
 
−
 
−
All expressions are guaranteed to be evaluated from left to right. Thus,
 
−
 
−
<blockquote>
 
−
<div class="CodeBlockHeader">Code:</div>
 
−
<syntaxhighlight lang="sci">
 
−
(= x 4)
 
−
(= y (/ (+= x 4) (/= x 2)))
 
−
</syntaxhighlight>
 
−
</blockquote>
 
−
 
−
will result in y = 2 and x = 4.
 
−
 
−
Comments in Script begin with a semi-colon, ';', and continue to the end of the line.
 
  
 
;Notes
 
;Notes

Revision as of 17:48, 29 November 2015