Grades and deadlines

Unit 1 Labs Overview (next three weeks)

You will design and write careful specifications for a new programming language. As of now, and for the next three weeks, your language will only support string literals, string input/output, and a few string operations.

For this week’s lab, you will work creatively to design a new language that provides the features (details below). You will turn in a careful spec of your language, and an example program written in that language which demonstrates all of the features.

Unlike code, language specs are mostly written for other humans. You will do peer review of each other’s work to help make sure your spec makes sense to someone else, and to give you all an opportunity to see a wider variety of different approaches. At a minimum, everyone is responsible to review at least one classmate’s spec, and to have their spec reviewed by at least one classmate.

Looking ahead, for next week’s lab your instructors will select a few of the clearest and most interesting language specifications from this week. You will all choose one of those select-few languages, write an example program in that language, and then write code for an interpreter for that language. A complete, working, and well tested interpreter will be earn 10 points.

In two weeks, you will continue and write a compiler for that same language to LLVM IR code. A complete, working compiler will earn 3 points.

In total, up to 20 points of your total lab grade are available over the next three weeks.

YAML file to complete

Download the file lab1.1.yml.

As you complete your work for this part, you will fill in and eventually submit this file.

The parts you need to fill in are written in all caps like BLAH BLAH. Replace any of that with your actual responses.

The file format should be mostly self-explanatory. Just be careful about the indentation. Generally, when your response goes over multiple lines, you have to maintain the same level of indentation (or greater) to keep that response together.

(If you care, you can read the full YAML language specification here: https://yaml.org/spec/1.2.2/)

Task 1: Language Design

Ground rules

Source code for your language should be plain-text, using the characters on your keyboard. Specifically, the 95 ASCII printable characters, space, and newline. (So no weird control characters, tabs, emojis, accents, etc.)

Required capabilities

Your language needs to support:

REQUIREMENTS

Fill in the language_name field in lab1.1.yml with a name you choose for your programming language.

There is nothing else really to turn in for this part — you are still brainstorming before you get into the details. But before you move on to the next part, you should have a pretty good idea of what your language looks like.

To receive credit for this lab, your language needs to:

Tips

If you are feeling stuck for ideas, feel free to peruse some of these sources of inspiration.

(Note, I was starting to make links for all of these so you can read more, but often the official documentation is too technical for a casual browse, and the many unofficial tutorials are on random websites that aren’t of high quality. You are genuinely better off asking an AI chatbot to explain these to you and give you some examples.)

Task 2: Example program

Once you have a good “feel” for how you want your language to work, test it out by writing an example program in your language.

Your program should first prompt for a name, then say hello to that name. Then it should prompt for a noun and a verb, read in two strings, reverse the first string, and then concatenate it with is not and the second string.

Specifically, it should work exactly the same as this Ruby program:

puts "What is your name?"
puts "Hello #{gets.chomp}"
puts "Enter a noun and an adjective:"
puts "#{gets.chomp.reverse} is not #{gets.chomp}"

(Note, you probably haven’t seen the Ruby programming language before, but I bet you can still see easily how this program works! You can try copy-pasting this code to a file like stringex.rb and then running it from the command line with ruby stringex.rb)

Here is a Python version of the same exact program:

print("What is your name?")
name = input()
print("Hello " + name)
print("Enter a noun and an adjective:")
noun = input()
adj = input()
revnoun = ''.join(reversed(noun))
print(revnoun + " is not " + adj)

Note that the Python version is a little more verbose and the method to reverse a string is a little more complicated, but it is functionally equivalent to the Ruby program above.

(Also note that your program will not be able to be just like the Python one, since your language probably doesn’t support variables!)

For either version — or for the version you write in your language — if you enter these three strings for the prompts:

Walter
drawer
open

then the program should print

What is your name?
Hello Walter
Enter a noun and an adjective:
reward is not open

REQUIREMENTS

Fill in the complete source code (along with comments) under the example_program field in your YAML file.

Your example program must:

Task 3: Language specification

Syntax specification

Start by clearly and unambiguously defining the syntax of allowable programs in your language. You are not yet saying what anything means or how it should be executed, just what any possible program could look like.

You might want to look at the COOLBOOL language from your homework to see an example of a (very simple!) language spec.

You might want to think about organizing things into statements and expressions, and be clear when an expression can be nested inside another expression, or inside a statement.

Semantics specification

Now describe the precise meaning of the syntax you just laid out.

For each kind of expression, you should explain what value that expression produces. (Remember, every value in this language has the same type, strings.)

And for each kind of statement, you should explain exactly what that statement is supposed to do when executed.

REQUIREMENTS

Fill in the language syntax and semantics under language_syntax and language_semantics in the lab1.1.yml file.

Your spec must:

Task 4: Peer Review

Everyone is expected to act as a reviewer for at least one classmate’s submission, and everyone must have a classmate carefully review and sign off on their submission before it can be considered complete.

(Note, you can still turn in your work if it’s incomplete and not yet reviewed! That can certainly count as “significant progress” to get a chance to resubmit with a new deadline.)

Reviewer guidelines

Reviewee guidelines

REQUIREMENTS

Fill in the following fields in your lab1.1.yml: