Skip to content

Commit

Permalink
docs(readme): Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Demali-876 authored Dec 5, 2024
1 parent 1dc6efd commit d9400a8
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,79 @@ A NFA based regular expression engine implemented in Motoko.

⚠️ **Note**: This project is currently under development and not intended for production use.

## Architecture

The following diagram illustrates the core components and data flow of the regex engine:

```mermaid
graph TD
subgraph Input
input[TEXT INPUT]
cursor[EXTERNAL CURSOR]
end
subgraph Engine Core
lexer[LEXER]
parser[PARSER]
compiler[COMPILER]
matcher[MATCHER]
api[REGEX API]
end
subgraph Outputs
tokens[Tokens]
ast[AST]
nfa[NFA]
result[MATCH RESULT]
end
%% Input flow
input --> cursor
cursor --> lexer
%% Main processing flow
lexer --> tokens
tokens --> parser
parser --> ast
ast --> compiler
compiler --> nfa
nfa --> matcher
matcher --> result
%% API connections
api --> lexer
api --> parser
api --> compiler
api --> matcher
%% Styling
classDef core fill:#f5f5f5,stroke:#333,stroke-width:2px
classDef output fill:#e1f5fe,stroke:#333
classDef api fill:#fff3e0,stroke:#333,stroke-width:2px
class lexer,parser,compiler,matcher core
class tokens,ast,nfa,result output
class api api
```

### Component Description

1. **Input Processing**:
- Text Input: Raw regular expression string
- External Cursor: Character-by-character stream processor

2. **Core Components**:
- **Lexer**: Tokenizes the input stream into meaningful regex components
- **Parser**: Builds an Abstract Syntax Tree (AST) from tokens
- **Compiler**: Transforms the AST into a Non-deterministic Finite Automaton (NFA)
- **Matcher**: Executes pattern matching using the compiled NFA

3. **Intermediate Outputs**:
- Tokens: Lexical units of the regex pattern
- AST: Tree representation of the pattern structure
- NFA: State machine for pattern matching
- Match Result: Final output indicating match success/failure and captures

## Installation

You can install the regex engine using [MOPS](https://mops.one/):
Expand Down

0 comments on commit d9400a8

Please sign in to comment.