https://github.com/nssharmaofficial/lark-switch-parser
Implementation of switch case in Lark
https://github.com/nssharmaofficial/lark-switch-parser
lark-parser parser switch-case
Last synced: 6 days ago
JSON representation
Implementation of switch case in Lark
- Host: GitHub
- URL: https://github.com/nssharmaofficial/lark-switch-parser
- Owner: nssharmaofficial
- Created: 2023-01-01T12:45:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-05T18:27:24.000Z (8 months ago)
- Last Synced: 2025-03-29T22:06:01.942Z (about 1 month ago)
- Topics: lark-parser, parser, switch-case
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Switch parser using Lark
This project was an assignment for the NLP class at University of Siena.
## Assignment
Using lark implement a parser for managing the **switch** statement in a simplified version.
- the variable used in the switch is one integer variable in a predefined set of two variables `x`, `y`.
- the values to `x`, `y` are assigned before the if statement (assume 0 if there is no assignment)
- the switch instruction has the following syntax```lark
switch(var) {
case 0: z=cost0;
break;...
case N: z=costN;
break;default: z=costD;
break;
}
```- the instruction contains only the assignment of a constant value to the variable `z`
- at the end print the value of the variable `z`