is
is an experimental simplified language that is transpiled to JavaScript.
The aim is to create a language for scripting that does not require any
significantly complex symbols or constructs, so that it can be used by more
novice programmers to achieve simple tasks.
- Write a
.is
input file in theis
language (see below). - Run
npm run compile $INPUT_FILE
to transpile to JavaScript. - Run the output
build.js
as usual usingnode
.
For example, the example test file example.is
:
$ npm run compile ./example.is
$ node build.js
Optionally, specify
--show-source
to see each output line's input included as a comment.
$ npm test
The is
language follows a similar structure to most other statement-based
languages. The basic concepts are demonstrated below.
Note: At the moment, only one operation per line is supported.
Comments are signified using //
at the start of a line.
// This is a comment!
Variables are declared using the value
keyword, and an initial value.
value my_value is 0
value my_value is 25 + 100
Variables are reassigned using the is
keyword.
my_value is 10
my_value is 'hello' + 'world'
Use the log
keyword to output strings, optionally including variables with
a template.
value my_value is 10
log 'Your value is now {my_value}'
Functions are declared using the task
keyword and ended with the end
keyword. Function parameters must always be declared after gets
, or nothing
if there are no parameters.
task increment gets input_value
return input_value + 1
end
Functions are called using the run
keyword, specifying arguments after with
.
task greet gets name
log 'Hello there, {name}!'
end
value name is 'Chris'
run greet with name
You can use the return value of a function by combining is
with run
(and optionally with
):
value result is run fibonacci with 9
An 'if' style statement can be used with when
and any standard operators. As
with functions, the end
keyword tells is
when the 'if' is finished.
when temperature > 28
log 'Too hot!'
end
The until
keyword allows a 'while' style loop to run until the value indicated
by equals
is reached. As with functions, the end
keyword tells is
when the
loop is finished.
value counter is 0
value maximum is 100
until counter equals maximum
run increment with counter
log '{counter}'
end
Objects can contain more than one value, and so are declared differently to
plain values with the object
keyword, then followed up with property
statements to add properties.
object car
car property num_wheels is 4
car property color is 'red'
Object values are accesses simply using the .
operator.
log 'Car has {car.wheels} wheels'
value car_color is car.color
Specific imports are available (such as fetch
for web requests) by using the
using
keyword.
using fetch
Using an unrecognised library will throw an error detailing which libraries are available to use.
See the
examples
directory for more example scripts.
task fibonacci gets input
when input <= 1
return input
end
// return fib(n-1) + fib(n-2);
value n_minus_1 is input - 1
value n_minus_2 is input - 2
value result_1 is from fibonacci with n_minus_1
value result_2 is from fibonacci with n_minus_2
return result_1 + result_2
end
value result is from fibonacci with 9
log 'result: {result}'
result: 34
using fetch
task main
value body is from fetch with 'http://time.evrythng.com/time'
// Convert string to object
object json is body
log 'The time is {json.timestamp}'
end
run main
- Utilities (date/time, random numbers, read/write files, etc.)
- Evaluate function calls inline (multiple passes)
- Multiline test (e.g: to test object from variable)