Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abrahammurciano/s-interpreter
https://github.com/abrahammurciano/s-interpreter
Last synced: about 9 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/abrahammurciano/s-interpreter
- Owner: abrahammurciano
- License: gpl-3.0
- Created: 2021-04-28T17:11:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-04-29T15:48:45.000Z (over 3 years ago)
- Last Synced: 2024-08-03T21:03:17.444Z (3 months ago)
- Language: Python
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# S Iinterpreter
An interpreter for the S language written in python. The S language is a minimal turing complete language created for educational purposes.
# Usage
Run `s.py` with the first argument being the name of the file containing the S code and the rest of the arguments (none to infinitely many) being the arguments to pass to the S program. All arguments after the first must be positive integers.
Example run:
```
$ ./s.py /path/to/multiply.s 10 5
50
```# Syntax
Each line of the S program must be in one of the following formats:
- `[{label}]{instruction}`
- `{instruction}`Each `{instruction}` must be in one of the following four forms:
- `{var}<-{var}`: This is a no-op. This instruction does nothing.
- `{var}<-{var}+1`: This instruction increments `{var}` by one.
- `{var}<-{var}-1`: This instruction decrements `{var}` by one, with a lower limit of zero.
- `IF {var}!=0 GOTO {label}`: This instruction jumps to the first instruction starting with `[{label}]` only if the value of `{var}` is not zero.`{label}` can be any string starting with an uppercase letter or underscore and containing only uppercase letters, underscores, and digits. Labels point to the end of the program by default. Note, variables `A`, `B`, `C`, `D`, and `E` are aliases for `A1`, `B1`, `C1`, `D1`, and `E1` respectively.
`{var}` can be any string starting with an uppercase letter or underscore and containing only uppercase letters, underscores, and digits. Variables' values are zero by default. `X1`, `X2`, etc. are set to the input values. Note, variables `X` and `Z` are aliases for `X1` and `Z1` respectively. Variable `Y` is the returned variable.