qscript ~experimental
a tiny, small, & fast scripting lang.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
QScript
This branch is used for experimenting with QScript, nothing in here is stable, go to master branch, or dev if you want to see what I'm working on actually. This branch mainly contains failed attempts to improve QScript A fast, static typed, scripting language, with a syntax similar to D Language.
Setting it up
To add QScript to your dub package or project, add the following into dub.json dependencies:
"qscript": "~>0.7.0"
or if you have dub.sdl:
dependency "qscript" version="~>0.7.0"
After adding that, look at the source/demo.d
to see how to use the QScript
class to execute scripts.
Getting Started:
To get started on using QScript, see the following documents:
spec/syntax.md
- Contains the specification for QScript's syntax.spec/functions.md
- Contains a list of predefined QScript functions.demos/demo.d
- A demo usage of QScript in D langauage. Shows how to add new functions
The code is thoroughly documented (a bit less documentation in compiler, but you probably wont touch that). Separate documentation can be found here.
The spec for QScript's byte code is also available, in spec/bytecode.md
, but knowing it is not necessary for using QScript.
the byte code is currently only for debugging and listing instructions available in VM. There is currently no functionality to write byte code and load it to run, so at this moment, that spec only describes how to read byte code to debug the compiler.
Building Demo:
To be able to run basic scripts, you can build the demo using:
dub build --config=demo --build=release
This will create an executable named demo
in the directory. To run a script through it, do:
./demo path/to/script
You can also use the demo build to see the generated byte code for your scripts using:
./demo "path/to/script" "output/bytecode/file/path"
Features:
- Syntax similar to D
- Dynamic arrays
- Very fast execution speed. QScript has a virtual machine for this purpose, no interpretation is done at run time.
- Static typed. This eliminates a lot of errors.
- Function overloading
- References (similar to pointers, but much much simpler)
TODO For Upcoming Versions
- Implement
do-while
andfor
loops - done (out in 0.7.0) - Change syntax of variable declarations to the way it's done in D-lang - done (out in 0.7.0)
- Function overloading - done (out in 0.7.0)
- Errors detected in byte-code-generation can currently not tell which line error is in, fix it - done (out in 0.7.0)
- Add structs, and
new
keyword to be used with references - Yet to do (planned for sometime later in 0.8.x, or maybe even 0.7.x if I figure it out early) - Add library support using
import
keyword - Planned for 0.8.0
Example Scripts:
These scripts can be run through the demo configuration.
Hello World:
function void main(){
writeln ("Hello World!");
}
Array & For loop:
function void main{
int[] array = [1, 2, 3, 4];
for (int i = 0, length = length(array); i < length; i = i + 1;){
writeln (toStr(array[i]));
}
}
- ~experimental released 5 years ago
- Nafees10/qscript
- MIT
- Copyright © 2016, nafees
- Authors:
- Dependencies:
- utils
- Versions:
-
0.8.0-alpha 2021-Mar-22 0.7.4 2021-Feb-02 0.7.3 2020-Dec-17 0.7.2 2020-Oct-27 0.7.1 2020-Mar-14 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
4 downloads this month
-
197 downloads total
-
- Score:
- 2.3
- Short URL:
- qscript.dub.pm