| Crates.io | whiledb |
| lib.rs | whiledb |
| version | 0.1.4 |
| created_at | 2023-12-12 11:51:35.411203+00 |
| updated_at | 2023-12-31 09:36:41.443685+00 |
| description | rust implementation of WhileDB language |
| homepage | |
| repository | https://github.com/HellOwhatAs/whiledb |
| max_upload_size | |
| id | 1066285 |
| size | 103,495 |
rust implementation of While-DB, the programming language used in SJTU CS2612 (2022 Fall) Attachment 1014
find a way to omit ; after }
currently unable to add ;, however
add function
make any expression callable (currently only ident callable)
add class and method
add [ ] to represent array and getitem
add string
add interpreter or compiler
any object (including the program state) can be represented as
Any, pointer toWdAnyWdAnyis eitherObjectorFunctionObjecthas 2 fieldsbuildin(store buildin types orNot) andattrs(a string toAnymap)Functionis either build-in or definedstate store
- types (object with
"__name__"=> typename, and"__method_name__"=> method function)- instances (object with
"__type__"=> type object)- functions ...
state =
{ <locals>, "..": {<nonlocals>} }😎, only do this in DefinedFunction (buildin function do not have locals)
call an expression
- expr is a
expr0.identand expr is a instance (__type__is nottype), args =[expr0, *args]plan to check this via add flags on return value ofevalpub fn eval(expr: Rc<Expr>, state: Any) -> Result<(Any, Option<Any>)>etc.plan to check
break,continue,returnthe same way.- expr is a
WdAny::Function, original args- expr if a
Object
- with
__init__self-attr, args =[new_obj (with __type__ => this expr), *args]- with
__call__self-attr, original args- with
__call__attr found from__type__attr, args =[this expr, *args]