enhex 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
enhex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: enhex
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Rust
8
+ Summary: EnhEx - Enhanced Expression. Write readable patterns, get Regex.
9
+ Keywords: regex,dsl,enhex,pattern,compiler
10
+ Author-email: Mahan Khalili <khalili1388mahan@gmail.com>
11
+ License: MIT
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
+
15
+ # EnhEx: Enhanced Expression
16
+
17
+ _Regex, Enhanced for Readability._
18
+
19
+ EnhEx is a simple, readable language for writing regular expressions. Write patterns like sentences. Get standard Regex output. Use it anywhere — Python, JavaScript, Rust, CLI, browser.
20
+
21
+ ---
22
+
23
+ ## Why EnhEx?
24
+
25
+ Regex is powerful but painfully unreadable. After a few months, even your own patterns look like alien code.
26
+
27
+ EnhEx fixes this:
28
+
29
+ - **Write** patterns in a clean, human-readable syntax
30
+ - **Compile** to standard Regex that works everywhere
31
+ - **One core**, written in Rust, compiled to WASM — runs identically in every language
32
+
33
+ ---
34
+
35
+ ## Quick Example
36
+
37
+ ### EnhEx Input
38
+ ```
39
+ start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + "." + tld() + end
40
+ ```
41
+
42
+ ### Regex Output
43
+ ```
44
+ ^[\w\.-]+@[\w-]+\.[a-z]{2,10}$
45
+ ```
46
+
47
+ Same logic, but you can actually **read** the first one.
48
+
49
+ ---
50
+
51
+ ## Installation
52
+
53
+ ### Python
54
+ ```bash
55
+ pip install enhex
56
+ ```
57
+
58
+ ### Rust
59
+ ```bash
60
+ cargo install enhex-core
61
+ ```
62
+
63
+ ### JavaScript / TypeScript
64
+ ```bash
65
+ npm install enhex
66
+ ```
67
+
68
+ ### CLI (via Python)
69
+ ```bash
70
+ pip install enhex
71
+ enhex compile "start + one_or_more(digit) + end"
72
+ # Output: ^\d+$
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Usage
78
+
79
+ ### Python
80
+ ```python
81
+ import enhex as ex
82
+
83
+ # Compile a pattern string
84
+ pattern = ex.compile('start + one_or_more(digit) + end')
85
+
86
+ # Compile from a .enhex file
87
+ pattern = ex.compile_file('phone.enhex')
88
+
89
+ # Use with standard re module
90
+ import re
91
+ if re.match(pattern, "09123456789"):
92
+ print("Valid phone number!")
93
+ ```
94
+
95
+ ### JavaScript
96
+ ```javascript
97
+ import { compile } from 'enhex';
98
+
99
+ const pattern = compile('start + one_or_more(digit) + end');
100
+ const regex = new RegExp(pattern);
101
+
102
+ if (regex.test('12345')) {
103
+ console.log('Only digits!');
104
+ }
105
+ ```
106
+
107
+ ### Rust
108
+ ```rust
109
+ use enhex_core::compile;
110
+
111
+ let pattern = compile("start + one_or_more(digit) + end").unwrap();
112
+ let re = regex::Regex::new(&pattern).unwrap();
113
+
114
+ assert!(re.is_match("12345"));
115
+ ```
116
+
117
+ ### CLI
118
+ ```bash
119
+ # Compile a pattern string
120
+ enhex compile 'start + exactly(10, digit) + end'
121
+
122
+ # Compile a .enhex file
123
+ enhex compile phone.enhex
124
+
125
+ # Show version
126
+ enhex version
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Syntax Overview
132
+
133
+ ### Atoms (Basic Building Blocks)
134
+
135
+ | EnhEx | Description | Regex Equivalent |
136
+ |:------|:------------|:-----------------|
137
+ | `digit` | Any digit 0-9 | `\d` |
138
+ | `word_char` | Letter, digit, or underscore | `\w` |
139
+ | `whitespace` | Space, tab, or newline | `\s` |
140
+ | `lowercase` | Lowercase letters a-z | `[a-z]` |
141
+ | `uppercase` | Uppercase letters A-Z | `[A-Z]` |
142
+ | `letter` | Any letter | `[a-zA-Z]` |
143
+ | `anything` | Any character | `.` |
144
+ | `dot` | Literal dot | `\.` |
145
+ | `dash` | Literal dash | `\-` |
146
+ | `tab` | Literal tab | `\t` |
147
+ | `newline` | Literal newline | `\n` |
148
+
149
+ ### Quantifiers
150
+
151
+ | EnhEx | Regex Equivalent |
152
+ |:------|:-----------------|
153
+ | `one_or_more(X)` | `X+` |
154
+ | `zero_or_more(X)` | `X*` |
155
+ | `optional(X)` | `X?` |
156
+ | `exactly(N, X)` | `X{N}` |
157
+ | `at_least(N, X)` | `X{N,}` |
158
+ | `between(N, M, X)` | `X{N,M}` |
159
+
160
+ ### Composition & Anchors
161
+
162
+ | EnhEx | Meaning | Regex Equivalent |
163
+ |:------|:--------|:-----------------|
164
+ | `X + Y` | X followed by Y | `XY` |
165
+ | `X \| Y` | X or Y | `X\|Y` |
166
+ | `"text"` | Literal text | escaped text |
167
+ | `start` | Start of string | `^` |
168
+ | `end` | End of string | `$` |
169
+ | `word_boundary` | Word boundary | `\b` |
170
+
171
+ ### Groups
172
+
173
+ | EnhEx | Regex Equivalent |
174
+ |:------|:-----------------|
175
+ | `group(X)` | `(X)` |
176
+ | `non_capturing(X)` | `(?:X)` |
177
+ | `named("name", X)` | `(?P<name>X)` |
178
+
179
+ ### Lookaround
180
+
181
+ | EnhEx | Regex Equivalent |
182
+ |:------|:-----------------|
183
+ | `followed_by(X)` | `(?=X)` |
184
+ | `not_followed_by(X)` | `(?!X)` |
185
+ | `preceded_by(X)` | `(?<=X)` |
186
+ | `not_preceded_by(X)` | `(?<!X)` |
187
+
188
+ ### Built-in Presets
189
+
190
+ | EnhEx | Matches |
191
+ |:------|:--------|
192
+ | `tld()` | Top-level domain (com, org, ir, ...) |
193
+ | `email()` | Full email address |
194
+ | `url()` | URL |
195
+ | `ipv4()` | IPv4 address |
196
+
197
+ ---
198
+
199
+ ## File Format
200
+
201
+ EnhEx patterns are stored in `.enhex` files:
202
+
203
+ `email.enhex`:
204
+ ```
205
+ start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + "." + tld() + end
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Project Structure
211
+
212
+ ```
213
+ enhex/
214
+ ├── core/ # Rust core engine
215
+ ├── bindings/
216
+ │ ├── python/ # Python package
217
+ │ └── js/ # JavaScript/TypeScript package
218
+ ├── examples/ # Example .enhex patterns
219
+ ├── vscode/ # VSCode extension (coming soon)
220
+ ├── playground/ # Web playground (coming soon)
221
+ ├── SPEC.md # Full language specification
222
+ └── README.md
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Roadmap
228
+
229
+ - [x] Language specification
230
+ - [ ] Rust core engine + WASM
231
+ - [ ] Python binding
232
+ - [ ] CLI tool
233
+ - [ ] JavaScript/TypeScript binding
234
+ - [ ] VSCode extension (syntax highlighting + live preview)
235
+ - [ ] Web playground
236
+
237
+ ---
238
+
239
+ ## License
240
+
241
+ MIT © Mahan Khalili
242
+
243
+ ---
244
+
245
+ *RegEx, Enhanced.*
246
+
enhex-0.1.0/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # EnhEx: Enhanced Expression
2
+
3
+ _Regex, Enhanced for Readability._
4
+
5
+ EnhEx is a simple, readable language for writing regular expressions. Write patterns like sentences. Get standard Regex output. Use it anywhere — Python, JavaScript, Rust, CLI, browser.
6
+
7
+ ---
8
+
9
+ ## Why EnhEx?
10
+
11
+ Regex is powerful but painfully unreadable. After a few months, even your own patterns look like alien code.
12
+
13
+ EnhEx fixes this:
14
+
15
+ - **Write** patterns in a clean, human-readable syntax
16
+ - **Compile** to standard Regex that works everywhere
17
+ - **One core**, written in Rust, compiled to WASM — runs identically in every language
18
+
19
+ ---
20
+
21
+ ## Quick Example
22
+
23
+ ### EnhEx Input
24
+ ```
25
+ start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + "." + tld() + end
26
+ ```
27
+
28
+ ### Regex Output
29
+ ```
30
+ ^[\w\.-]+@[\w-]+\.[a-z]{2,10}$
31
+ ```
32
+
33
+ Same logic, but you can actually **read** the first one.
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ### Python
40
+ ```bash
41
+ pip install enhex
42
+ ```
43
+
44
+ ### Rust
45
+ ```bash
46
+ cargo install enhex-core
47
+ ```
48
+
49
+ ### JavaScript / TypeScript
50
+ ```bash
51
+ npm install enhex
52
+ ```
53
+
54
+ ### CLI (via Python)
55
+ ```bash
56
+ pip install enhex
57
+ enhex compile "start + one_or_more(digit) + end"
58
+ # Output: ^\d+$
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Usage
64
+
65
+ ### Python
66
+ ```python
67
+ import enhex as ex
68
+
69
+ # Compile a pattern string
70
+ pattern = ex.compile('start + one_or_more(digit) + end')
71
+
72
+ # Compile from a .enhex file
73
+ pattern = ex.compile_file('phone.enhex')
74
+
75
+ # Use with standard re module
76
+ import re
77
+ if re.match(pattern, "09123456789"):
78
+ print("Valid phone number!")
79
+ ```
80
+
81
+ ### JavaScript
82
+ ```javascript
83
+ import { compile } from 'enhex';
84
+
85
+ const pattern = compile('start + one_or_more(digit) + end');
86
+ const regex = new RegExp(pattern);
87
+
88
+ if (regex.test('12345')) {
89
+ console.log('Only digits!');
90
+ }
91
+ ```
92
+
93
+ ### Rust
94
+ ```rust
95
+ use enhex_core::compile;
96
+
97
+ let pattern = compile("start + one_or_more(digit) + end").unwrap();
98
+ let re = regex::Regex::new(&pattern).unwrap();
99
+
100
+ assert!(re.is_match("12345"));
101
+ ```
102
+
103
+ ### CLI
104
+ ```bash
105
+ # Compile a pattern string
106
+ enhex compile 'start + exactly(10, digit) + end'
107
+
108
+ # Compile a .enhex file
109
+ enhex compile phone.enhex
110
+
111
+ # Show version
112
+ enhex version
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Syntax Overview
118
+
119
+ ### Atoms (Basic Building Blocks)
120
+
121
+ | EnhEx | Description | Regex Equivalent |
122
+ |:------|:------------|:-----------------|
123
+ | `digit` | Any digit 0-9 | `\d` |
124
+ | `word_char` | Letter, digit, or underscore | `\w` |
125
+ | `whitespace` | Space, tab, or newline | `\s` |
126
+ | `lowercase` | Lowercase letters a-z | `[a-z]` |
127
+ | `uppercase` | Uppercase letters A-Z | `[A-Z]` |
128
+ | `letter` | Any letter | `[a-zA-Z]` |
129
+ | `anything` | Any character | `.` |
130
+ | `dot` | Literal dot | `\.` |
131
+ | `dash` | Literal dash | `\-` |
132
+ | `tab` | Literal tab | `\t` |
133
+ | `newline` | Literal newline | `\n` |
134
+
135
+ ### Quantifiers
136
+
137
+ | EnhEx | Regex Equivalent |
138
+ |:------|:-----------------|
139
+ | `one_or_more(X)` | `X+` |
140
+ | `zero_or_more(X)` | `X*` |
141
+ | `optional(X)` | `X?` |
142
+ | `exactly(N, X)` | `X{N}` |
143
+ | `at_least(N, X)` | `X{N,}` |
144
+ | `between(N, M, X)` | `X{N,M}` |
145
+
146
+ ### Composition & Anchors
147
+
148
+ | EnhEx | Meaning | Regex Equivalent |
149
+ |:------|:--------|:-----------------|
150
+ | `X + Y` | X followed by Y | `XY` |
151
+ | `X \| Y` | X or Y | `X\|Y` |
152
+ | `"text"` | Literal text | escaped text |
153
+ | `start` | Start of string | `^` |
154
+ | `end` | End of string | `$` |
155
+ | `word_boundary` | Word boundary | `\b` |
156
+
157
+ ### Groups
158
+
159
+ | EnhEx | Regex Equivalent |
160
+ |:------|:-----------------|
161
+ | `group(X)` | `(X)` |
162
+ | `non_capturing(X)` | `(?:X)` |
163
+ | `named("name", X)` | `(?P<name>X)` |
164
+
165
+ ### Lookaround
166
+
167
+ | EnhEx | Regex Equivalent |
168
+ |:------|:-----------------|
169
+ | `followed_by(X)` | `(?=X)` |
170
+ | `not_followed_by(X)` | `(?!X)` |
171
+ | `preceded_by(X)` | `(?<=X)` |
172
+ | `not_preceded_by(X)` | `(?<!X)` |
173
+
174
+ ### Built-in Presets
175
+
176
+ | EnhEx | Matches |
177
+ |:------|:--------|
178
+ | `tld()` | Top-level domain (com, org, ir, ...) |
179
+ | `email()` | Full email address |
180
+ | `url()` | URL |
181
+ | `ipv4()` | IPv4 address |
182
+
183
+ ---
184
+
185
+ ## File Format
186
+
187
+ EnhEx patterns are stored in `.enhex` files:
188
+
189
+ `email.enhex`:
190
+ ```
191
+ start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + "." + tld() + end
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Project Structure
197
+
198
+ ```
199
+ enhex/
200
+ ├── core/ # Rust core engine
201
+ ├── bindings/
202
+ │ ├── python/ # Python package
203
+ │ └── js/ # JavaScript/TypeScript package
204
+ ├── examples/ # Example .enhex patterns
205
+ ├── vscode/ # VSCode extension (coming soon)
206
+ ├── playground/ # Web playground (coming soon)
207
+ ├── SPEC.md # Full language specification
208
+ └── README.md
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Roadmap
214
+
215
+ - [x] Language specification
216
+ - [ ] Rust core engine + WASM
217
+ - [ ] Python binding
218
+ - [ ] CLI tool
219
+ - [ ] JavaScript/TypeScript binding
220
+ - [ ] VSCode extension (syntax highlighting + live preview)
221
+ - [ ] Web playground
222
+
223
+ ---
224
+
225
+ ## License
226
+
227
+ MIT © Mahan Khalili
228
+
229
+ ---
230
+
231
+ *RegEx, Enhanced.*
@@ -0,0 +1,72 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version