8.18.0.13

1 — Start Me Up🔗

Due Thursday, 11 September 2026, 11:59:59pm

Purpose The assignment has five learning objectives:
  1. to create a program that can be run on the command line, reads from STDIN, and writes to STDOUT.

  2. to formulate one integration test as specified in the testing task below;

  3. to get to know the S-expression (see S-expression Readers) library of your chosen programming language;

  4. to study a data representation for a self-referential form of information representation according to the principles of Fundamentals I or II; and

  5. to implement a simple piece of functionality (functions, methods) for this data representation according to the principles of Fundamentals I or II.

Delivery Deliver your solutions in a directory called 1 within your assigned GitHub repository. The directory should contain the following items:

  • the executables xcount as specified below;

  • the sub-directory 1/Tests/ with the required integration test; and

  • an optional sub-directory called 1/Other/ for all auxiliary files.

The directory 1/ may also contain a Makefile (see Make) in case you need us to build your executable. An executable should not be checked into a repository.

Programming Task Someone has created files that contain information of this shape: Hint In this context Example plays the role of information and your chosen language represents this information as data, as determined by the S-expression library.

An Example is one of:
– a Name
– a Number
– a sequence of space-separated Examples wrapped in ( and ).

A Name is a non-empty sequence of at most 20 (US alphabetical) letters.

A Number is a decimal number (contains a decimal point) between -1000.0 and +1000.0, with at most one digit to the right of the decimal point.

Nothing else is an Example.

The xcount program reads one Example from STDIN, determines the number of Names in the given S-expression, and writes this count to STDOUT as a String (including the quotes).

You may assume that the input is always an instance of Example.

Testing Task Create one integration test for xcount.

A test always consists of inputs, expected output, and an automated procedure for comparing the actual output with the expected one. — For this course, an integration test consists of a pair of files: n-in.ss, the input file, and n-out.ss, the expected output file, where n is an integer between 0 and the requested number of tests (exclusive). The comparison procedure is (string or numeric) equality on the content of the output file and the actual output. — Constraint No test file may exceed the size limit of 5Kb.

Ensure that xcount succeeds on your test on the Linux delivery machines as follows:

    $ cat Tests/0-in.ss

    aName

    $ cat Tests/0-out.ss

    "1"

    $ ./xcount < TestsCount/0-in.ss | diff - TestsCount/0-out.ss

This will produce no output if the test succeeds; otherwise it will show the difference.

Readings Language and Pragmatics