Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artem-burashnikov/simpleparser
Part of the SPBU's programming course. Parser, interpretator and optimizer for a simple formal language.
https://github.com/artem-burashnikov/simpleparser
fsharp interpretator optimizer parser parser-combinators
Last synced: about 2 months ago
JSON representation
Part of the SPBU's programming course. Parser, interpretator and optimizer for a simple formal language.
- Host: GitHub
- URL: https://github.com/artem-burashnikov/simpleparser
- Owner: artem-burashnikov
- License: mit
- Archived: true
- Created: 2023-11-18T21:41:34.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-22T18:42:19.000Z (11 months ago)
- Last Synced: 2024-09-29T06:22:39.477Z (about 2 months ago)
- Topics: fsharp, interpretator, optimizer, parser, parser-combinators
- Language: F#
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![MIT License][license-shield]][license-url]
# SimpleParser
SPBU 3rd semester homework assignment.
## Language grammar
Definition using [EBNF][grammar-notation] notation:
`[x]` denotes one or more
`{x}` denotes zero or more
`(x)` denotes a capture group
```ignorelang
digit = "1" | ... | "9"number = { digit }
letter = "a" | ... | "z" | "A" | ... | "Z"
identifier = letter { letter | digit }
factor = identifier | number | ifExpression | (factor "*" factor)
add = factor | (add "+" add)
arithmeticExpression = factor | add
booleanValue = "true" | "false"
relationalOperator = "=" | "<>" | "<=" | "<" | ">=" | ">"
booleanExpression = booleanValue | (arithmeticExpression | identifier) relationalOperator (arithmeticExpression | identifier)
ifExpression = "if" "(" booleanExpression ")" "then"
"(" [ arithmeticExpression | booleanExpression | ifExpression ] ")"
"else"
"(" [ arithmeticExpression | booleanExpression | ifExpression ] ")"command = "print:" (arithmeticExpression | identifier)
assignment = identifier "=" (booleanValue | arithmeticExpression | identifier | ifExpression)
statement = assignment | command
program = {statement}
```## Getting Started
To get a local copy up and running follow the steps below.
### Prerequisites
[.NET >= 7.0][net-link]
### Installation
1. Clone the repo:
```shell
git clone https://github.com/artem-burashnikov/SimpleParser.git
```
2. Build the project:```shell
./build.sh
```### Usage
CLI is available:
```ignorelang
USAGE: SimpleParser [--help]FILEPATH:
Specify a path to the file
containing a program.OPTIONS:
--help Display this list of options.
```
Following a language definition, a simple program may look like this:
```
x=3
y=2
z=if(true)then(x*y+7)else(1)
print:z
```
Outputs `13` to the console.## License
Distributed under the MIT License. See [LICENSE][license-url] for more information.
[license-shield]: https://img.shields.io/github/license/artem-burashnikov/SimpleParser.svg?style=for-the-badge
[license-url]: https://github.com/artem-burashnikov/SimpleParser/blob/main/LICENSE
[net-link]: https://dotnet.microsoft.com/en-us/download
[grammar-notation]: https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form