@bscript/lang
v2.0.0
Published
A CLI for BlueScript
Maintainers
Readme
Run BlueScript on 64bit-Linux (or macOS) systems
Requirement
node.js
The
cccommand for compilation of C programs
Installation
Download BlueScript from GitHub:
git clone https://github.com/csg-tokyo/bluescript.gitand install it.
npm installMove to the ./lang directory.
cd langRun the REPL
To run the REPL (Read-Eval-Print Loop) of BlueScript,
npm run shellBuilt-in utility functions print(v: any), print_i32(v: integer), and performance_now() are available.
To close the shell,
> .quitTo read a source file and run its content,
> .load foo.bsThis reads foo.bs and runs the BlueScript program contained in that source file.
The source files can be given as command-line arguments.
npm run shell foo.bs bar.bsThis reads and runs foo.bs and bar.bs in this order when the REPL starts running.
Note that the REPL separately compiles every code fragment by users.
It performs the reading, compiling, running, and printing loop.
All the temporary files are stored in ./lang/temp-files.
Compile a BlueScript program
To compile a BlueScript program,
npm run compile foo.bs bar.bsThis compiles foo.bs and bar.bs and generates the native binary,
which first runs foo.bs and then bar.bs.
If a function called in foo.bs is defined in bar.bs, a compilation error will
be reported.
The compiled programs can access the same built-in functions as the ones available in the REPL.
To give an optional argument to the backend C compiler,
npm run compile foo.bs bar.bs -- -args=-g,-o,fooArguments specified with -args= are passed directly to the C compiler.
Commas within the argument string are automatically replaced with whitespace
to separate individual compiler options.
For example, the input -args=-g,-o,foo results in the compiler receiving
the arguments -g -o foo.
Alternatively, use +args= without the -- separator.
npm run compile +args=-g,-o,foo foo.bs bar.bsFor debugging, pass the -g or +g option to the compiler.
This prevents the compiler from removing working files such as generated source files in C.
npm run compile foo.bs bar.bs -- -g -args=-g,-o,foo