Skip to content

Commit c78d388

Browse files
Added dictionaries, multiline comments and more
1 parent cbfc8ef commit c78d388

File tree

8 files changed

+194
-99
lines changed

8 files changed

+194
-99
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ CritLang/Properties/PublishProfiles/FolderProfile.pubxml.user
77
CritLang/CritLang.csproj.user
88
CritLang/Content/ola.txt
99

10-
.antlr
10+
.antlr
11+
test.crit

CHANGELOG.MD

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
## 0.2.0 -> 0.2.1
2+
This update mainly brings dictionaries but it also brings a lot of bug fixes and improvements.
3+
Fixed the syntax warnings.
4+
Optimized arrays.
5+
Fixed the bug that made that you coudn't use a declared variable as a value to an array.
6+
Added multi line comments E.g /* */.
7+
Removed unused code.
8+
Improved the way `Write` and `WriteLine` print arrays and now dictionaries.
9+
10+
11+
12+
13+
114
## 0.1.11 -> 0.2.0
215
Updated from .Net 6 to [.Net 7](https://dotnet.microsoft.com/en-us/download/dotnet/7.0).
316
Updated from [Antlrcs4.6.6](https://github.com/tunnelvisionlabs/antlr4cs/releases/tag/v4.6.6) to [Antlr4.11.1](https://github.com/antlr/antlr4/releases/tag/4.11.1).
4-
No more dynamics used inside the interpreter, this only happened because of the new Generic maths added in .NET 7 and for now, basically all numbers are converted to doubles but this needs urgent change.
17+
No more dynamic types used inside the interpreter, this only happened because of the new Generic maths added in .NET 7 and for now, basically all numbers are converted to doubles but this needs urgent change.
518
The compiled executable is about 5.5 times smaller and the execution time is about 4.5 times faster, this is only possible with the new [Native AOT](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/) introduced in .Net7.<br> Unfortunately it only works on win-x64 and Linux-x64 (it also works for win-arm64 and linux-arm64, but I don't own any ARM machines to compile it to those targets) for now, the other platforms still use [ReadyToRun](https://learn.microsoft.com/en-us/dotnet/core/deploying/ready-to-run).

CritLang/Content/Crit.g4

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ line: statement | ifBlock | whileBlock;
88

99
statement: (assignment|functionCall) ';';
1010

11-
ifBlock: 'if' expression block ('else' elseIfBlock);
11+
ifBlock: 'if' expression block ('else' elseIfBlock)?;
1212

1313
elseIfBlock: block | ifBlock;
1414

15-
whileBlock: WHILE expression block ('else' elseIfBlock);
15+
whileBlock: WHILE expression block ('else' elseIfBlock)?;
1616

1717
WHILE: 'while' | 'until';
1818

@@ -44,27 +44,27 @@ boolOp: BOOL_OPERATOR;
4444

4545
BOOL_OPERATOR: 'and' | 'or' | 'xor';
4646

47-
constant: INTEGER | FLOAT | STRING | BOOL | array | NULL;
47+
constant: INTEGER | FLOAT | STRING | BOOL | array | dictionary | NULL;
4848
//arrayIndex: constant '[' INTEGER ']';
4949
INTEGER: [0-9]+;
5050
//SEPERATOR: '.' | ',';
5151
FLOAT: [0-9]+ '.' [0-9]+;
5252
STRING: ('"' ~'"'* '"') | ('\'' ~'\''* '\'');
5353
BOOL: 'true' | 'false';
54-
array: '[' (constant (',' constant)*)? ']';
54+
array: '[' ((constant | IDENTIFIER) (',' (constant | IDENTIFIER))*?)? ']';
55+
//array: '[' (constoridentifier (',' constoridentifier)*?)? ']';
56+
dictionary: '{' (STRING ':' (constant | IDENTIFIER) (',' (constant ':' (constant | IDENTIFIER)))*?)? '}';
5557
//index: '[' INTEGER ']';
58+
constoridentifier: constant | IDENTIFIER;
5659
NULL: 'null';
5760

58-
INDEX: '[' IDENTIFIER ']' | '[' INTEGER ']';
61+
fragment INDEX: '[' (IDENTIFIER | INTEGER | STRING) ']';
5962
INCREMENTOP: '++' | '--';
6063

6164
block: '{' line* '}';
6265

6366
WS: [ \t\r\n]+ -> skip;
6467
IDENTIFIER: [a-zA-Z_][a-zA-Z0-9_]* (INDEX)* ;
6568

66-
Comment
67-
: '#' ~( '\r' | '\n' )*
68-
;
69-
70-
69+
LINECOMMENT: '#' ~[\r\n]* -> skip;
70+
MULTICOMMENT: '/*' .*? '*/' -> skip;

CritLang/Content/test.crit

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)