Difference between revisions of "SCI Parser Programmer's Reference/Introduction"

From SCI Wiki
Jump to navigationJump to search
(Created page with "Official SCI Documentation<br /> Official SCI Documentation<br /> <div align="center"> Chapter: 1 | SCI Parser...")
 
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Official SCI Documentation]]<br />
 
 
 
[[Official SCI Documentation]]<br />
 
[[Official SCI Documentation]]<br />
  
Line 8: Line 6:
 
[[SCI Parser Programmer's Reference/User Parse Trees|2]] |  
 
[[SCI Parser Programmer's Reference/User Parse Trees|2]] |  
 
[[SCI Parser Programmer's Reference/Said Specs|3]] |  
 
[[SCI Parser Programmer's Reference/Said Specs|3]] |  
[[SCI Parser Programmer's Reference/Syntax|4]] |  
+
[[SCI Parser Programmer's Reference/Said Syntax|4]] |  
[[SCI Parser Programmer's Reference/Spec Trees|5]] |  
+
[[SCI Parser Programmer's Reference/Said Spec Trees|5]] |  
 
[[SCI Parser Programmer's Reference/Tree Matching|6]] |  
 
[[SCI Parser Programmer's Reference/Tree Matching|6]] |  
 
[[SCI Parser Programmer's Reference/Examples|7]] |  
 
[[SCI Parser Programmer's Reference/Examples|7]] |  
Line 15: Line 13:
 
</div><br />
 
</div><br />
  
<div align="center"><span style="font-size: 22pt">SCI Parser Programmer's Reference</span><br />
+
<div align="center"><span style="font-size: 22pt">Introduction</span><br />
 
''Author: [[Pablo Ghenis]]''<br />
 
''Author: [[Pablo Ghenis]]''<br />
 
''Date: 21 July 1988 9:56:56 am''</div>
 
''Date: 21 July 1988 9:56:56 am''</div>
Line 21: Line 19:
 
&nbsp;
 
&nbsp;
  
-- content here --
+
==<br /> Introduction ==
 +
 
 +
===<br /> Purpose ===
 +
 
 +
The parser is the part of SCI that accepts sentences from the user and allows game coders to specify  how to respond to it. For example "get the diamond" is an acceptable sentence for a user to type, and the coder can recognize it with a "spec" such as 'get/diamond', which is followed by SCI code to be executed IF this sentences is entered.
 +
 
 +
There are three functional blocks in the parser: the sentence parser, the spec parser and the matcher. The sentence parser takes the words typed by the user and generates a "tree" that describes the sentence's structure using traditional grammar rules. The spec parser accepts "specs" and also generates tree structures. A special syntax is provided for specs since they are more versatile than simple sentences; for example one can SPECify alternative or optional words to be recognized. Finally, the matcher is the module that takes both trees and decides whether or not there is a match.
 +
 
 +
The following block diagram describes the parser:
 +
 
 +
<blockquote><blockquote>
 +
<pre>*********          ************
 +
* User  ************* Sentence *
 +
* input *      * *  * Parser  *
 +
*********      * *  ************
 +
              * *      *
 +
************  * *      *    ************
 +
* External ***** *      ****** Sentence *
 +
* Grammar  *    *            * Tree    *** ***********
 +
************    *            ************ * *        *
 +
                *                        *** Matcher *
 +
**************  *            ************ * *        *
 +
* External  *****            * Spec    *** ***********
 +
* Dictionary ****        ****** Tree    *
 +
**************  *        *    ************
 +
                *        *
 +
                *        *
 +
*********      *  ************
 +
* Coder ************* Spec    *
 +
* Specs *          * Parser  *
 +
*********          ************</pre>
 +
</blockquote></blockquote>
 +
 
 +
In the case of a common sentence, only a handful of comparisons may be required before a match is found. If the user were to type in something totally inappropriate, the resulting tree might be compared to fifty or even a hundred specs before falling through to a default answer like "what are you trying to say?".
 +
 
 +
===<br /> Parseable Sentences: ===
 +
 
 +
{|
 +
!width= "400" align= "left"|SENTENCE!!align= "left"|POSSIBLE MATCHING SPECS
 +
|-class="Mono"
 +
|"look"||'look[/!*]' or 'look'
 +
|-class="Mono"
 +
|"get the food"||'get/food' or 'get'
 +
|- class="Mono" valign= "top"
 +
|"hit the small tree"||'hit/tree<small'<br />'hit/tree[<small]<br />'hit[/tree[<small]]<br />'hit'
 +
|- class="Mono" valign= "top"
 +
|"hit the small green tree with the ax"||'hit/tree/ax'<br />'hit/tree<(green<small)/ax<with'
 +
|-class="Mono"
 +
|"burn it" = "burn tree" after last sentence||'burn/tree'
 +
|-class="Mono"
 +
|"when do fairies sleep?"||'(sleep<do<fairies)<when'
 +
|-class="Mono"
 +
|"what time is it?"||'is<what<time'
 +
|}
  
 
&nbsp;
 
&nbsp;
Line 34: Line 85:
 
&nbsp;
 
&nbsp;
  
<span style="float: left">[[The Script Programming Language |&lt; Previous: Table of Contents]]</span><span style="float: right">[[The Script Programming Language/Files|Next: Files &gt;]]</span>
+
<span style="float: left">[[SCI Parser Programmer's Reference |&lt; Previous: Table of Contents]]</span>
 +
<span style="float: right">[[SCI Parser Programmer's Reference/User Parse Trees|Next: User Parse Trees &gt;]]</span>
  
 
&nbsp;
 
&nbsp;
Line 40: Line 92:
 
[[Category:SCI Documentation]]
 
[[Category:SCI Documentation]]
 
[[Category:Scripting]]
 
[[Category:Scripting]]
 +
[[Category:The SCI Parser]]

Latest revision as of 02:26, 22 December 2015

Official SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | Index


Introduction

Author: Pablo Ghenis

Date: 21 July 1988 9:56:56 am

 


Introduction


Purpose

The parser is the part of SCI that accepts sentences from the user and allows game coders to specify how to respond to it. For example "get the diamond" is an acceptable sentence for a user to type, and the coder can recognize it with a "spec" such as 'get/diamond', which is followed by SCI code to be executed IF this sentences is entered.

There are three functional blocks in the parser: the sentence parser, the spec parser and the matcher. The sentence parser takes the words typed by the user and generates a "tree" that describes the sentence's structure using traditional grammar rules. The spec parser accepts "specs" and also generates tree structures. A special syntax is provided for specs since they are more versatile than simple sentences; for example one can SPECify alternative or optional words to be recognized. Finally, the matcher is the module that takes both trees and decides whether or not there is a match.

The following block diagram describes the parser:

*********           ************ 
* User  ************* Sentence * 
* input *      * *  * Parser   * 
*********      * *  ************ 
               * *       * 
************   * *       *    ************ 
* External ***** *       ****** Sentence * 
* Grammar  *     *            * Tree     *** *********** 
************     *            ************ * *         * 
                 *                         *** Matcher * 
**************   *            ************ * *         * 
* External   *****            * Spec     *** *********** 
* Dictionary ****        ****** Tree     * 
**************  *        *    ************ 
                *        * 
                *        * 
*********       *   ************ 
* Coder ************* Spec     * 
* Specs *           * Parser   * 
*********           ************

In the case of a common sentence, only a handful of comparisons may be required before a match is found. If the user were to type in something totally inappropriate, the resulting tree might be compared to fifty or even a hundred specs before falling through to a default answer like "what are you trying to say?".


Parseable Sentences:

SENTENCE POSSIBLE MATCHING SPECS
"look" 'look[/!*]' or 'look'
"get the food" 'get/food' or 'get'
"hit the small tree" 'hit/tree<small'
'hit/tree[<small]
'hit[/tree[<small]]
'hit'
"hit the small green tree with the ax" 'hit/tree/ax'
'hit/tree<(green<small)/ax<with'
"burn it" = "burn tree" after last sentence 'burn/tree'
"when do fairies sleep?" '(sleep<do<fairies)<when'
"what time is it?" 'is<what<time'

 

Notes


 

Table of Contents

 

< Previous: Table of Contents Next: User Parse Trees >