-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.txt
122 lines (94 loc) · 2.02 KB
/
grammar.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
SEMICOLONS ARE NEEDED
Data Types
arrays - numpy array - [1, 2, 3]
lists - python lists - ("foo", "bar")
tuples - python tuples - {"foo", "bar"} // should not use
string - python string - "Hello world"
integer - python int - 12314235
float - python float - 1.23325123
booleans - python boolean - true false
Operators
Logical Operators
or - |
and - &
not - !
greater than - >
less than - <
equal to - ==
greater than or equal to - >=<
25
<
25
less than or equal to - <=
Math
addition - +
subtraction - -
multiplication - *
division - /
Variable Declarations
variable - Can't start with number - e.g. a_variable NOT 2123_x
declaration - variable = expression
If Else Statements
if (expression) {
something;
} else if (expression) {
something;
} else {
something;
}
Comments
// This is a Comment
Loops
while (condition) { // While loop
do something;
}
loop { // Forever loop
something;
if (something) {
break;
cont;
}
}
for (something in something) { // For loop
print(something)
break;
cont;
}
Functions
function call - this_is_a_function(arg1, arg2, optional_arg=op_arg)
function declaration - func function(arg1, arg2) {
something here;
--return-- = something;
}
Create custom rules to interpret to
`some_python_code_here e.g. print("Foo")`;
to use local variables, you must call self.object["name_of_variable"]
to use global variables, you must use global_objects["name_of_variable"]
Create classes
class file(filename) {
def --init--(this) {
this::filename = filename;
stuff;
}
def read(this, thing) {
stuff;
}
}
make class - file_obj = file(filename);
call method - file_obj::read()
Functions to be made
file(filename);
file::read();
file::write();
file::append();
Keyword Thing:
kword name_of_keyword(arg1) {
--GLOBAL-- = "global"
--parse-- = "GLOBAL arg1 ';'";
`global_objects[str(self.object["arg1"])] = self.object[str(self.object["arg1"])]`;
}
print(arg);
Get from other file
get!("io/print") //import print with namespace
get!("io/stdin")
print("Hi"); // use imported function