This laboration focuses on creating a parser and runtime system for a simple custom language designed to perform pattern matching, similar to simplified regular expressions. You will define a grammar, implement parsing logic, and design a runtime capable of executing the patterns against input data.
- Implement a parser for a custom mini-language with specific pattern-matching capabilities.
- Create a runtime that executes expressions written in this language.
- Design and implement grammar rules that define the language’s structure.
- Handle both matching and non-matching cases with correct exit codes.
The language supports the following pattern-matching operators:
| Operator | Syntax | Description |
|---|---|---|
| Alternation | OP1+OP2 |
Matches one of two alternatives |
| Repetition | OP* |
Matches one or more repetitions of an operand |
| Grouping | (EXPR) |
Groups subexpressions for parsing |
| Wildcard | . |
Matches any single character |
| Counter | OP{N} |
Matches exactly N repetitions of operand |
| Case Ignore | EXPR\I |
Matches expression case-insensitively |
| Output Select | EXPR\O{N} |
Specifies which capturing group to return as output (\O{0} by default) |
🔹
OP= Operand (defined in your grammar)
🔹EXPR= Any valid expression consisting of operators and operands
- The program should accept an expression and apply it to input data.
- If a match is found, return:
EXIT_SUCCESSand display the match. - If no match is found, return:
EXIT_FAILUREand do not output anything tostdout.
- Implement a grammar to define valid expressions using the above operators.
- Build a parser that can parse valid EXPR inputs.
- Create a runtime engine that interprets and executes parsed expressions.
- Ensure correct handling of capturing groups and case sensitivity rules.