Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 1.51 KB

File metadata and controls

52 lines (44 loc) · 1.51 KB

hsilop Language

An interpreted (toy) language based on reverse polish notation (RPN).

Usage

You can compile a standalone interpreter by:

meson setup build
cd build
ninja

You can run it by

./hsilop

Language Quickstart

Here is how you might write some common expressions in hsilop

Traditional hsilop
1 + 2 1 2 +
1 + 2 * 3 1 2 3 * +
(1 + 2) * 3 1 2 + 3 *
a = 1 a 1 =
a = a + 1 a a 1 + =
if 1 + 2 == 3 then a = 1 1 2 + 3 == if a 1 = then
if 1 + 2 == 3 then a = 1 else a = 2 1 2 + 3 == if a 1 = then a 2 = else

Language Standard

hsilop is a dynamically typed language. Currently there are three types.

  • Int (0, -1, 1, 104, etc.)
  • Float (0.0, -1.0, 2.45, .40, etc.)
  • Bool (true, false)

Based on literal, type is automatically deduced.

You can do basic operations:

  • (Int|Float) (Int|Float) (+|-|*|/|==|!=|>|>=|<|<=)
  • Bool Bool (and|or)
    • Instead of and and or, you can use && and || respectively.
  • Bool not
    • You can use ! instead of not.

You can assign values to variable as well:

  • VariableName (Value Expression) =

You can do if statements by the following syntax:

  • Bool if Expression then
    • This is just an if statement. Note that Bool here is any expression outputting boolean value.
  • Bool if Expression then Expression else
    • This is an if-else statement. The first expression is evaluated if the condition (Bool) is true; otherwise, else statement is evaluated.