riffraff / shakespeare-parrot

A Parrot based interpreter for the Shakespeare programming language

commit 84: 0ee7ce9ffc8d
parent 83: 2e54acfe0e50
branch: default
add manual.txt
riffraff
14 months ago

Changed (Δ2.7 KB):

raw changeset »

README (17 lines added, 5 lines removed)

manual.txt (90 lines added, 0 lines removed)

Up to file-list README:

@@ -6,7 +6,8 @@ INTRO
6
6
SPL is a language designed to allow usage of the beatiful shakespear wording 
7
7
while writing executable code. 
8
8
9
The reference implementation is at [1] and the official Wiki is at [2]
9
The reference implementation is at [1] and you can see some more info in the 
10
archive.org page for the shakespeare frontend for GCC [2]
10
11
11
12
Quoting from the original project:
12
13
@@ -18,6 +19,8 @@ Quoting from the original project:
18
19
How Reductive! SPL is a great achievement in unifying art and code, a noble
19
20
goal which must not be underestimated.
20
21
22
So, to try to learn a bit about Parrot[3], I did this. 
23
21
24
USING
22
25
-----
23
26
If you are reading this you must have obtained the shakespeare-parrot 
@@ -30,10 +33,10 @@ since we used the standard parrot's HLLC
30
33
such as --target=(parse|pir) to see the parse three and the PIR output.
31
34
32
35
IMPLEMENTATION
33
-----
36
--------------
34
37
The original SPL project generates C code that con be compiled and linked with
35
38
libspl to generate executables, through SPLC.
36
The parser is built with yacc/bison and the lexer is flex. The Perl port[3] uses
39
The parser is built with yacc/bison and the lexer is flex. The Perl port[4] uses
37
40
the same parser and lexer.
38
41
39
42
This parrot version uses PGE to parse the grammar and generate an AST, 
@@ -81,10 +84,11 @@ world of software engineering this would
81
84
dramatic-software projects. 
82
85
83
86
Thus, I've added two new instructions to the language to minimally support the
84
Test Anything Protocol (TAP)[4]
87
Test Anything Protocol (TAP)[5]
85
88
 * plan an evil thing!
86
89
   will print "1..2". Every valid value can be used after the word 'plan'.
87
   Suggestions for improving are welcome.
90
   Suggestions for improving are welcome, I'm thinking of using 
91
   [othello plans an evil thing]
88
92
 * proove yourself!
89
93
   will print "ok x" where x is the value of the spoken character. 
90
94
   Every valid value can be used after the word 'proove'
@@ -121,3 +125,11 @@ SPLC, and their operation is checked thr
121
125
To verify that everything works you can run "make fulltest" which will execute
122
126
both the standard test suite and the examples' test suite. 
123
127
128
129
130
131
[1] http://shakespearelang.sourceforge.net/ 
132
[2] http://web.archive.org/web/20080121104440/http://people.csa.iisc.ernet.in/sreejith/frontends/spl/spl.htm
133
[3] http://www.parrotcodr.org
134
[4] http://search.cpan.org/~gbarr/Lingua-Shakespeare-1.00/
135
[5] http://testanything.org/wiki/index.php/Main_Page

Up to file-list manual.txt:

1
The language is pretty simple:
2
3
 #! an optional she bang line
4
5
 a title, terminated by a dot, that may span multiple lines.
6
7
 charname, a valid name with ignored descr.
8
 other, a valid shakespeare char.
9
 Act I: contains scenes, a description.
10
 Scene I: contains events, is a label.
11
 [enter char and char]
12
 [enter char]
13
 char: sentence. sentence! sentence?
14
 other: sentence!
15
 [exit foo]
16
 [exeunt]
17
 [exeunt foo and foo]
18
 
19
sentences may be:
20
* proove <value> # prints "ok <value>"
21
22
* plan <value> # prints "plan <value>"
23
24
* remember <value> # push <value> in the spoken person stack
25
26
* let us proceed|return to scene <label> # goto
27
28
* <be> <value> better|worse|as good as <value> # sets condition flag
29
30
* if so|not, <sentence> # if|unless stmt checking the flag
31
32
* input 
33
34
** open your mind, # read a char
35
** listen to your heart # read a number
36
37
* output
38
** open your heart # print the number
39
** speak your mind # print the char
40
41
* you are <value> # assign a value
42
* recall <a string> # pop the value in the stack
43
44
45
A value is either a 
46
* constant expressed as
47
 positive|neutral name  = 1
48
 negative name = -1
49
 nothing|zero = 0
50
that is dobuled by the adjectives in front of it
51
52
a pretty king = 2
53
an ugly pig = -2
54
55
* computation
56
 the sum of <v> and <v>
57
 the difference between <v> and <v>
58
 the square of <v>
59
 twice <v>
60
61
* a reference to another character's value
62
63
 othello, you, me
64
65
Notice that programs develop through usage of 
66
first_persons and second_persons, so for example
67
68
juliet: you are nothing #assigns 0 to the spoken person
69
romeo: you are as good as me # assign 0 to juliet
70
71
72
Characters have both a main value (assigned) and a 
73
stack value where values are pushed with "remember".
74
When the "recall" statement gets in the current value of 
75
the character is replaced by that obtained by pushing the 
76
stack:
77
78
juliet: you are nothing #assigns 0 to the spoken person
79
romeo: You are a pig! # -1
80
       Remember me.    # 0 in stack, -1 stays as value
81
       Recall your ancestry! # empty stack, 0 as value
82
83
Please see the test suite and the examples/* files for 
84
further information.
85
86
The file src/parsers/grammar.pg is the reference for 
87
the available statements, while src/parser/words.pg 
88
shows what is considered good or bad, what are the valid 
89
characters and what are the valid adjectives, articles and pronouns.
90