[View] [Edit] [Attachments] [History] [Home] [Changes] [Search] [Help]
Manual 2002 Sep
Install
If you just want to play LanguageGame, try Demonstration.
But you want to use in standalone Squeak, Please fill in the file
- Missing File (/ggame/uploads/GGame.st) - the body of LanguageGame
- Missing File (/ggame/uploads/GGame-User.st) - sample data
and doit
GLauncher new open
window
Missing File (/ggame/uploads/GGameWindow.png)
- grammar pane - input grammar with BNF notation
- This example shows that the sentence "Hello World" is mached "greeting". In technical term, a left hand symbol is called "non terminal symbol" and "terminal symbol" is never in left hand. The goal of LanguageGame is to match with all sentence to non terminal symbols and to match with the first non terminal symbol.
- sample pane - input sentence you want to parse
- You can input here sample sentence but also drop a target TextMorph or so.
context menu
Missing File (/ggame/uploads/WindowMenu.png)
- main menu
- swich grammar - change to use grammar
- new grammar - make a new grammar
- tile style - You can change style for graphical parsed tree.
- derivation -
- accept
Missing File (/ggame/uploads/Gtiles.png)
- tile style - result object after parse
- GTileNull - not shown but pop up 'OK' if it able to parse
- GTileSimple - symbol tiles line horizonaly
- GTileTree - Normal tree
- GTileText - editable text box
Let's play
Hello world
Language game has two pane, top pane is grammar pane described grammar and bottom pane is sample pane which you can write sample string. To play LanguaageGame is to make a grammar in grammar pane then put sample string fitted the grammar.
(Of course, you can first write sample string then next grammar)
Let's make a grammar to recognize 'Hello world'.
At first, put grammar pane as
greeting : Hello world
then accept this grammar (alt + s). It is maked as new grammar.
This grammar means 'Hello world' is as 'greeting'
Next, you should write a sample string
Hello world
in sample pane and push enter. The sample will be parsed and be shown syntax tree.
If you put another string like
Bye world
and parser reject and pop up red error tree.
Recursive Hello world
In this example
greeting : Hello
greeting : greeting world
matches 'Hello world', and in addition, the string
Hello world world world ... ('Hello' any numbers of 'world')
is matched. why?
In this example, definition of greeting uses a term of 'greeting' itself. Like this, the definition include itself is called 'recursive'. You can see the construction as tile tree easy.
Action
expr : expr inc [ :a :b | a + 1 ]
expr : number
In this example, a part enclosed in [] called 'action'.
This grammar meens the language which can add number '1'. You can put the sample pane like
10 inc inc
and then click 'expr' tile of generated tree. Now result 12 is popped up.
There is secret in 'a + 1' in action. In the fact, each word parsed as symbol (called 'node') has value, then you can see the value as click the tile. The value has rules bellow.
- If action is, node value is a result of block evaluted.
- If action is not, node value is node itself.
Additionary, :a is represented first symbol on right hand in the rule, and :b is represented second.
Moving morph
You can put the action any Smalltalk expression. And LanguageGame has blaata function, You can drop ScriptEditorMorph to grammar pane and put action like
[scripteditor1300 tryMe]
In this function, You can make a grammar to use any morphic object.
gg