Comments (6)
For the moment, I have no plan of adding this. Maybe someday I'll add this support.
from magpie.
@haifenghuang why I can’t include magpie modules?
include os // returns an error module not found
include net // too
Are they included by default? And is there any way to do not include them by default?
from magpie.
You don't need to include os
or net
because they are built-in modules. You just need to use them, Take os
built-in module for an example:
println(os.args())
println(os.getenv("PATH"))
println(os.getwd())
println(os.PATH_SEPARATOR)
Which methods or constants the os
module contain? You can take a look at os.go
source file. Particularly SetGlobalObj
and CallMethod
.
BTW, there is no way to not include them by default, sorry for this.
But..., If you really do not want to include them by default, then you must modify the source. How?
In object.go
, there is a init
method, which registers all the built-in modules. You can comment the modules you don't want.
for example, you don't want the os
module, then you could comment NewOsObj()
line.
from magpie.
@haifenghuang I want to add ability to include this modules from:
func (p *Parser) getIncludedStatements(importpath string) (*ast.Program, error) { ... }
Can I add NewOsObj()
to parser.go
to getIncludedStatements
. Is a NewOsObj()
the part of object.go
and can I import this function to parser.go
?
Thanks
from magpie.
I think you can not do it.
If you check the os.go
or object.go
, You can see that they are all dealing with object
, not AST(Abstract Syntax Tree)
.
What I mean is that in parser phase, it deals with AST, but in evaluator phase, it mainly deals with object.
They are different phases of the processing.
from magpie.
For your understanding, the magpie interpreter works like below:
Lexer---->Parser---->Evaluator
Below table lists the input & output of each phase:
Input | Phase | Output |
---|---|---|
source | Lexer | token |
token | Parser | AST |
AST | Evaluator | object |
from magpie.
Related Issues (17)
- hash vivification not working HOT 15
- Hello HOT 1
- tcp的read方法阻塞 HOT 1
- Please add multiline code blocks to the REPL. HOT 5
- Errors in tests. HOT 4
- I found a way to add support for highlight on Windows HOT 2
- Question: let keyword HOT 3
- Compilation succeed for Windows but failed for other platforms. HOT 12
- Question: have you planned to make Magpie compilable or bytecode? HOT 2
- Question: When do you want to implement interface, public, private, protected keywords? HOT 1
- [REPL Bug] stdin does not scans full string. HOT 1
- [REPL Bug] include errors ignoring. HOT 1
- How to check the typeof obj ? HOT 2
- Could Break to Label? HOT 1
- Is there go-routine feature? HOT 1
- howto get properties from json object HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magpie.