9.0.0.1

10 — A La JS🔗

LATE ADDITION

Partner Evaluation Due: Monday morning by 9am

As you may have noticed, your repos contain a file named log-Friday,-November-7th,-2025. It contains basic statistics about the commits to your repo.

Reflect on your pair programming effort and on your work with a colleague in general:
  • Did you contribute to this partnership in a responsible manner?

  • Did your partner contribute to this partnership in a responsible manner?

  • Do you want to continue this partnership?

Each individual should send me an email to the address listed on this web site, using the following format:

    Subject: partnership evaluation

    

    My name: Foo Bar

    My partner's name: Fumble Mumble

    My repo name: Adjective-Animal

    

    Our partnership is ...

    

The body of the message may otherwise be just a single sentence (e.g., "... the happiest ever") or several paragraphs with details (e.g., "From the very first minute of coding together .. And then ... can you imagine?"). What you want to say is completely up you, and it will stay between me and you.

If you have already sent me an email (because of this log), there is no need to send another one.

The partnership evaluation is worth 50 points.

END ADDITION

 

 

 

 

 

 

 

 

 

 

Due Thursday, 13 November 2025, 11:59:59pm

Purpose to build a model of a mixed-typed language, similar to JavaScript

This assignment is part of a mini-project about the pragmatics of mixed-typed programming languages like the TypeScript/JavaScript or Typed Racket/Racket combination.

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

  • the executables xjs as specified below;

  • the sub-directory 10/Tests/ with the required integration test

  • the sub-directory 10/Special/ with the required special test; and

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

The directory 10/ 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 Using your favorite programming language, you are to create a complete model of the Mixed language: its syntax and its JavaScript-like semantics. The Mixed language enables programmers to construct a software system that mixes typed and untyped modules.

ExampleGG is an Example whose Names also contain the following keywords: if0, while0, block, def, =, /, +, ==, class, method, isa, new, >, tmodule, module, timport, import.

See figure 28 for the BNF grammar of systems and import specifications in the Mixed language. For all other productions, consult the preceding milestones. A mixed system consists of typed and untyped modules, with the former importing from the latter and vice versa. The new keyword timport bridges the gap between typed modules that need services from untyped modules.

The typed modules and the body of a mixed system must satisfy typing constraints. Let's repeat this. The body of a Mixed system is typed, so treat it like a typed module. Accommodating the import of an untyped module into a typed one calls for one additional validity rule; see figure 29. The rule for type checking complete systems should be modified so it skips untyped modules.

The modules of a Mixed system are subject to three structural constraints:
  • A tmodule (and the system's typed body) must import modules via a timport specification.

  • A tmodule may not import the same module using two different Shapes.

  • A tmodule (and the system's typed body) may not import a tmodule using a timport specification.

  MixedSystem ::= (MixedModule^*

                   MixedImport^*

                   Declaration^*

                   Statement^*

                   Expression)

  

  MixedModule ::= (tmodule ModuleName MixedImport^* Class Shape)

                | (module ModuleName Import^* Class)

  

  MixedImport ::= (import ModuleName)

                | (timport ModuleName Shape)

Figure 28: The concrete syntax of types in the Type language

M is the name of mod in Modules

C is the name of the class defined in mod

    

[an import]

Modules, SClasses(timport M S) ⟹ SClasses [C : S]

    

Figure 29: Typing rules for imports in mixed systems the Mixed language

Plan The following is a concrete plan for building a model of Mixed:
  • Adapt the AST data representation from Typed to Mixed. Update your parser and type checker for Module accordingly.

  • Implement an additional pass that checks the validity of import specifications.

  • Consider modifying the rule for type checking systems from figure 20 so that untyped modules (module) are ignored. Your type checker needs to be modified accordingly.

  • Create a pass that throws away the types in tmodules and timports, turning them into modules and imports, respectively.

    I have deleted words from this item because striking out might have obfuscated its meaning.

    At that point the linker can take over and generate an ordinary Classes program that can be run on the existing CESK machine.

    Note Depending on your chosen implementation language and your choice of AST data representation, your linker might already work for Mixed ASTs or you might find it easy to adapt the linker so that it works this way.

  • Uncomment the cases of the CESK machine that you commented for 9 — Static Types. Stop! Why is this necessary?

The xjs program reads one ExampleGG from STDIN, constructs the AST, performs the validity checks, links the system into a complete program, runs the CESK machine, and writes one of the following strings to STDOUT: The outcomes are listed in the order in which they may occur for a given program.

  • "parser error" if the given ExampleGG is not an element of the Mixed grammar;

  • "duplicate module name" if in the well-formed Mixed system, at least two of the module definitions come with the same name;

  • "duplicate method, field, or parameter name" if in the well-formed Mixed system one class definition one method definition, or one Shape comes with (at least) two fields, methods, or parameters that have the same name;

  • "bad import" if in the well-formed Mixed system one of the validity constraints concerning imports into tmodules is violated;

  • "undeclared variable error" if in the well-formed Mixed system one of the variable references comes without declaration or one reference to a ClassName (in a statement or an expression) comes without a (possibly imported) class definition;

  • "type error" if in the well-formed Mixed system one of the typed pieces of code fails to satisfy one of the typing judgments;

  • a number n if the CESK machine produces a number n for the well-formed and valid Mixed system;

  • "object", if the CESK machine produces an object for the well-formed and valid Mixed system; or

  • "run-time error" if the CESK machine produces an error outcome for the well-formed and valid Mixed system.

Special Create the following systems in Mixed:
  • blatant, which (1) type checks and to which (2) the CESK semantics assigns an object, even though fact (1) predicts that its CESK semantics is a number.

  • insidious, which (1) type checks, (2) has a numeric CESK semantics, and (3) violates a type between a typed and an untyped module.

    That is, a value going from typed code to untyped code does not satisfy the specified type, which means that the type checker would flag a fully-typed version of this program.

Deliver these programs test cases in the folder 10/Special/ 0-*.ss and 1-*.ss, respectively.

Extra credit Reconstruct the programthese two programs in the JavaScript/TypeScript world. Deliver these extra-credit test cases in the folder 10/Special/ as blatant.js/blatant.ts and insidious.js/insidious.ts.

Testing Task Create 10 integration tests for xjs.

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.

Readings Pragmatics and Mixed-Typed Systems If you’d like to know more, take a look at the slightly expanded version [HTML only].