Initial enums working

This commit is contained in:
Krzosa Karol
2022-05-31 11:50:36 +02:00
parent 5e0aabb1cb
commit 627e2bad88
8 changed files with 168 additions and 17 deletions

View File

@@ -7,6 +7,8 @@
#include "ccodegen.cpp"
/*
-------------------------------------------------------------------------------
2022.05.28 - On lambda expressions
I think it's not wise to add the multiline lambda expressions
As is the case with python it would require new alternative syntax.
@@ -18,12 +20,14 @@ in a language to solve something that is a minor inconvenience,
second of all it turned out to be kind of bad, maybe if it would be more
complicated then it would be ok but it implies that you have to semicolon end
a lot of thing unintuitively.
//
Probably single line lambdas should be ok. Currently braces turn off indentation
awareness. There might be something you can do by trying to turn that on
problem is that complicates parsing a lot cause you have to account for multiple
indent styles, which means error messages become bad.
-------------------------------------------------------------------------------
2022.05.30 - On constructors and compound expressions
I unified the compound expression syntax (Type){} with function call syntax Type().
It's differentiating on whether you used type. I think there is a benefit to the language
@@ -33,6 +37,7 @@ and variants. having the idea of compounds doing one thing is reassuring I think
You can always do a constructor by writing a function with lower case type if you want that.
For now I don't thing it should be overloadable.
-------------------------------------------------------------------------------
@todo
[ ] - Enums
@@ -40,11 +45,13 @@ For now I don't thing it should be overloadable.
[ ] - Fixing access to constants, in C we cant have constants inside of structs / functions so we need to rewrite the tree
[ ] - Access through struct names to constants Arena.CONSTANT
[ ] - Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative
[ ] - Write up on order independent declarations
[ ] - For loop
[ ] - Switch
[ ] - Lexer: Need to insert scope endings when hitting End of file
[ ] - Add single line lambda expressions
@donzo
[x] - Struct calls
[x] - Default values in calls
@@ -76,7 +83,8 @@ int main(){
String result = {};
// result = compile_file("order1.kl"_s);
// result = compile_file("lambdas.kl"_s);
result = compile_file("order2.kl"_s);
// result = compile_file("order2.kl"_s);
result = compile_file("enums.kl"_s);
// result = compile_file("globals.kl"_s);
printf("%s", result.str);