Skip to content

Commit 24fa13e

Browse files
committed
Refactoring & documentation
1 parent 9d32eb4 commit 24fa13e

File tree

13 files changed

+216
-474
lines changed

13 files changed

+216
-474
lines changed

ecr/domain/core/core-keywords.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef CORE_KEYWORDS_H
2+
#define CORE_KEYWORDS_H
3+
4+
char* keywords[] = {
5+
"add",
6+
"append",
7+
"array",
8+
"begin",
9+
"clear",
10+
"close",
11+
"debug",
12+
"decrement",
13+
"delete",
14+
"divide",
15+
"dummy",
16+
"end",
17+
"exit",
18+
"file",
19+
"fork",
20+
"get",
21+
"gosub",
22+
"go",
23+
"goto",
24+
"gotoPC",
25+
"if",
26+
"increment",
27+
"index",
28+
"input",
29+
"init",
30+
"multiply",
31+
"object",
32+
"open",
33+
"pop",
34+
"post",
35+
"print",
36+
"push",
37+
"put",
38+
"read",
39+
"replace",
40+
"return",
41+
"script",
42+
"set",
43+
"split",
44+
"stack",
45+
"stop",
46+
"system",
47+
"take",
48+
"toggle",
49+
"variable",
50+
"wait",
51+
"while",
52+
"write"
53+
};
54+
55+
#endif

ecr/test.code

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
0:1,2:3,#4,4:5,6:7,8:9,10:11,12:13,14:15,16:[,18,],19:9
2-
0:1,2:3,#5,4:5,6:7,8:9,10:20,12:13,14:15,16:[,18,],19:9
3-
0:21,2:3,#7,4:18,6:9,16:{,2:3,4:22,23:{,4:24,23:25,},},26:20
4-
0:21,2:3,#8,4:18,6:9,16:{,2:3,4:22,23:{,4:24,23:27,},},26:11
5-
0:21,2:3,#9,4:18,6:9,16:{,4:24,23:28,},26:11
6-
0:29,2:3,#10,4:18,6:9,16:{,2:3,10:11,4:5,},30:20
7-
0:31,2:3,#11,4:18,6:9,16:{,4:32,33:7,34:[,17:{,4:24,23:35,},17:{,2:3,10:11,4:5,},],}
8-
0:21,2:3,#12,4:18,6:9,16:{,4:24,23:36,},26:11
9-
0:31,2:3,#13,4:18,6:9,16:{,4:32,33:7,34:[,17:{,4:24,23:37,},17:{,2:3,10:11,4:5,},],}
10-
0:38,2:3,#14,4:18,6:9,26:11,39:20
11-
0:31,2:3,#15,4:18,6:9,16:{,4:32,33:7,34:[,17:{,4:24,23:40,},17:{,2:3,10:11,4:5,},],}
12-
0:41,2:3,#16,4:18,6:9
1+
0:1,2:3,#2,4:5,6:7,8:{,4:9,10:11,}
2+
0:12,2:3,#3,4:5,6:7
133

ecr/test.ecs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
! Test script
22

3-
script Test
4-
5-
variable V
6-
variable Stack
7-
8-
put json `[]` into Stack
9-
put json `{}` into V
10-
put `Hello, world!` into V
11-
push V to Stack
12-
print `Pushed ` cat V
13-
put `Goodbye` into V
14-
print `V: ` cat V
15-
pop V from Stack
16-
print `Popped ` cat V
17-
exit
3+
print `Hello, world!`
4+
exit

ecr/test.json

Lines changed: 3 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,20 @@
11
[
2-
{
3-
"debug": false,
4-
"domain": "core",
5-
"elements": 1,
6-
"index": 0,
7-
"keyword": "variable",
8-
"lino": 4,
9-
"name": "V",
10-
"type": "symbol",
11-
"used": true,
12-
"value": [
13-
null
14-
],
15-
"valueHolder": true
16-
},
17-
{
18-
"debug": false,
19-
"domain": "core",
20-
"elements": 1,
21-
"index": 0,
22-
"keyword": "variable",
23-
"lino": 5,
24-
"name": "Stack",
25-
"type": "symbol",
26-
"used": true,
27-
"value": [
28-
null
29-
],
30-
"valueHolder": true
31-
},
32-
{
33-
"debug": true,
34-
"domain": "core",
35-
"keyword": "put",
36-
"lino": 7,
37-
"target": "Stack",
38-
"type": null,
39-
"value": {
40-
"content": {
41-
"content": "[]",
42-
"type": "text"
43-
},
44-
"domain": "core",
45-
"type": "json"
46-
}
47-
},
48-
{
49-
"debug": true,
50-
"domain": "core",
51-
"keyword": "put",
52-
"lino": 8,
53-
"target": "V",
54-
"type": null,
55-
"value": {
56-
"content": {
57-
"content": "{}",
58-
"type": "text"
59-
},
60-
"domain": "core",
61-
"type": "json"
62-
}
63-
},
64-
{
65-
"debug": true,
66-
"domain": "core",
67-
"keyword": "put",
68-
"lino": 9,
69-
"target": "V",
70-
"type": null,
71-
"value": {
72-
"content": "Hello, world!",
73-
"type": "text"
74-
}
75-
},
76-
{
77-
"debug": true,
78-
"domain": "core",
79-
"keyword": "push",
80-
"lino": 10,
81-
"to": "Stack",
82-
"type": null,
83-
"value": {
84-
"domain": "core",
85-
"name": "V",
86-
"type": "symbol"
87-
}
88-
},
892
{
903
"debug": true,
914
"domain": "core",
925
"keyword": "print",
93-
"lino": 11,
94-
"type": null,
95-
"value": {
96-
"numeric": false,
97-
"parts": [
98-
{
99-
"content": "Pushed ",
100-
"type": "text"
101-
},
102-
{
103-
"domain": "core",
104-
"name": "V",
105-
"type": "symbol"
106-
}
107-
],
108-
"type": "cat"
109-
}
110-
},
111-
{
112-
"debug": true,
113-
"domain": "core",
114-
"keyword": "put",
115-
"lino": 12,
116-
"target": "V",
6+
"lino": 2,
1177
"type": null,
1188
"value": {
119-
"content": "Goodbye",
9+
"content": "Hello, world!",
12010
"type": "text"
12111
}
12212
},
123-
{
124-
"debug": true,
125-
"domain": "core",
126-
"keyword": "print",
127-
"lino": 13,
128-
"type": null,
129-
"value": {
130-
"numeric": false,
131-
"parts": [
132-
{
133-
"content": "V: ",
134-
"type": "text"
135-
},
136-
{
137-
"domain": "core",
138-
"name": "V",
139-
"type": "symbol"
140-
}
141-
],
142-
"type": "cat"
143-
}
144-
},
145-
{
146-
"debug": true,
147-
"domain": "core",
148-
"from": "Stack",
149-
"keyword": "pop",
150-
"lino": 14,
151-
"target": "V",
152-
"type": null
153-
},
154-
{
155-
"debug": true,
156-
"domain": "core",
157-
"keyword": "print",
158-
"lino": 15,
159-
"type": null,
160-
"value": {
161-
"numeric": false,
162-
"parts": [
163-
{
164-
"content": "Popped ",
165-
"type": "text"
166-
},
167-
{
168-
"domain": "core",
169-
"name": "V",
170-
"type": "symbol"
171-
}
172-
],
173-
"type": "cat"
174-
}
175-
},
17613
{
17714
"debug": true,
17815
"domain": "core",
17916
"keyword": "exit",
180-
"lino": 16,
17+
"lino": 3,
18118
"type": null
18219
}
18320
]

ecr/test.keys

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,13 @@
11
keyword
2-
variable
2+
print
33
domain
44
core
55
type
6-
symbol
6+
None
77
debug
8-
False
9-
valueHolder
108
True
11-
name
12-
V
13-
elements
14-
1
15-
index
16-
0
179
value
18-
None
19-
None
20-
used
21-
Stack
22-
put
23-
json
24-
content
2510
text
26-
[]
27-
target
28-
{}
11+
content
2912
Hello, world!
30-
push
31-
to
32-
print
33-
cat
34-
numeric
35-
parts
36-
Pushed
37-
Goodbye
38-
V:
39-
pop
40-
from
41-
Popped
4213
exit

ecr/test2.ecs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! Test script
2+
3+
script Test
4+
5+
variable V
6+
stack Stack
7+
object Object
8+
9+
debug step
10+
11+
init Stack
12+
init Object
13+
push `Here we go!` to Stack
14+
put `Hello, world!` into V
15+
push V to Stack
16+
print `Pushed ` cat V
17+
put `Goodbye` into V
18+
print `V: ` cat V
19+
pop V from Stack
20+
print `Popped ` cat V
21+
pop V from Stack
22+
print `Popped ` cat V
23+
exit

py/ec/ec_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def getSymbolRecord(self):
116116
def compileLabel(self, command):
117117
return self.compileSymbol(command, self.getToken(), False)
118118

119-
def compileVariable(self, command, valueHolder=False):
119+
def compileVariable(self, command, valueHolder = False):
120120
return self.compileSymbol(command, self.nextToken(), valueHolder)
121121

122122
def compileSymbol(self, command, name, valueHolder):

0 commit comments

Comments
 (0)