Added information to the readme
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

Added examples and automatic copying of them to the output directory, for launching in the example profiles
This commit is contained in:
Brychan Dempsey 2021-03-29 12:45:37 +13:00
parent 71ec98967d
commit 093b4455a6
8 changed files with 140 additions and 19 deletions

View File

@ -6,4 +6,12 @@
<RootNamespace>Assignment_1</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="Examples\" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="xcopy &quot;$(ProjectDir)\Examples\*.txt&quot; &quot;$(OutDir)&quot; /Y /I" />
</Target>
</Project>

View File

@ -0,0 +1,12 @@
set one "The cat";
set two "sat on the mat";
set sentence one + SPACE + two;
append sentence " by itself.";
print sentence;
printwords sentence;
printwordcount sentence;
printlength sentence;
reverse sentence;
print sentence;
list;
exit;

View File

@ -0,0 +1,11 @@
set var1 "The";
set var2 "pesky";
set var3 "feline";
set var4 "sat,";
set var5 "for what is hopefully the last time,";
set var6 "on the mat.";
set longvar var1 + SPACE;
append longvar var2 + SPACE + var3 + SPACE + var4 + SPACE;
append longvar var5 + SPACE + var6 + NEWLINE;
list;
exit;

View File

@ -0,0 +1,6 @@
set a1 "To be, or not to be - that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune Or to take arms against a sea of troubles, And by opposing end them. To die - to sleep - No more, and by a sleep to say we end The heartache, and the thousand natural shocks That flesh is heir to. 'Tis a consummation Devoutly to be wish'd. To die - to sleep. To sleep - perchance to dream: ay, there's the rub! For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause. There's the respect That makes calamity of so long life. For who would bear the whips and scorns of time, The oppressor's wrong, the proud man's contumely, The pangs of despised love, the law's delay, The insolence of office, and the spurns That patient merit of the unworthy takes, When he himself might his quietus make";
print a1;
printwords a1;
printwordcount a1;
printlength a1;
exit;

View File

@ -0,0 +1,49 @@
set a1 "
To be, or not to be - that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles,
And by opposing end them. To die - to sleep -
No more; and by a sleep to say we end
The heartache, and the thousand natural shocks
That flesh is heir to. 'Tis a consummation
Devoutly to be wish'd. To die - to sleep.
To sleep - perchance to dream: ay, there's the rub!
For in that sleep of death what dreams may come
When we have shuffled off this mortal coil,
Must give us pause. There's the respect
That makes calamity of so long life.
For who would bear the whips and scorns of time,
The oppressor's wrong, the proud man's contumely,
The pangs of despised love, the law's delay,
The insolence of office, and the spurns
That patient merit of the unworthy takes,
When he himself might his quietus make" + NEWLINE +
"With a bare bodkin?
";
set averylongvariablethathasbeencontrivedjusttobeanuisancetothe341classwhohaveprobablythoughtthattheycouldgetawaywithallocatingshortvariablenamesofashortlengthbutaregoingtobereallydisappointediftheydidbecausethisisnotashortvariableidentifieratall "
Who would these fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death -
The undiscover'd country, from whose bourn
No traveller returns - puzzles the will,
And makes us rather bear those ills we have
Than fly to others that we know not of?
Thus conscience does make cowards of us all,
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought,
And enterprises of great pith and moment
With this regard their currents turn awry
And lose the name of action.";
set soliloquy a1 + NEWLINE + averylongvariablethathasbeencontrivedjusttobeanuisancetothe341classwhohaveprobablythoughtthattheycouldgetawaywithallocatingshortvariablenamesofashortlengthbutaregoingtobereallydisappointediftheydidbecausethisisnotashortvariableidentifieratall;
set dummy "dummy1";
print soliloquy;
printwordcount soliloquy;
printwords soliloquy;
printlength soliloquy;
list;
exit;

View File

@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Threading;
namespace Assignment_1
@ -236,12 +232,6 @@ namespace Assignment_1
source.Position = initPos;
source.SetLength(initPos);
break;
/*case Statements.writeout:
// Writes the full command history to the stream.
Console.WriteLine("Writing input commands to {0}...");
source.Position = initPos;
source.SetLength(initPos);
break;*/
}
// Do a check semicolons etc
if (IsNextEoS(source))

View File

@ -3,11 +3,6 @@
"Assignment 1": {
"commandName": "Project"
},
"newProfile1": {
"commandName": "Executable",
"executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"commandLineArgs": "-command \"& type .\\ExampleOutput.txt | & '.\\Assignment 1.exe'\""
},
"Example1": {
"commandName": "Executable",
"executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",

View File

@ -1,5 +1,55 @@
[![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)
# 159.341 Assignment 1 - String Interpreter
# 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.
A basic JIT interpreter for a simple, custom programming language.
There exists only one implicit type definition - strings.
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.
* 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)