Skip to content

Latest commit

 

History

History
93 lines (60 loc) · 2.89 KB

File metadata and controls

93 lines (60 loc) · 2.89 KB

tscript

Description: These files implement an interpreter for the Tscript language. Tscript is a subset of ECMAScript 5.1 defined at UNH for use in the Compiler Design course (CS712/CS812). The interpreter is implemented in Java and uses the ANTLR (version 4) parser generator.

The Tscript interpreter is known as "ts".

This initial version of the interpreter only supports the following features:

  • "var" statement
    • but only declares a single identifier and without initialization
  • expression statement
  • print statement
    • not actually part of ECMAScript 5.1
    • for use until objects and functions are supported
  • expressions
    • assignment
    • add and multiply
    • identifier
    • numeric literal
    • parenthesized subexpressions

The system files are organized into three directories:

	bin - contains bash scripts for building the system.

	src - contains the source code for the interpreter

        src/ts - main class for the interpreter
        src/ts/parser - parser
        src/ts/support - support classes for executing Tscript programs
        src/ts/tree - classes that define the AST (abstract syntax tree)
        src/ts/tree/visit - classes to traverse the AST (uses the visitor pattern)

	scripts - contains templates for the scripts used to run the interpreter

	test - contains test programs for the interpreter

Project Setup

To build and run the system:

  1. Copy the tar file containing the system to your account:

    cp -r ~cs712/public/tscript.tar . 
  2. Un-tar the files:

    tar xvf tscript.tar
  3. Install and build the system:

<pre>cd tscript/bin
bash install.sh </pre>

 This will create a directory, tscript/build, to contain the files
 generated by the build.

 Once an install is done, then you can re-build the system by cd-ing
 to tscript/bin and then:

 <pre>bash build.sh</pre>
  1. While in tscript/bin, test the build by running the regression test suite:

    bash regression.sh

    If all is well, nothing should be printed.

  2. You run the interpreter by executing tscript/build/bin/ts. You can make a bash alias for this script, add its directory to your bash PATH, or even copy the script to where you want to use it.

    The script takes a few optional parameters followed by a single Tscript source file. (See tscript/src/ts/Main.java for a discussion of the parameters.) Therefore to execute a Tscript program:

    ts file.ts

    You must use the "ts" file extension for Tscript programs.

    You can run the interpreter from within the Java debuggger (jdb):

    tsdb file.ts
  3. The build procedure runs javadoc to generate HTML files to document the system. These files are rooted in tscript/build/html.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.