Skip to content

13. Language Tokens

Tom Dodd edited this page Dec 10, 2023 · 7 revisions

Below is a list of all fixed tokens in DSSL and their associated actions. The expected arguments are written in italics.

  • {: Denotes the start of a block.

  • }: Denotes the end of a block.

  • (: Pushes a range opening bracket.

  • ): Pushes a range closing bracket.

  • [: Pushes a list opening bracket.

  • ]: Pushes a list closing bracket.

  • (|: Pushes a set opening bracket.

  • |): Pushes a set closing bracket.

  • [|: Pushes a dictionary opening bracket.

  • |]: Pushes a dictionary closing bracket.

  • (module) include: Executes the file specified by the string or built-in module identifier and stores the contents of its root hierarchy to the current hierarchy.

  • (label module) import: Executes the file specified by the string or built-in module identifier and stores its root hierarchy to the sub-hierarchy specified by the label.

  • (arguments... string) native: Implementation-dependent keyword. This DSSL interpreter uses reflection to access the Java field or method specified by the string, which must be a fully qualified name. If a method is accessed, the elements preceding the string will be used as arguments, with the final argument being used as the instance if it is an instance method. DSSL will automatically convert between stack elements and native Java objects where possible.

  • (label value) def: Defines the variable specified by the label and initialises it to the value.

  • (label block) macro: Defines the executable macro specified by the label.

  • (label supers... block) class: Defines the class and stores its root hierarchy to the sub-hierarchy specified by the label. The ordering of the superclasses determines their priorities.

  • (label) deref: Pushes the variable, executes the macro or pushes the class associated with the label.

  • (label) delete: Deletes the variable, macro or class associated with the label.

  • (elem) new: Creates a new instance of the type defined by the element, calling its constructor if it exists.

  • null: Pushes the null element to the stack.

  • (elem) type: Pushes the class of the element.

  • (elem1 elem2) cast: Explicitly casts the first element to the type defined by the second element.

  • (elem1 elem2) is: Pushes a true boolean if the first element is an instance of the type defined by the second element, and a false boolean otherwise.

  • exch: Swaps the positions of the top two elements on the stack.

  • (number distance) roll: Cycles the specified number of elements on the top of the stack clockwise by the specified distance.

  • (elem) pop: Pops the element from the stack.

  • dup: Duplicates the top element on the stack.

  • stacksize: Pushes an integer equal to the total number of elements on the stack.

  • (int) stackindex: Pushes the element the number of positions back in the stack specified by the integer.

  • read: Pushes a string read from the implementation-defined IO (console input for this interpreter).

  • (elem) print: Prints the element to the implementation-defined IO (console output for this interpreter).

  • (elem) println: Prints the element as well as a newline.

  • (string) interpret: Executes the string as DSSL code.

  • (block) exec: Executes the block.

  • (bool block) if: Executes the block if the boolean is true.

  • (bool block1 block2) ifelse: Executes the first block if the boolean is true, and the second block otherwise.

  • (block) loop: Continually executes the block.

  • (int block) repeat: Repeatedly executes the block the number of times specified by the integer.

  • (iterable block) foreach: Executes the block for each element in the iterable, pushing it to the stack before each iteration.

  • continue: Jumps to the next iteration of the current loop.

  • break: Ends the current loop.

  • quit: Ends the program.

  • (label elem) =: Assigns the value of the element to the variable associated with the label.

  • (label) ++: Increments the value of the variable associated with the label.

  • (label) --: Decrements the value of the variable associated with the label.

  • (label elem) +=: Addition assignment.

  • (label elem) &=: AND assignment.

  • (label elem) |=: OR assignment.

  • (label elem) ^=: XOR assignment.

  • (label elem) -=: Subtraction assignment.

  • (label elem) ~=: Concatenation assignment.

  • (label elem) <<=: Left-shift assignment.

  • (label elem) >>=: Right-shift assignment.

  • (label elem) *=: Multiplication assignment.

  • (label elem) /=: Division assignment.

  • (label elem) %=: Remainder assignment.

  • (label elem) **=: Power assignment.

  • (label elem) //=: Integer division assignment.

  • (label elem) %%=: Modulo assignment.

  • (elem1 elem2) ==: Pushes a true boolean if the elements are equal, and a false boolean otherwise.

  • (elem1 elem2) !=: Pushes a true boolean if the elements are not equal, and a false boolean otherwise.

  • (elem1 elem2) <: Pushes a true boolean if the first element is less than the second element, and a false boolean otherwise.

  • (elem1 elem2) <=: Pushes a true boolean if the first element is less than or equal to the second element, and a false boolean otherwise.

  • (elem1 elem2) >: Pushes a true boolean if the first element is greater than the second element, and a false boolean otherwise.

  • (elem1 elem2) >=: Pushes a true boolean if the first element is greater than or equal to the second element, and a false boolean otherwise.

  • (elem1 elem2) +: Pushes the sum of the two elements.

  • (elem1 elem2) &: Pushes the AND value of the two elements.

  • (elem1 elem2) |: Pushes the OR value of the two elements.

  • (elem1 elem2) ^: Pushes the XOR value of the two elements.

  • (elem1 elem2) -: Pushes the subtraction of the second element from the first element.

  • (elem1 elem2) ~: Pushes the concatenation of the second element to the first element.

  • (elem1 elem2) <<: Pushes the value of the first element left-shifted by the second element.

  • (elem1 elem2) >>: Pushes the value of the first element right-shifted by the second element.

  • (elem1 elem2) *: Pushes the product of the two elements.

  • (elem1 elem2) /: Pushes the division of the first element by the second element.

  • (elem1 elem2) %: Pushes remainder of the division of the first element by the second element.

  • (elem1 elem2) **: Pushes the value of the first element to the power of the second element.

  • (elem1 elem2) //: Pushes the integer division of the first element by the second element.

  • (elem1 elem2) %%: Pushes the value of the first element modulo the second element.

  • (elem) !: Pushes the inverse of the element.

Clone this wiki locally