# SI413 Fall 2025 Unit 1 Labs language_name: rds notes_from_prof: | Language designed by Brendan Lewis and reviewed by Evan Lee, who want you to know that rds stands for Rolling Down the Stairs. This is a "postfix" language where the operations come after the arguments. Look up "reverse Polish notation" for a similar idea using numbers. Think about how your interpreter can work with a single stack, where each operation does something with the one or two strings on top of the stack. example_program: | ~ Prints a string literal, then reads a string and prints it, ~ then concatenates a literal to another input and prints that, ~ then reverses a string literal and prints it /str1/ p i p /OOO / i ~Check out this awesome in-line comment~ ss p /CHANGE_STRING/ r p ~ The spacing is up to the programmer. /hot//dog/rissssp example_input_1: | Hello World YUM example_output_1: | str1 Hello OOO World GNIRTS_EGNAHC hotgodYUM example_input_2: | Go Lions beef example_output_2: | str1 Go OOO Lions GNIRTS_EGNAHC hotgodbeef language_syntax: | A program consists of a sequence of statements. Statements: Print: EXPR p (where EXPR is any expression as defined below) Expressions: String literal: /STRING/ An ordinary character is any single character other than forward slash / or backslash \. An escape sequence is backslash \ followed by any single character. A string literal is a forward slash / followed by a sequence of ordinary character or escape sequences, followed by a forward slash /. Concatenation: EXPR EXPR ss Reversal: EXPR r Input: i Comments: A comment starts with a ~ (not inside a string literal), and extends until the next ~, or until the end of the line, whichever comes first. Whitespace and comments are ignored between any expressions and statements. language_semantics: | Print takes an expression and prints it to the terminal Within a string literal, ordinary characters are interpreted as themselves, and escape sequences are interpreted as the character after the backslash. Concatenate takes two expressions and combines them in left-to-right order. Reversal takes an expression, reverses it, and then returns the reversed string. Input reads a line of text from the terminal and returns it