Skip to content
Shylie edited this page Apr 3, 2020 · 2 revisions

Syntax

And other stuff, like examples.


Literals

A literal pushes that literal value to the stack. Simple.

Integer

A digit followed by 0 or more digits (0-9), optionally preceded by a negative sign (-).

  • 1
  • 3
  • -2

Float

A digit followed by 0 or more digits (0-9), followed by a period (.), followed by 1 or more digits (0-9), optionally preceded by a negative sign (-).

  • 1.0
  • -2.9
  • 3.1415927

String

A double-quote (") followed by text, followed by another double-quote ("). Don't forget to end it!

  • "this is a string"
  • "also a string"
  • "third example text"

Boolean

true (true) or false (false). Capitalization matters.

  • true
  • false

Variables

To store state, or something.

Declaration

Makes the variable usable. Undeclared variables throw a runtime error if anything else is done with them.

A variable name (not a keyword or a literal, can include _ ) followed by two periods (..). Capitalization still matters.

  • var..
  • other_variable..
  • example_text..

Deletion

Makes the variable not usable, as if it had not been declared.

A variable name (not a keyword or a literal, can include _ ) followed by two tildes (~~). Capitalization still matters. The language you're writing in hasn't changed.

  • var~~
  • other_variable~~
  • example_text~~

Store

Pops the top value of the stack and stores the value in the variable for later use. Make sure to declare the variable before doing this!

-> followed by a variable name.

  • ->var
  • ->other_variable
  • ->example_text

Load

Pushes the value stored in the variable onto the stack. Make sure to assign something to the variable before doing this!

<- followed by a variable name.

  • <-var
  • <-other_variable
  • <-example_text

Do-Loop

A special type of variable declaration that makes a loop from low number to high number by increment of one. Stores the current value in the declared variable.

Expression resulting in the high number; Expression resulting in the low number; var..; do <code> loop

  • 5 0 i.. do <code> loop loops from i=0 to i=4, running <code> 5 times.
  • 0 10 i.. do <code> loop doesn't loop. high value first, running <code> no times.
  • 10 5 i.. do <code> loop loops from i=5 to i=9, running <code> 5 times.

Functions, If-Else-EndIf & While-Loop

More cool stuff, like recursion.

While-Loop

Loops while a statement grouping results in true on the top of the stack.

while <while loop condition> do <code> loop

  • while true do <code> loop runs forever. true is a literal.
  • while false do <code> loop doesn't run. false isn't true.
  • while 0 0 eq do <code> loop runs forever because 0 is always equal to 0. This example is just to demonstrate multiple statements in the condition.

Function Header

Ends the main program definition or the previous function definition and starts defining the new function.

: followed by a valid identifier.

  • :foo
  • :bar

Function Call

Calls a function.

@ followed by a valid identifier. Make sure to actually define it though!

  • @foo
  • @bar

If-Else-EndIf

Conditionally runs code.

bool value on stack; if; <code> else <code> endif

  • <val> if "value is true" else "value is false" endif println