A programming language that revolves around piping.
Pipescript is functional, high-level, interpreted/compiled, indented, single threaded, dynamically typed programming language.
Pipescript can be interpreted directly or be compiled into javascript.
- commands for everything
- human readable code
- using piping for everything posible
- using less symbols
install pipe scipt development kit from npm npm install -g pipescript-dev-kit
which comes with pipescript interpreter (command - pipescript) and pipescript compiler (command - psc)
plz report any bugs by opening a issue
Variables are declared using set command. use $ to use Variables. use -$ sign to get negative
# setting variable
set var 10
# using variables
log $var
log -$var
use # to write comments and ## to write multi-line comments
# this is comment
##
this is a comment
this also is a comment
##
use | to use output of one command as input of another
log | add 1 1
# how it is processed
log | add 1 1
log 2
set n | add 1 | multiply 1 2
set n | add 1 2
set n 3
[ ] are used encapsulate code
log [add 1 1]
# how it is processed
log [add 1 1]
log 2
log [add 1 1] [add 1 1]
log 2 2
functions as usual
function <name> $arg1 $arg2
return $arg1
function example $n
return | add $n 10
mostly every thing in pipescript is done using commands. command takes arguments and return a output.
used for setting variables
set <name> <value>
set n 100
return value : null arguments : var-name, value
get index or key of refrence types
get <refrence-type> <keys/indexs>
example
# pipescript form
1. get $array 0
2. get $array 0 10 'key'
# javascript form
1. array[0]
2. array[0][10]['key']
return value : target value arguments : refrence-type, multiple key/index
log multiple inputs to console
log <input> ...
log 'this string will get logged'
log 100 100 # 100100
return value : null arguments : input, input ...
calling a function
call <function_name> <arg>
call process 10 10
function process $a $b
return | add $a $b
return value : the return value from called function arguments : function-name, args for function
exit interpreting script
exit
return value : null arguments : none
Arithmetic commands
command | definition | args no | js equivalent |
---|---|---|---|
add | adds multiple inputs | multiple | + |
divide | divde multiple inputs | multiple | / |
multiply | multiply multiple inputs | multiple | * |
neg | return $1 multiply by -1 | 1 | -1 * input |
reminder | reminder of first / secound | 2 | % |
command | definition | args no | js equivalent |
---|---|---|---|
floor | floor the number | 1 | Math.floor() |
pow | power of $1 raised to $2 | 2 | Math.pow() |
random | random number between 0 & 1 | 0 | Math.random() |
round | round the number | 1 | Math.round() |
command | definition | args no | js equivalent |
---|---|---|---|
boolean | change to boolean | 1 | Boolean() |
eq | equal to | 2 | == |
ge | greater than or equal | 2 | >= |
gt | greater than | 2 | > |
le | less than or equal | 2 | <= |
lt | less than | 2 | < |
not | not operator | 1 | ! |
ternary | ternary operator | 3 | $1 ? $2 : $3 |
Number include integer and floats
basically string without spaces and quotes
log word
NOTE word type is not supported by the compiler. using word is not recommended
boolean as usual
null as usual fun fact, function return null when return statement is not mentioned
undefined as usual;
refrence types have pointers that point to a js object, array, string. to see the pointer
log | new Array
# output -> %array%@1 : []
%array%@1
is example for a pointer
use the new command to create a array
set arr | new Array
# example
log | new Array 1 2 'element'
output -> [1,2,'element']
array commands take array as first argument
command | definition | args no | js equivalent |
---|---|---|---|
pop | pop last element | 1 | .pop() |
shift | pop first element | 1 | .shift() |
indexof | get index of element | 2 | .indexOf() |
length | length of array | 1 | .length |
reverse | reverse the array | 1 | .reverse() |
last | last element of array | 1 | arr[arr.length-1] |
push | push $1 to end of array | 2 | .push() |
unshift | push $1 to start of array | 2 | .unshift() |
includes | check if includes $1 | 2 | .includes() |
use the new command to create a array
set obj | new Object
object command takes target object as argument
command | definition | args no | js equivalent |
---|
single quotes ' '
are used to declare string
log 'this is a string'
string command takes target string as first argument
command | definition | args no | js equivalent |
---|---|---|---|
includes | check for search string | 2 | .includes() |
indexof | get index of string | 2 | .indexOf() |
"do this" or "do that" based on some condition.
if statements as usual
if <boolean>
# do something
elseif <boolean>
# do something
else
# do something
learn more about Logical Operators
example
if | eq $n 0
log 'equal to 0'
elseif | lt $n 0
log 'less than 0'
else
log 'something else'
switch case as usual.
NOTE pipescript interpreter support multiple default blocks at diffrent levels but the compiler doesnot. the compiler collects all default blocks and puts all of them in single default block at the end of switch block
switch <input>
case <value>
# do something
# break to stop here
case <value>
# do something
# break to stop here
default
# do something
learn more about Arithmetic commands
example
set n 10
switch $n
case 10
log 10
break
case | add 1 1
log 1
default
log 'default'
learn more about Logical Operators
while loop as usual
while <condition>
# do something
# break to stop
example
set n 0
while | ge 10 $n
set n | add $n 1
log $n
loop for certain times
loop <number>
# do something
# break to stop
example
loop 10
log 'still looping'
loop through items in something iterable ( arrays, objects, string)
foreach <var> <something iterable>
# do something
# break to stop
example
set array | new Array
foreach $value $array
log $value