Skip to content

Commit

Permalink
Update Syntax and README
Browse files Browse the repository at this point in the history
  • Loading branch information
SingularityT3 committed Mar 28, 2024
1 parent 2a5b580 commit 7b5f345
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 15 deletions.
Binary file added HelloWorld.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 55 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,70 @@

A pseudocode interpreter designed to be compatible with the Cambridge IGCSE and A level pseudocode [syntax](./Syntax.md)

![PseudoEngine2](https://user-images.githubusercontent.com/44658109/220901152-5a794d58-de15-4028-91b0-fbebee033a70.png)
![Demo](./HelloWorld.gif)

## The REPL
The REPL stands for Read Execute Print Loop and is an interface where pseudocode statements can be entered. The statement is immediately executed after it is entered and the result is printed to the console(if any)
The REPL stands for **R**ead **E**xecute **P**rint **L**oop and is an interface where pseudocode statements can be entered. The statement is immediately executed after it is entered and the result or potential errors are printed to the console to make it easy for debugging.

```
> 5 + 2 * 3
11
> LEFT("ABCD", 2)
"AB"
> x <- 1 / 0
Runtime Error in file <stdin>:
Division by 0
Traceback:
Program, line 1, column 9
```

## Usage
- Run the following commands in terminal/powershell in the directory of the executable.
### Launching the REPL
Lanuch the program directly by double clicking the [executable](https://github.com/SingularityT3/PseudoEngine2/releases) \
**OR** \
Run it in the terminal with no arguements

### Running files in the REPL
The REPL can be used to run files using `RUNFILE <file>`. \
For example, here is a simple hello world program stored in the file `hello.pseudo`
```
OUTPUT "Hello World!"
```
\
Run it with `RUNFILE hello.pseudo` \
Example output:
```
PseudoEngine2 v1.0.0 REPL
Enter 'EXIT' to quit
> RUNFILE hello.pseudo
Running file hello.pseudo
Hello World!
Program exited successfully
>
```
> Tip:
> The program must be stored in the _same folder_ as the executable **or** the full path of the program has to be mentioned when using `RUNFILE`

Windows:
```
PseudoEngine2.exe [filename]
```
Linux/Unix:
```
./PseudoEngine2 [filename]
```
NOTE: `PseudoEngine2` would be replaced by the name of the executable which may be something like `Pseudoengine2-v0.5.exe` if it is downloaded from the [releases](https://github.com/SingularityT3/PseudoEngine2/releases)
### Running files from the terminal
Navigate to the executable and run it providing the path of the program file as an arguement similar to `RUNFILE`

Filename is an optional arguement. If it is provided the program in the corresponding file is run otherwise the REPL is launched.
Windows:
```
PseudoEngine2.exe <filepath>
```
Linux/Unix:
```
./PseudoEngine2 <filepath>
```

- Alternatively, double click the executable file if supported by the OS to directly start the REPL. It is also possible to run files from the REPL using the command `RUNFILE <filename>`.
Make sure you replace `PseudoEngine2` with the actual name of the executable or rename the executable

## Examples
See [examples](./examples) and [tests](./tests)
See [examples](./examples)

## Building
Make sure cmake and a c++ compiler is installed, then clone the repository and inside its folder run the following commands:
Expand Down
1 change: 1 addition & 0 deletions Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,5 @@ CLOSEFILE <filename>
- `CONTINUE` - Skip to next iteration of loop
- `ELSE IF` - Alternative to reduce nesting
- Alternate method of type conversion(apart from in-built functions): `<data type>(<value>)`. For example: `INTEGER("57")`
- Math functions like `SIN`, `EXP`
- Character escape codes like `\n`, `\t` etc.

0 comments on commit 7b5f345

Please sign in to comment.