-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
212 additions
and
43 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
final def::INFO as { | ||
name = "def"; | ||
author = "Emmanouil Krasanakis"; | ||
license = "Apache 2.0"; | ||
version = "1.0"; | ||
release = 0; | ||
year = 2024; | ||
doc = " | ||
\n Introduces class and function definition semantics | ||
\n that make code look similar to other languages. | ||
\n | ||
\n def::fn | ||
\n ------- | ||
\n Defines a final code block with a given name and | ||
\n arguments. Positional arguments (in fact, a runnable | ||
\n default code block) are also supported like below. | ||
\n Additional arguments can also be provided. | ||
\n | ||
\n | def::fn adder(x, y|bias=0) \{return x+y+bias\} | ||
\n | ||
\n def::class | ||
\n Defines a class through its constructor. The | ||
\n constructor is final and callable. Here is an | ||
\n example: | ||
\n | ||
\n | def::class Dog(name) \{def::uses name;\} | ||
"; | ||
} | ||
|
||
|
||
#include "libs/def/fn" | ||
#include "libs/def/class" | ||
|
||
// enables the | ||
#macro {def::simplify;} as { | ||
#macro {fn} as {def::fn} | ||
#macro {module} as {def::module} | ||
#macro {abstract} as {def::abstract} | ||
#macro {uses} as {def::uses} | ||
#macro {class} as {def::class} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ final env::INFO as { | |
name = "env"; | ||
author = "Emmanouil Krasanakis"; | ||
license = "Apache 2.0"; | ||
version = "1.0"; | ||
version = "1.1"; | ||
release = 0; | ||
year = 2024; | ||
doc = " | ||
|
@@ -18,7 +18,7 @@ final env::INFO as { | |
\n - env::include(library); | ||
\n Includes a library by its name (as a string). | ||
\n | ||
\n - env::include(library|version=...;minrelease=...); | ||
\n - env::include(library|version=..;minrelease=..); | ||
\n Includes a library with a specific version and | ||
\n minimum release number. You may ommit the latter. | ||
\n | ||
|
@@ -64,12 +64,16 @@ final env::dependencies = list(new{env::INFO:}); | |
// check whether imnported library satisfies the version or release | ||
while(dependency as std::next(#of iter(env::dependencies))) | ||
if([email protected]) { | ||
if((version as version) and (dependency.version!=version)) | ||
fail("Incompatible versions for library {@lib}: | ||
\nimported version is {dependency.version} but {version} is required."); | ||
if((minrelease as minrelease) and (dependency.release<minrelease)) | ||
fail("Incompatible versions for library {@lib} version {version}: | ||
\nimported minor release is {dependency.release} but a minimum of {minrelease} is required."); | ||
if(version as version) | ||
if(dependency.version!=version) | ||
fail("Incompatible versions for library {@lib}: | ||
\nimported version is {dependency.version} but {version} is required."); | ||
if(minrelease as minrelease) { | ||
if(dependency.release<minrelease) | ||
fail("Incompatible versions for library {@lib} version {version}: | ||
\nimported minor release is {dependency.release} but a minimum of {minrelease} is required."); | ||
dependency.release = minrelease; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -98,3 +102,13 @@ final env::versions() = { | |
desc = desc + env::hbar; | ||
print(desc); | ||
} | ||
// print the full include statement | ||
final env::export() = { | ||
ljust = {size=7;env::ljust:} | ||
desc = env::hbar + "\n#include \"libs/env\"\n"; | ||
while(dependency as std::next(#of std::iter(env::dependencies))) | ||
desc = desc + "env::include({dependency.name|ljust} | version={dependency.version}, minrelease={dependency.release});\n"; | ||
desc = desc + env::hbar; | ||
print(desc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ final symb::INFO as { | |
"; | ||
} | ||
|
||
#macro {λ} as {symb::lambda} | ||
#macro {λ} as {symb::lambda} | ||
#macro {π} as {symb::pi} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
x = "fff" | float | int; | ||
print(x); | ||
#include "libs/env" | ||
env::include(loop); | ||
env::include(def); | ||
|
||
def::fn test(x,y) { | ||
return x+y; | ||
} | ||
|
||
print(test(1,2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,52 @@ | ||
BUILTIN _bb2 "fff" | ||
float _bb1 _bb2 | ||
int x _bb1 | ||
print # x | ||
BEGIN _bb4 | ||
BUILTIN name "env" | ||
END | ||
AS env::INFO _bb4 | ||
final # env::INFO | ||
BEGIN _bb54 | ||
inline _bb55 env::INFO | ||
return # this | ||
END | ||
new _bb52 _bb54 | ||
list env::dependencies _bb52 | ||
final # env::dependencies | ||
BEGIN _bb132 | ||
BUILTIN name "loop" | ||
END | ||
AS loop::INFO _bb132 | ||
final # loop::INFO | ||
BEGIN _bb143 | ||
inline _bb144 loop::INFO | ||
return # this | ||
END | ||
new _bbmacro2 _bb143 | ||
push # env::dependencies _bbmacro2 | ||
BEGIN _bb145 | ||
BUILTIN name "def" | ||
END | ||
AS def::INFO _bb145 | ||
final # def::INFO | ||
BEGIN _bb156 | ||
inline _bb157 def::INFO | ||
return # this | ||
END | ||
new _bbmacro3 _bb156 | ||
push # env::dependencies _bbmacro3 | ||
BEGIN _bb158 | ||
next x args | ||
next y args | ||
add _bb159 x y | ||
return # _bb159 | ||
END | ||
IS test _bb158 | ||
final # test | ||
setfinal # test name test | ||
BUILTIN _bb160 "fn" | ||
setfinal # test type _bb160 | ||
BEGIN _bb162 | ||
BUILTIN _bb163 I1 | ||
BUILTIN _bb164 I2 | ||
list args _bb163 _bb164 | ||
END | ||
call _bb161 _bb162 test | ||
print # _bb161 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters