Closed IngwiePhoenix closed 10 years ago
Hello, thank you for good questions, I'll try to answer.
I see, thanks for the reply!
So the parser is only the step before the VM, I see. And, what is the „rough“ logic that the VM has to execute things? Sorry that I ask such deep questions, but I am very curios ^^;
Also, how would one teach the parser/vm additional syntax - and how hard is that, too?
And, Im totally going to implement Objectscript into an upcomming project - its jsut too awesome :) Am So. Feb. 02 2014 21:18:04 schrieb Evgeniy Golovin:
Hello, I'll try to answer all questions.
OS has parser and compiler. The parser splits input text to list of tokens. The compiler uses the tokens to make result opcodes used by OS virtual machine.
The parser doesn't know which purpose it has to expect but the compiler knows. For example "if" token expects boolean expression and body. The body could be started using "{" character.
if(i > 0){ echo "OK" }
The compiler knows that the "{" character contains number of instructions but not OS object declaration.
It's C++ templates magic. OS binder uses template functions that convert OS arguments to C++.
Use objectscript.h, objectscript.cpp, os-heap.h, os-heap.cpp, os-binder.h to compile OS min version.
— Reply to this email directly or view it on GitHub.
Not only, it contains Parser => Compiler => VM. OS::Core::execute() implements main VM logic.
New syntax should be implemented, debugged, tested, optimized, It should not conflict current syntax. So it depends on the new syntax.
Wat, that function is 1249 lines long?! Wow… That’ll take a lot of time untill I can wrap my head around that o-o
BTW. When I try to use
var $meep=“foo“;
I get an error that says that $ is a syntax error…but i saw nothing in the documentation that this way of variable naming was disallowed? o.o Am Mo. Feb. 03 2014 09:57:58 schrieb Evgeniy Golovin:
Not only, it contains Parser => Compiler => VM. OS::Core::execute() implements main VM logic.
New syntax should be implemented, debugged, tested, optimized, It should not conflict current syntax. So it depends on the new syntax.
— Reply to this email directly or view it on GitHub.
Sorry, $ is reserved for future purposes at the moment.
$ is not reserved now, you could use it for names of variables or functions
Awesome. I just tested it and made the function I wanted to make. Thanks for the info!
Hello there ^.^
I am currently just browsing GitHub, looking here and there, while spending my time with thinking about different ways to embed stuff into an application. And that was the way I came across thsi project here. And it once again made me ask: How do scripting languages work?
The reason I am asking here is rather simple. I see that a lot of syntaxes are mixed here - like the sugar syntax (yep, I read the "Programming in Objectscript" page completely) - making regular "read and parse" probably harder.
And that brings me to the first question: How does OS actually tokenize the input script? Does it iterate over each character (byte) one by one? Or how does it do that?
The second question: How hard is it, to implement a new feature into an existing language like OS? Like, I am looking for a way to bring ObjC syntax to a scripting language. To me, that syntax makes a lot of sense - having objects, that can recieve messages. Just imagine a multi-threading application, and you have a global object to send messages between the threads. That kind of syntax is nice, and I just cant imagine how it would be implemented. Because, I know that [] are already used to create arrays and denote object/array entries - so that token already has a sense. But it has two purposes - how does a prser like the one OS has know which purpose it has to expect?
Then my third question: How does OS pass the arguments so directly, that it can litterally take a C/++ function pointer and pass the original types to its arguments? from what I know about C++, the functions are pre-defined, and its not (correct me if I am wrong) possible to dynamically pass arguments to a function...? I could guess that all the function arguments are first turned into voids, and upon the call, are converted to their original type again...but yet, I dont know how to think about that.
I really like ObjectScript, and I want to do more with it. There is just one thing that I am always looking for: implementing into an existing project. My project uses GYP - so I can not use CMake. Which files do I need to get a basic OS runtime together? I see there are a lot of extensions too - as well as bindings for ncuses and the like. How do I compile OS "by hand"?
Hope this isnt too much to answer, really. ^^; But I am very curios about scripting languages - especially those that are easy to reuse / implement into existing applications to make them scriptable.
Kind regards, Ingwie