# SI413 Unit 2 Languages, Fall 2026 language_name: Waverunner notes_from_prof: | Language designed by Brennan McElfresh and reviewed by Joey Seliskar. This language looks absolutely wild, but don't let the syntax fool you! It's really just about maintaining a "buffer", which is either a long concatenated string, or a single boolean value. By maintaining that buffer as the program runs, it makes each of the actual operations pretty simple. This is the most creative-looking language we have seen so far. But once you wrap your head around it, I think you'll find it's not any more difficult to implement. example_program: | | > || Adds input to the buffer || | = order || Assigns the input value to the variable order, flushes the buffer || | : order || Loads order back onto the buffer || | % [ salad] || Chops " salad" off of the buffer || | ~ || Reverses the buffer || | = label || Assigns the buffer value to the variable label, flushes the buffer || | +~> #T || Adds true to the buffer || | = rushhour || Assigns true to the variable rushhour, flushes the buffer || | +~> #F || Adds false to the buffer || | = manager || Assigns false to the variable manager, flushes the buffer || | : label || Loads label onto the buffer || | +-> [sandwich] || Concatenates the value of label with "sandwich" || | ? [mustard] || String less than operator with the current buffer < "mustard", adds either true or false to the buffer || | ! || NOT the buffer || | $ manager || OR the buffer with the value of manager || | $ #F || OR false || | = weird || Assigns to the variable weird, flushes the buffer || | <- [eat up: ^[] || Prints "eat up: [", have to escape the bracket, the "-" next to the "<" indicates no new line || | <- label || Prints out the value of label, with no new line || | < [^]] || Prints the right bracket, have to escape again || | +-> [hot: ] || Adds "hot: " to the buffer || | = status || Assigns "hot: " to the variable status, flushes || | ! rushhour || Adds NOT rushhour to the buffer || | $ weird || OR buffer with the value of weird || | @ || bool2str operator for whats on the buffer || | = temp || Assisns temp the value of the result of the bool2str, flushes || | : status || Adds the value of status to the buffer || | : temp || Concatenates the temp with status || | = status || Assigns status this concatenated value || | < status || Prints status || | - example_input_1: | hamburger salad example_output_1: | eat up: [regrubmah] hot: yes example_input_2: | apple salad example_output_2: | eat up: [ellpa] hot: no tokens: | INPUT: > LOAD: : ASSIGN: = CONCAT: \+-> BOOL: \+~> CHOP: % REV: ~ COMP_LT: \? NOT: ! OR: \$ PRINT_NO_NL: <- PRINT: < BOOL2STR: @ BOOL_LIT: #T|#F DELIM: \| VAR: [a-zA-Z][a-zA-Z0-9_]* STR_LIT: \[(\^\[|\^\]|\^\^|[^\]^])*\] END_PROG: - ignore: [ \t\n]+|\|\|[^\n]*?\|\| grammar: | parser grammar Grammar; tokens { INPUT, LOAD, ASSIGN, CONCAT, BOOL, CHOP, REV, COMP_LT, NOT, OR, PRINT_NO_NL, PRINT, BOOL2STR, BOOL_LIT, DELIM, VAR, STR_LIT, END_PROG} prog : cmd EOF ; cmd : cmd DELIM op | DELIM op ; op : INPUT | LOAD VAR | ASSIGN VAR | CONCAT STR_LIT | BOOL varOrBool | CHOP printable | REV | COMP_LT printable | NOT | NOT VAR | OR varOrBool | PRINT_NO_NL | PRINT_NO_NL printable | PRINT | PRINT printable | BOOL2STR | END_PROG ; printable : VAR | STR_LIT ; varOrBool : VAR | BOOL_LIT ; semantics: | - "|": maintains sequential execution down the spine, has no effect on the buffer state, acts as a delimeter - "+->": concatenates strings onto the end of the buffer - ">": reads input from the terminal and appends the resuls to the buffer - "~": reverses the entire buffer - "<": writes the contents of the buffer to standard output and clears the buffer to "" - "< [string]": appends the string literal to the buffer and prints out in a single line, equivalent to the two lines +-> and <, still clears the buffer - "<-": same as "<" just no new line - "<- [string]": same as "< [string]" just no new line - "-": terminates that block of the wave and clears the buffer without printing - "+~>": adds a boolean literal to the buffer, cannot have both a string and a boolean literal on the buffer at the same time - "#T/#F": boolean literals must be led by a # followed by a capital T or F corresponding to true and false respectively - "=" var: assigns the value on the buffer to the given variable, and clears the buffer. Variables must start with a letter or an underscore, then they may include numbers after the first character - ":" var: loads the given variable and adds it onto the buffer. The variable must have been declared prior to this statement. - "%" [string]: string chop operator, chops the string given from the string currently on the buffer - "% var": also works if the variable is a string variable - "!": not operator, not's whatever is on the buffer - "$ #T/#F": or operator, can be used to or what's on the buffer with a given bool - "$ var": or can also be used with a variable, but the variable has to be of bool value - "?" [string]: String less than operator, compares if the current buffer is less than the string given, adds the result of the evaluation to the buffer (#T/#F) - "? var": also works if the var is a string variable - "@": bool2str operator, changes the bool that is on the buffer to a string (#T becomes yes, #F becomes no)