MCLang, now with testing!

This commit is contained in:
2024-12-21 05:10:03 +02:00
parent 54b6df5862
commit debcf6ad6c
26 changed files with 1210 additions and 41 deletions

View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

10
tests/parser/loops.exp Normal file
View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

10
tests/parser/structs.exp Normal file
View File

@@ -0,0 +1,10 @@
Program {
ast: Block(
[],
),
structs: {},
enums: {},
types: {},
functions: {},
member_functions: {},
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,7 @@
// Hello, this is a single line comment
/*
And this is a multiline comment, which is
useful for longer documentation
*/

View File

@@ -0,0 +1,62 @@
[
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 3,
col: 4,
},
tt: Delim(
ParenR,
),
},
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 3,
col: 2,
},
tt: Delim(
ParenL,
),
},
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 2,
col: 4,
},
tt: Delim(
CurlyR,
),
},
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 2,
col: 2,
},
tt: Delim(
CurlyL,
),
},
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 1,
col: 4,
},
tt: Delim(
SquareR,
),
},
Token {
loc: Loc {
file: "tokeniser/delimiters.mcl",
line: 1,
col: 2,
},
tt: Delim(
SquareL,
),
},
]

View File

@@ -0,0 +1,3 @@
[ ]
{ }
( )

View File

@@ -0,0 +1,212 @@
[
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 21,
col: 5,
},
tt: Keyword(
Loop,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 20,
col: 3,
},
tt: Keyword(
As,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 19,
col: 7,
},
tt: Keyword(
Return,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 18,
col: 7,
},
tt: Keyword(
Extern,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 17,
col: 8,
},
tt: Keyword(
Include,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 16,
col: 6,
},
tt: Keyword(
False,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 15,
col: 5,
},
tt: Keyword(
True,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 14,
col: 7,
},
tt: Keyword(
Static,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 13,
col: 4,
},
tt: Keyword(
Mut,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 12,
col: 6,
},
tt: Keyword(
Const,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 11,
col: 4,
},
tt: Keyword(
Let,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 10,
col: 9,
},
tt: Keyword(
Continue,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 9,
col: 6,
},
tt: Keyword(
Break,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 8,
col: 4,
},
tt: Keyword(
For,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 7,
col: 6,
},
tt: Keyword(
While,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 6,
col: 5,
},
tt: Keyword(
Type,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 5,
col: 5,
},
tt: Keyword(
Enum,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 4,
col: 7,
},
tt: Keyword(
Struct,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 3,
col: 5,
},
tt: Keyword(
Else,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 2,
col: 3,
},
tt: Keyword(
If,
),
},
Token {
loc: Loc {
file: "tokeniser/keywords.mcl",
line: 1,
col: 3,
},
tt: Keyword(
Fn,
),
},
]

View File

@@ -0,0 +1,21 @@
fn
if
else
struct
enum
type
while
for
break
continue
let
const
mut
static
true
false
include
extern
return
as
loop

View File

@@ -0,0 +1,96 @@
[
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 7,
col: 11,
},
tt: Number(
Number {
val: 173,
base: 2,
signed: false,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 6,
col: 8,
},
tt: Number(
Number {
val: 13633,
base: 8,
signed: false,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 5,
col: 9,
},
tt: Number(
Number {
val: 16759299,
base: 16,
signed: false,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 4,
col: 3,
},
tt: Number(
Number {
val: 21,
base: 10,
signed: false,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 3,
col: 22,
},
tt: String(
TString {
val: "this is a c string!",
cstr: true,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 2,
col: 27,
},
tt: String(
TString {
val: "this is a normal string!",
cstr: false,
},
),
},
Token {
loc: Loc {
file: "tokeniser/literals.mcl",
line: 1,
col: 4,
},
tt: Char(
Char(
'c',
),
),
},
]

View File

@@ -0,0 +1,8 @@
'c'
"this is a normal string!"
c"this is a c string!"
21
0xFfbA03
0o32501
0b10101101

View File

@@ -0,0 +1,382 @@
[
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 38,
col: 2,
},
tt: Punct(
Pathaccess,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 37,
col: 2,
},
tt: Punct(
Fieldaccess,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 36,
col: 2,
},
tt: Punct(
Neq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 35,
col: 2,
},
tt: Punct(
EqEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 34,
col: 2,
},
tt: Punct(
Eq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 33,
col: 2,
},
tt: Punct(
XorEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 32,
col: 2,
},
tt: Punct(
OrEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 31,
col: 2,
},
tt: Punct(
AndEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 30,
col: 2,
},
tt: Punct(
ShrEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 29,
col: 2,
},
tt: Punct(
ShlEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 28,
col: 2,
},
tt: Punct(
ModEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 27,
col: 2,
},
tt: Punct(
MulEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 26,
col: 2,
},
tt: Punct(
DivEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 25,
col: 2,
},
tt: Punct(
SubEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 24,
col: 2,
},
tt: Punct(
AddEq,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 23,
col: 2,
},
tt: Punct(
Xor,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 22,
col: 2,
},
tt: Punct(
Le,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 21,
col: 2,
},
tt: Punct(
Ge,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 20,
col: 2,
},
tt: Punct(
Lt,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 19,
col: 2,
},
tt: Punct(
Gt,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 18,
col: 2,
},
tt: Punct(
Or,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 17,
col: 2,
},
tt: Punct(
OrOr,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 16,
col: 2,
},
tt: Punct(
AndAnd,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 15,
col: 2,
},
tt: Punct(
Shr,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 14,
col: 2,
},
tt: Punct(
Shl,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 13,
col: 2,
},
tt: Punct(
Mod,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 12,
col: 2,
},
tt: Punct(
Div,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 11,
col: 2,
},
tt: Punct(
Not,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 10,
col: 2,
},
tt: Punct(
Star,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 9,
col: 2,
},
tt: Punct(
Ampersand,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 8,
col: 2,
},
tt: Punct(
Comma,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 7,
col: 2,
},
tt: Punct(
Minus,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 6,
col: 2,
},
tt: Punct(
Plus,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 5,
col: 2,
},
tt: Punct(
FatArrow,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 4,
col: 2,
},
tt: Punct(
Arrow,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 3,
col: 2,
},
tt: Punct(
Pathaccess,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 2,
col: 2,
},
tt: Punct(
Colon,
),
},
Token {
loc: Loc {
file: "tokeniser/punctuation.mcl",
line: 1,
col: 2,
},
tt: Punct(
Semi,
),
},
]

View File

@@ -0,0 +1,39 @@
;
:
::
->
=>
+
-
,
&
*
!
/
%
<<
>>
&&
||
|
>
<
>=
<=
^
+=
-=
/=
*=
%=
<<=
>>=
&=
|=
^=
=
==
!=
.
::