hoverfly
hoverfly is an esoteric, Turing-complete and purely imperative language. The name may be translated, when speaking in another language.
hoverfly was intended to be a 'normal' language, however, since I am new to parsing, I downgraded the syntax to the lowest and it became an interesting concept to be an esoteric language. The name is coming from an insect, that mimics a bee. That's my favorite insect, btw. In the future I still plan to write a serious version of hoverfly. If that happens at some point, this article will still be about the fun version.
The language is almost ready, but the docs here are not very detailed. Please check out the guide/
folder in repository linked at the bottom for the full walkthrough.
types
# number
- integer^ number
- object& number
- stream! number
- flag
number
is an integer
integer
# value <=
- result in zero# value <= value
- result is told value
#0
is command pointer, can be used for jump
object
^ value <=
- empty object^ value <= ^ value => value
- pointing to another object
(in JS: global[value]=global[value][value]
)
^ value <= "string"
- well, a string
^ value => value => value <= value
- defining number value of object
(in JS: global[value][value][value] = value
)
# value <= ^ value => value
- getting value of object
stream
File descriptors, must already be defined before interpretation. Implementation-dependent. May be passed as argumnets, or whatelse. Originally only 0, 1 and 2 defined for stdio. Having only &? in the code must print all the streams and exit.
# value <= & value
- read bytewise& value <= # value
- write bytewise
flag
! number
Act as a predefined jump points. Values are put into the flags object before the interpreting. They can't be changed in runtime.
value
#0 <= #0 + 1
(in JS: global[0]=global[0]+1
)
Available operators: +, -, *, /, (, )
Division is made without a rest: 9 / 2
results in 4
0/0
produces 0
, (something else)/0
produces exception
import
Now, there are also imports allowed.
They must have following form:
<= source:path
for source:
base
- code gets imported related to the working directorylib
- code gets imported from lib/ folder in the root directory of hoverfly
path: will always be put a .fly
at the end.
An import reads all the code from provided file
and executes it. Numbers object is private, so any computations can be performed in numbers object without overwriting main file's numbers object. Arguments can be passed to the import file via objects object. Typically the ^0
object.
comments
Single line comments only, start with ::
examples
Hello world:
^1 <= "Hello World!\n" #1 <= 0 #2 <= ^1 => #1 &1 <= #2 #1 <= #1 + 1 #0 <= #0 - #2 / #2 * 4
Truth machine:
#0<=(49-&0)*3 &1<=49 #0<=0
Printing using lib:
^0 <= "Hoverfly is an insect <>" <= lib:io/puts
interpreter
Available in python: https://github.com/gXLg/hoverfly-eso