Skip to content

Repository files navigation

Pattern Matching Language

📚 Overview

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.


🎯 Objectives

  • 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.

🧪 Operators & Syntax

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


📥 Input & Output

  • The program should accept an expression and apply it to input data.
  • If a match is found, return: EXIT_SUCCESS and display the match.
  • If no match is found, return: EXIT_FAILURE and do not output anything to stdout.

🛠️ Implementation Requirements

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages