2021-03-29 12:45:37 +13:00
|
|
|
# 159.341 Assignment 1 - String Interpreter [![Build status](https://ci.software.kauripeak.co.nz/api/projects/status/44sgyt4dadc2il99?svg=true)](https://ci.software.kauripeak.co.nz/project/AppVeyor/159-341-assignment-1)
|
|
|
|
## A basic interpreter for a simple programming language.
|
2021-03-15 15:07:09 +13:00
|
|
|
|
2021-03-29 12:45:37 +13:00
|
|
|
There is only one implicit type definition - strings.
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
This program is written in C# (.NET Core 3.0*) and specifically avoids the use of the `regex` class and the
|
|
|
|
|
|
|
|
```cs
|
|
|
|
string.split()
|
|
|
|
```
|
|
|
|
method to show an understanding of the implementation.
|
|
|
|
|
|
|
|
\* *.NET Core 3.0 **should** be supported on the lab machines*
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
The application accepts piped input streams via `StreamReader` and piped input via `type <file> | <application>`
|
|
|
|
|
|
|
|
There are preconfigured build options that will automatically pipe the example files:
|
|
|
|
|
|
|
|
[![VS Build Configuration](https://git.software.kauripeak.co.nz/content/upload/159.341/159-341-assignment-1-build-configuration.png)](https://git.software.kauripeak.co.nz/content/upload/159.341/159-341-assignment-1-build-configuration.png)
|
|
|
|
|
|
|
|
These examples are automatically copied to the output directory at build.
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
This stream is navigated character-by-character (not byte-by-byte)
|
|
|
|
|
|
|
|
|
|
|
|
Example usage:
|
|
|
|
```py
|
|
|
|
set somevar "NewValue";
|
|
|
|
set othervar somevar + SPACE + ";";
|
|
|
|
list;
|
|
|
|
exit;
|
|
|
|
```
|
|
|
|
Would output:
|
|
|
|
```
|
|
|
|
┌─────────────┬──────────────────────┬─────────┐
|
|
|
|
│ Symbol │ Value │ Flags │
|
|
|
|
├─────────────┼──────────────────────┼─────────┤
|
|
|
|
│somevar │NewValue │00000000 │
|
|
|
|
├─────────────┼──────────────────────┼─────────┤
|
|
|
|
│othervar │NewValue ; │00000000 │
|
|
|
|
└─────────────┴──────────────────────┴─────────┘
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Additional Parameters | Behaviours
|
|
|
|
* The option `list;` may be augmented with the parameter `all` (i.e. `list all;`), which will additionally list the constant/global symbols.
|
|
|
|
* It is possible to save the command list on `exit;`; this is prompted and guided.
|
2021-03-29 14:02:25 +13:00
|
|
|
* The program instances its operation; at `exit;` you will have the option to load a new file or write a new program.
|
|
|
|
* A quick help option is available by using the command `h` (semi-colon not required).
|
2021-03-29 16:32:58 +13:00
|
|
|
|
|
|
|
**NB:**
|
|
|
|
* A double quote can be inserted into the literal by using a backslash immediately beforehand (i.e. `\"`)
|
|
|
|
```cs
|
|
|
|
set someVar "this literal \" has a value";
|
|
|
|
```
|
|
|
|
prints
|
|
|
|
|
|
|
|
`this literal " has a value`
|