This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfinal-pitch.mur
252 lines (168 loc) · 8.13 KB
/
final-pitch.mur
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#header <nothing-to-see-here>
// ^ The header is used to give the compiler nessessary information before it
// starts compiling the code. Flags start with the operators "--". If you do not
// wish to pass any information to the compiler, you can just remove it.
// The available flags are:
// "no-comments": can be used to tell the compiler to not look for comments in this
// file
// "no-preprocessor-methods": can be used to tell the compiler that this file does
// not contain any preprocessor methods
// "skip-processor": can be used to tell the compiler to not compile the code after
// the header, and jump to the C compiler compiling stage.
/*
Murmur | (C) EnderCommunity
------------------------------------------------------------------------------------
This is a pitch file for Murmur that will include the syntax and structure
of Murmur, and all the functions that it can use.
(!) This is nowhere near being final, this is all just a pitch.
*/
// (!) All the functions used outside of groups are seen by the compiler as
// preprocessor functions! So any normal code outside of groups that is not a
// preprocessor-related feature will cause the compiler to exit with an error.
// using system.io; //Tell the compiler that the program is going to use the
//input/output library in the folder "system"
using test;
using foldertest.test2;
// using array;
// using file; // The "file" type should be managed
// // by this library
// using io;
import "final-pitch-lib.lib.mur"; // Import another Murmur file!
define ZERO 0; // You can use the `define` function to define a var that
// will be replaced by the provided value before the execution
// of this code
setsize int 2; // Set a custom size of memory (in bytes) to allocate for any type
setsize double 10; // You can do the same with all the built-in types
// import "path/to/my/file2.mur"; //You need to pay attention to the importing order
// of your files! For example, "file.mur" will not be able to use the custom set
// amount of memory for the 'int' var, whereas "file2.mur" will be able to
// use it with no problem whatsoever.
// (!) Modules may not be necessary anymore with this new arrangement
group::public FinalPitch { // Groups can help you keep a whole block of code within one
// structure to better organise your code
// Groups can only contain classes, any normal code here will cause the
// program to crash.
class::public Program { // Classes can be used to completely separate functions from one
// another, in case you wanted to prevent other classes from
// accessing some vars or functions
// These at class-level variables!
// They can only be accessed using the class object ("this", or any class reference)
var::public:int globA = 0;
var::public:double globB = 0.0;
var::public:float globC = 0.0;
var::public:char globD = 'D';
var::public:string globE = "Global E";
var::public:bool globF = true;
var::public:file globG = new file.stream("path/to/my/file.txt");
var::public:hex globH = 0xFF;
var::public:string[] globI = new array.string(6);
var::private:hex[,] globJ = new array.hex(8, 2);
func::public:int Main(envi:string[], length:int){ //This is the main
//function in the program!
//All Murmur programs
//should include a main
//function.
//This is a public function! (It can be accessed from anywhere
//outside this class)
Func(); //You can access any function inside this class
var:^int a = 0; //This var will allocate the custom set amount of
//memory specified at the start of this program!
var:int b = 1; //This var will allocate the default amount of
//memory set by the compiler
var:^int c = Test(a, 1); //You can pass all types of vars to other functions
a = 1, c = 5; //Change the value of 'c' to '5'm and the value of 'a' to '1'
a = c = 6; // The same as a = 6, c = 6;
//a & c = self + 5; // EXP: The same as a = a + 5, c = c + 5;
//a | c = self + 5; // EXP: The same as if(a) a = a + 5; if(c) c = c + 5;
PlusOne(b:refer); //the value of 'b' is '2' now!
var:bool myTest = false;
if(myTest == true){ //This condition is impossible
//Anything here will never manage to run
}else if(false){
// Hm...
}else{
//Hmm...
}
if(myTest != true){ //This condition is possible
//...
}
if(1 >= 5 || 1 > 5 || (1 > 1 && 1 < 1)){ //These conditions are impossible
//Anything here will never manage to run
}
if(1 <= 5 || 1 < 5){ //These conditions are possible
//...
}
io.console.print("Hello there!");
return ZERO; //This is the final program output code
}
func::private:void Func(){
//^ This is the return type of the function!
//This is a private function! (It can be accessed only by
//other functions inside this class)
//Your code goes here!
}
func::public:^int Test(a:^int, b:int){
a = (^int) b; //Do not support this!
// First, add a library that can take care of this stuff.
return a;
}
func::public:void PlusOne(a:int:refer){ //with the keyword "ref", you can make changes to the originally passed var within this function
//^ "reference"
//int og = 0;
//PlusOne(og:refer);
a++; //the value of 'og' will change to '1'!
}
func::public:void myTests(){
var:bool myTest = false;
var:int a = 0, b = 0;
var:double c = 4, d = 3;
myTest!!; //This is the same as myTest = !myTest;
myTest = !myTest;
a++; //This is the same as a += 1;
a += 1;
a = a + 1;
b--; //This is the same as b -= 1;
b -= 1;
b = b - 1;
c %= d; //This is the same as c = c % d;
c % d; //The result is 1!
c /= 0.5; //This is the same as c = c / 0.5;
c / d; //The result is 0.66666666!
c *= d; //This is the same as c = c * d;
c = c * d;
}
func:string myStringTest(a:string){
var:string b = "Hi!";
delete b; // You can delete vars using
// the keyword "delete".
// (But you can only do that on
// the level of your current
// zone!)
var:int b = 100, c = 0;
delete d, c;
// Also, you can't delete any vars
// that are passed as arguments to the
// function, class-level vars, or
// constants.
}
func:hex[,] ReturnHexArray(){
return this.globJ;
}
}
// Note to myself:
// - Define the behaviour of the "this" statement (make it so it points to the current class zone)
// - Make the return type a required argument when calling functions (`MyNameSpace.MyClass.MyFunction(); ==> MyNameSpace.MyClass.MyFunction:ReturnType();`)
class::public AnotherClass {
var::public:int a = 0;
var::private:int b = 0;
func::public:AnotherClass Construct(a:int, b:int){ //You can use constructors in your classes!
this.a = a;
this.b = b;
}
}
class Smth { //Any object with no state indicator will be set to 'public' by default
func:void myTest(a:int){
//
}
}
}