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.

You will form groups of two and three to peer review each others’ work. Everyone is responsible to be the primary reviewer for exactly one classmate. In order to receive credit, your primary reviewer needs to sign off on your work. (Remember to still turn in your work in progress, even if it has not yet been reviewed or you know it doesn’t yet meet the requirements, in order to earn the right to resubmit in another week!)

Looking ahead, for next week’s lab your instructors will select a few of the clearest 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 spec.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.

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 spec.yml with a name you choose for your programming language.

There is nothing else really to turn in for this part. But you should be sketching out ideas, writing small programs, starting to figure out what works and what doesn’t, as you narrow in on how your language will look and work.

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.

I am not going to tell you exactly what your program should do. It should exercise all of the features of your language, and sort of “stretch” the limits a bit to demonstrate what your language can do.

Your program doesn’t necessarily need to be super long, but it should be long enough to hit most of the conceivable ways of combining the different constructs in your language.

Think of it this way: if someone wrote an interpreter for your language, and then they ran your code and it worked as intended, you would be pretty convinced that their interpreter is correct.

And remember that someone will look at this code without knowing anything about how your language works. It needs to be very well commented, using the comment syntax that you come up with!

REQUIREMENTS

Fill in the complete source code (along with comments) under the example_program field in spec.yml

Come up with at least two input/output test cases, representing sample input that could be entered at the console when your program is run, and the expected output that would be printed by your program as a result.

Fill these in under example_input_1, example_output_1, etc.

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.

For example, to describe simple string literals in C++, we might write something like

An ordinary character is any single character other than newline,
double quote ", or backslash \.

An escape sequence is a backslash \ followed by any single
character.

A string literal is a double-quote character ", followed by
a sequence of ordinary characters and escape sequences, followed by
another double quote character.

Notice how carefully this is written to try and cover every possible case! Of course your language will work differently than this, but this is the kind of precision we want.

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 spec.yml file.

Your spec must:

Tasks 4 and 5: Peer Review

Make a group (circle) with two or three classmates, where you will each act as the official “final reviewer” of one other person’s spec.

Reviewer guidelines

Reviewee guidelines

REQUIREMENTS

Fill in the following fields in your spec.yml: