https://github.com/lesterlyu/snm-parser
https://github.com/lesterlyu/snm-parser
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lesterlyu/snm-parser
- Owner: LesterLyu
- Created: 2020-03-09T01:35:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-13T14:24:08.000Z (over 6 years ago)
- Last Synced: 2025-07-01T05:52:43.071Z (12 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## SNM Grammar Specification
### Install [Lark](https://github.com/lark-parser/lark)
```sh
$ pip3 install lark-parser # pip if in Windows environment
```
### Operator Precedence (High to Low)
- `+`, `-` Unary plus and minus
- `-1`
- `--+100` -> `100`
- `++++100` -> `100`
- `---100` -> `-100`
- `in` -> list operation
- `"abc" in ["abc", "def"]` -> `true`
- `1 in [1, 2, 3,]` -> `true`
- `[1, 2] in [1, 2, 4, 6]` -> `true`
- `[0, 2] in [1, 2, 3]` -> `false`
- `!1 in [true, false]` -> `false`
- `1 in [true, false]` is evaluated first!
- `!` Logical not
- `!false` -> `true`
- `!100` -> `false`
- `!0` -> `true`
- `*`, `/`, `%` Multiplication, division, and remainder
- `+`, `-` Addition and subtraction
- `<`, `<=`, `>`, `>=` Relational operators <, ≤, >, ≥
- `==`, `!=` Relational = and ≠ respectively
- `&&` Logical AND
- `||` Logical OR
### Data Types
- String: `"string"`
- Number: `123`, `-123`
- Boolean: `true`, `false`
- Array: `[1, 3, "hello", [123, 456], true, false]`
- An array can contain any data types
- Field:
- e.g. `age`, `AGE`, `age_01`, `i_am_a_field`
- Field name should contain only numbers, letters and underline _
- **No special characters** are allowed :point_left: