README.md

January 29, 2016 · View on GitHub

#yasa

yasa is Yet Another Scripting Attrocity. Its main feature is that it takes the stangeness of assembly language, and combines it with the slowness of an interpreted language. Its the worst of both worlds, but I like it all the same.

This package contains:

  • The yasa interpreter, yasa

  • A brainfuck to yassa translator, fuck-yasa

  • A befunge to yasa translator, be-yasa

More information about each of these submodules can be found in their respective directories.

###Language Guide yasa was designed for simplicity of parsing. As such, it consists of only a few different grammars:

  • Commands, which are always three letters, and always come at the start of a line
  • Variables, which always start with $, and take the form $[a-z]?, with the bare $ as a temp variable.
  • Literals, which can always take the place of variables, even when it seems like the shouldn't be able to.
  • Comments, which always start with #, and can be either after the arguments of a line, or on a line alone.

In general, the language looks something like:

# Comment
cmd $a 43 $  # More Comment
end

All variables and literals are integers, which may be converted to/from ASCII characters for IO purposes.

In addition to the 27 $var's, the runtime also has access to an array of integers, initailized to 0, that may be accesed at random, or with stack operations.

####Commands: All commands are broken down into these 4 categories. The included yasa.cson file provides syntax highlighting as documented.

As a general rule, the modified variable in a given command will be the last in the argument list.

#####State Change (purple):

CommandNameArgumentsDescription
Copycpyaa bassigns bthevalueofb the value of a
Pushpus$apushes $a onto global array
Poppop$aassigns $a value popped from global array
Putputaa iassigns atoglobalarrayindexa to global array index i
Getgetaa iassigns value at global array index itoi to a
Addaddaa b $rassigns rthevaluer the value `a + $b`

#####Math (blue):

CommandNameArgumentsDescription
Incrementinc$aassigns value a+1toa + 1 to a
Decrementdec$aassigns vlaue a1toa -1 to a
Addaddaa b $rassigns rthevaluer the value `a + $b`
Subtractsubaa b $rassigns rthevaluer the value `a - $b`
Multiplymulaa b $rassigns rthevaluer the value `a * $b`
Dividedivaa b $rassigns rthevaluer the value `a / $b`
Modulomodaa b $rassigns rthevaluer the value `a % $b`
Randomrannn aassigns arandomvaluebetween0anda random value between 0 and n
Equaleqlaa b $rgives r1ifr 1 if `a = b`, else \0
Greatergrtaa b $rgives r1ifr 1 if `a > b`, else \0

#####Control Flow (teal):

CommandNameArgumentsDescription
Labellbl$acreates a mark for future/past mov's. must be positive
Movemova[a [b]go to label a,searchingfrombeginningonward,noopifa, searching from beginning onward, noop if b is 0
Ififf$acontinue if $a is not 0, else jump to next elif or end
Else Ifeif$acontinue if $a is not 0, else jump to next elif or end
Elseelsnonecontinue so long as previous iff's evaluated false
Endendnoneend iff block or program

#####Input/Output (green):

CommandNameArgumentsDescription
Integer Iniin$aassigns $a integer read from stdin
Charachter Incin$aassigns $a char read from stdin
Showsho$aoutputs $a as an integer
Displaydis$aoutputs $a as an ASCII char