CS 315
Project 1


Assigned: February 13, 2026
Due: February 26, 2026, 23:59

Design of a Programming Language for Processing Boolean Data and Its Lexical Analyzer

This semester’s projects focus on the design of a new programming language that is limited to Boolean data types. This newly designed language will be similar to imperative languages. The main difference is that the language is restricted to Boolean data and aggregate structures built from Boolean values. String constants can be used in output operations. The first part of the project is about the design of the language and the implementation of its lexical analyzer.

Part A - Language Design (30 points)

First, you will give a name to your language and design its syntax. Note that the best way to hand in your design is with its grammar in the BNF (not EBNF) form, followed by a description of each language component. The following is a list of features that are required in your language:

You are encouraged to use your imagination to extend the list given above.

Discuss any other features of your language that you think are important.

Do not panic! You will have a chance to do minor revisions to your syntax design for Project 2 (later in the semester). Language designs are almost never exactly right in the first iteration. Just try your best to make it as readable, writable, and reliable as you can and keep your eyes open for what does and what does not work :)

Part B - Lexical Analyzer (40 points)

Having designed the language, you will design and implement a lexical analyzer for your language, using the lex tool available on all Unix-style systems. Your scanner should read its input stream and output a sequence of tokens corresponding to the lexemes you will define in your language. Since at this stage, you will not be able to connect the output to a parser, your scanner will print the names of the tokens on the screen. For instance, if we were designing a C-like syntax, for the input

if (p implies q) x gets false ; display "OK" x ;

the lexical analyzer should produce the output

IF LP IDENTIFIER OP IDENTIFIER RP IDENTIFIER ASSIGN CONST SC DISPLAY STR IDENTIFIER SC

Part C - Example Programs (30 points)

Finally, you will prepare three test programs of your choice that exercise all of the language constructs in your language, including the ones that you may have defined in addition to the required list given above. In addition to your test programs, write programs corresponding to the following two pieces of pseudocode:

Program 1:

1. prompt the user to enter the values of x, y, and z 
2. read the value of x, y, and z from the keyboard
3. if all of them are true ask the user to enter at least one false value 
4. keep reading new values until proper values are entered.
5. display the value of the expression (x implies y) and (not x doubly implies z)

Program 2:

1. define a function foo that has 3 parameters p, q, and r, 
   and displays its name, the names and the values of the parameters, then
   if r is true it returns the value of p implies (q or r), otherwise q doubly-implies r.
2. for each value of a in the list of {true, false} // assuming your data structure has such a syntax
2.1.   for each value of b in the list of {true, false}
2.1.1.    c gets foo(a, b, false)
2.1.2     display the values of a, b and c

Make sure your lex implementation correctly identifies all the tokens. The TA will test your lexical analyzer with these example programs along with other programs written in your language. Your grade will primarily depend on internal consistency between grammar, lexical analyzer, and example programs.

Do not panic! You are not required to write an interpreter or compiler for this language. Just write a few programs in the language you designed and make sure that the lexical analyzer produces the right sequence of tokens.

Groups

The project will be implemented in groups of two or three students. The members of the groups will be the same for this and the next project, in which you will write a parser for your propositional-calculus-based programming language. Note that all members of a group will get the same grade.

Submission

Resources

Good Luck! - Have fun.