PASM has a simple syntax. Each statement stands on its own line. Statements begin with a Parrot instruction code (commonly referred to as an “opcode”). The arguments follow, separated by commas:
If the opcode returns a result, it is stored in the first argument. Sometimes the first register is both a source value and the destination of the operation. The arguments are either registers or constants, though only source arguments can be constants:
LABEL: print "The answer is: " print 42 print "\n" end # halt the interpreter
are marked with the hash sign (
#) and continue to
the end of the line. Any line can start with a label definition like
LABEL:, but label definitions can also stand
on their own line.
Integer constants are signed integers.
constants can have a positive (
+) or negative
-) sign in front. Binary integers are preceded by
0B, and hexadecimal
integers are preceded by
print 42 # integer constant print -0b101 # binary integer constant with sign print 0Xdeadbeef # hex integer constant
Floating-point constants can also be positive or negative. Scientific
notation provides an exponent, marked with
E (the sign of the exponent is optional):
print 3.14159 # floating point constant print -1.23e+45 # in scientific notation
String constants are wrapped in single or double quotation marks. Quotation marks and other nonprintable characters inside the string have to be escaped by a backslash. ...