-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement module system for stdlib (msingi) and local libs (hapa) #97
Open
gekkowrld
wants to merge
7
commits into
NuruProgramming:main
Choose a base branch
from
gekkowrld:prof
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
A simple module that for now only works for the std lib. The std lib is named as `mkt`. A simple import can look like: where::file or where::dirs::file The file is the last part of the import. An example: ```nuru tumia mkt::hisabati andika("Thamani ya PI ni: {0}\n".panga(hisabati.PI())) ``` Faili hizi zinatafutwa: kwenye thamani ya mazingira: MAKTABA_YA_NURU mfano: MAKTABA_YA_NURU=$HOME/code/nr/maktaba -> /usr/lib/nuru/maktaba (something similar in Windows) -> /lib/nuru/maktaba Kama haitapatikana hapo, kutakuwa na kosa kuonyesha kuwa haijapatikana. Kwa sasa maktaba ya kawaida hayaandikwa, mifano hii haitafanya. Maktaba ya awali yalikuwa yameandikwa kwa lugha ya programu ya Go. Kutumia mabadilisho yanatumahi kuanzisha kuandika maktaba ya kawaida kwenye lugha ya programu ya Nuru. Faili zitakazo angaliwa ni ".nuru" badala ya zile za awali za ".sw" ama ".nr". Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
The module directory has been removed to make way for start of std rewriting. Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
From previous changes, the tests started to fail because of added <NEWLINE> token. This is now fixed for most modules except the evaluator module. The remaining problem may be related to the NEWLINE token. The tests check the last token, which previously would be the value. But now the last token would be the NEWLINE instead of another token like INTEGER. When running, the code works correctly. This strongly indicates the problem to be in the tests instead of the code (unlike the other tests). Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
Some modules were hardcoded, this has been removed. Tests pass as before (except module related ones which don't currently exist, and evaluator ones ofc). Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
Modules that are referenced by `hapa` e.g: tumia hapa::faili can be read succesfully. Add a new information to the token `Filename`. This is used for resolving, so its empty in most parts. its initialized by the import parser. The stdlib will be referenced by `msingi` instead of `mkt`. This is more approriate and sensible than the last. Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
Only functions were allowed to be imported/exported. If a variable or a function name (without a call), then it will fail. This restricted the way that packages can be written. It meant that to export anything, you need to wrap it inside a function. If a function that is not executed is printed, it follows the nodejs format. [Function: <name>] i.e [undo: <jina>]. If the function has parameters, then they can are displayed also. [undo: <jina>; inahitaji: <[vinavyohitajika]>] This is more cleaner than trying to piece together the function body. Add extra logic for when assignment is to a function. This is to add the function name which was lost when handing over from assign to functionEval. Signed-off-by: Gekko Wrld <gekkowrld@gmail.com>
i've improved most of the cases. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The module system is now nearly complete.
The module system is file based.
You can import a file (don't include the extension)
File extensions MUST be
.nuru
.You can nest as deep as possible but the last part MUST always be a file.
e.g tumia d1::d2::d3::...::d99::f
Aliasing can be used e.g tumia lan::fr = en
The
msingi
andhapa
resolutions are done and can be used.Outside modules have not yet been implemented.
This can be bypassed by using vendoring system(s).
To use a module from std, just write
If the module name already exists, you can add
= alias
to change the name used.For the internal modules, then the syntax to be used is
tumia hapa::faili
External modules are yet to be supported as of now.