# SI413 Unit 2 Languages, Fall 2026 language_name: SupScript notes_from_prof: | Language designed by Khatija Ahmed and reviewed by Audrey Shu. This is a wrestling-themed language. One of the interesting things about how the grammar is written is that string and boolean expressions are completely separated in the grammar, meaning that the parser actually does type checking for us completely! example_program: | rest Start of wrestling program wrestle suplet @order SHOT; wrestle suplet @label SPRAWL suplet @order GUT { salad}; wrestle bumplet @rushhour B; wrestle bumplet @manager R; wrestle bumplet @weird OT suplet @label TIEUP {sandwich} MATCH {mustard} DEC bumplet @manager DEC R; wrestle TD {eat up: [} TIEUP suplet @label TIEUP {]}; wrestle suplet @status {hot: } TIEUP SWITCH (OT bumplet @rushhour) DEC bumplet @weird; wrestle TD suplet @status; example_input_1: | ceasar salad example_output_1: | eat up: [rasaec] hot: yes example_input_2: | pasta example_output_2: | eat up: [atsap] hot: no tokens: | PROG: wrestle ignore: rest [^\n]* ignore: \s SHOT: SHOT TAKEDOWN: TD TIEUP: TIEUP DECISION: DEC OVERTURN: OT BLUE: B RED: R SWITCH: SWITCH MATCH: MATCH GUT: GUT SPRAWL: SPRAWL STRVAR: suplet BOOLVAR: bumplet VARNAME: @[A-Za-z]+ STRLIT: \{([^}]|\}\})*\} ENDLINE: ; LPAR: \( RPAR: \) grammar: | parser grammar SupScript; tokens {PROG, SHOT, TAKEDOWN, TIEUP, DECISION, OVERTURN, BLUE, RED, SWITCH, SPRAWL, MATCH, GUT, STRVAR, BOOLVAR, VARNAME, STRLIT, ENDLINE, LPAR, RPAR} program : statement | program statement ; statement : PROG varassign ENDLINE | PROG TAKEDOWN strexpr ENDLINE ; varassign : STRVAR VARNAME strexpr | BOOLVAR VARNAME boolexpr ; strexpr : LPAR strexpr RPAR | SHOT | STRLIT | STRVAR VARNAME | strexpr GUT strexpr | strexpr TIEUP strexpr | SWITCH boolexpr | SPRAWL strexpr ; boolexpr : LPAR boolexpr RPAR | BLUE | RED | OVERTURN boolexpr | boolexpr DECISION boolexpr | strexpr MATCH strexpr | BOOLVAR VARNAME ; semantics: | rest is a token indicating a comment line. wrestle is a token indicating a program line to be tokenized and processed by the parser. Anything between {} is a string literal. All variables and operators and string literals are space-separated with the exception of the ';' indicating EOL Order of operations is left to right for all operators The program executes in statement order. A sequence of one or more expressions make up a program. Basic Cmds SHOT is the input command. It can act as a placeholder for when to read from stdin (Ex. wrestle TD SHOT;) or store input within a variable (Ex. wrestle suplet @variable SHOT;). TD, short for takedown, is the output command. The expression after TD is to be printed to stdout. TIEUP is the concatenation operator for concatenating the string expression that comes after the cmd to the string expression that comes before the cmd. SPRAWL is the reverse cmd. The string expression after SPRAWL is reversed. String literals are delimited with {}. To put a } inside a string literal, write two }}'s in a row. Boolean DEC, short for decision, is the OR operator for boolean logic. DEC takes two boolean inputs and ORs them to produce the boolean output. OT, short for overturn, is the NOT operator for boolean logic. OT takes one boolean input and NOTs it to produce the boolean output. B indicates True for boolean logic. R indicates False for boolean logic. Print boolean values using wrestle TD boolean_value Functions SWITCH is the function that takes some boolean value and converts it into a string value. MATCH checks if a comes before b in lexicographic order where a is the string before MATCH and b is the string after MATCH. If yes, output returns boolean value True. Else, boolean value False is returned. GUT returns the substring of a from starting at the beginning and going up to the first occurrence of b where a is the string before GUT and b is the string after GUT. Variables There are two types of variables identified by a keyword before the variable name, type string and type boolean. Type string variables are identified by keyword suplet. Type boolean variables are identified by keyword bumplet. Variables are declared and assigned by this arrangement -> wrestle keyword var_name value. Variables may be reassigned in the same way they are declared and assigned. Reference a variable -> keyword var_name.