enlang 2.0.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.
- enlang-2.0.0/PKG-INFO +97 -0
- enlang-2.0.0/README.md +81 -0
- enlang-2.0.0/enlang.egg-info/PKG-INFO +97 -0
- enlang-2.0.0/enlang.egg-info/SOURCES.txt +24 -0
- enlang-2.0.0/enlang.egg-info/dependency_links.txt +1 -0
- enlang-2.0.0/enlang.egg-info/entry_points.txt +3 -0
- enlang-2.0.0/enlang.egg-info/top_level.txt +4 -0
- enlang-2.0.0/enlang.py +142 -0
- enlang-2.0.0/enlang_core/__init__.py +10 -0
- enlang-2.0.0/enlang_core/checker.py +162 -0
- enlang-2.0.0/enlang_core/cli.py +181 -0
- enlang-2.0.0/enlang_core/debugger.py +159 -0
- enlang-2.0.0/enlang_core/epm.py +161 -0
- enlang-2.0.0/enlang_core/grammar.py +1199 -0
- enlang-2.0.0/enlang_core/interpreter.py +49 -0
- enlang-2.0.0/enlang_core/nlp_engine.py +97 -0
- enlang-2.0.0/enlang_core/transpiler.py +761 -0
- enlang-2.0.0/enlang_core/web_server.py +235 -0
- enlang-2.0.0/gui_installer.py +325 -0
- enlang-2.0.0/installer.py +142 -0
- enlang-2.0.0/pyproject.toml +22 -0
- enlang-2.0.0/setup.cfg +4 -0
- enlang-2.0.0/setup.py +40 -0
- enlang-2.0.0/tests/test_comprehensive.py +742 -0
- enlang-2.0.0/tests/test_enlang.py +780 -0
- enlang-2.0.0/tests/test_mega_stress.py +155 -0
enlang-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: enlang
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: The Universal Natural English Programming Language Transpiler & Compiler Engine
|
|
5
|
+
Home-page: https://github.com/Aero99op/enlang
|
|
6
|
+
Author: Spandan Prayas Patra
|
|
7
|
+
Author-email: Spandan Prayas Patra <spandan@enlang.org>
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: home-page
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
|
|
17
|
+
# EnLang — The Universal Natural English Programming Language
|
|
18
|
+
### *Build Full-Stack Applications Using Natural English*
|
|
19
|
+
|
|
20
|
+
[](https://github.com/Aero99op/enlang)
|
|
21
|
+
[](LICENSE)
|
|
22
|
+
[](tests/)
|
|
23
|
+
|
|
24
|
+
Created and Authored by **Spandan Prayas Patra**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🌟 Overview
|
|
29
|
+
**EnLang** is a deterministic, universal multi-target programming language and transpilation engine that converts natural English into 1:1 clean, production-grade native targets:
|
|
30
|
+
|
|
31
|
+
- **`.enlg`** ➔ Core Backend Logic & Algorithms (Python 3)
|
|
32
|
+
- **`.enlgf`** ➔ Structural Frontend Markup (HTML5)
|
|
33
|
+
- **`.enlgd`** ➔ Styling & Design Systems (CSS3)
|
|
34
|
+
- **`.enlgs`** ➔ Client Scripting & DOM Logic (JavaScript ES6+)
|
|
35
|
+
- **`.enlgdb`** ➔ Database Schemas & Queries (SQL)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 Official Installation Methods
|
|
40
|
+
|
|
41
|
+
EnLang is distributed as a compiled distribution engine. You can install EnLang globally on your system using either of the following official methods:
|
|
42
|
+
|
|
43
|
+
### 1️⃣ Method 1: One-Click Windows GUI Installer (Recommended)
|
|
44
|
+
Download and launch the official compiled setup wizard:
|
|
45
|
+
👉 **[Download EnLangInstaller.exe](https://raw.githubusercontent.com/Aero99op/enlang/main/EnLangInstaller.exe)**
|
|
46
|
+
|
|
47
|
+
*The GUI Installer automatically extracts the core runtime binaries to `%USERPROFILE%\.enlang\` and registers the system `PATH` environment variable.*
|
|
48
|
+
|
|
49
|
+
### 2️⃣ Method 2: CLI Package Installation (`pip`)
|
|
50
|
+
Install EnLang directly into your Python CLI environment using `pip`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install enlang
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🛠️ Global CLI Tooling
|
|
59
|
+
|
|
60
|
+
Once installed via GUI or `pip`, open any command prompt or terminal and use:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
enlang run main.enlg # Compiles and executes EnLang program
|
|
64
|
+
enlang check main.enlg # Runs static analysis & syntax linter
|
|
65
|
+
enlang debug main.enlg # Launches step-by-step interactive debugger
|
|
66
|
+
enlang build index.enlgf # Transpiles source to native target file (.py, .html, .css, .js, .sql)
|
|
67
|
+
enlang server --port 8000 # Launches zero-config EnLang HTTP web server
|
|
68
|
+
epm init # Initializes a new EnLang project package
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 💡 Syntax Showcase
|
|
74
|
+
|
|
75
|
+
```enlang
|
|
76
|
+
define text username as "Spandan"
|
|
77
|
+
|
|
78
|
+
function numbers using n:
|
|
79
|
+
if n is greater than 10 then:
|
|
80
|
+
return
|
|
81
|
+
display n
|
|
82
|
+
call numbers with (n plus 1)
|
|
83
|
+
|
|
84
|
+
start numbers from 1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📚 Official Specification & Book
|
|
90
|
+
The official specification book **"EnLang for Developers: Enterprise Specification Edition (v2.0)"** is available in this repository:
|
|
91
|
+
- 📄 [ENLANG_FOR_DEVELOPERS_BOOK.pdf](ENLANG_FOR_DEVELOPERS_BOOK.pdf)
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 📜 Distribution & Rights
|
|
96
|
+
Copyright © 2026 Spandan Prayas Patra. All rights reserved.
|
|
97
|
+
Distributed via official GUI Standalone Binary & PyPI Package Manager (`pip`).
|
enlang-2.0.0/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# EnLang — The Universal Natural English Programming Language
|
|
2
|
+
### *Build Full-Stack Applications Using Natural English*
|
|
3
|
+
|
|
4
|
+
[](https://github.com/Aero99op/enlang)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](tests/)
|
|
7
|
+
|
|
8
|
+
Created and Authored by **Spandan Prayas Patra**.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🌟 Overview
|
|
13
|
+
**EnLang** is a deterministic, universal multi-target programming language and transpilation engine that converts natural English into 1:1 clean, production-grade native targets:
|
|
14
|
+
|
|
15
|
+
- **`.enlg`** ➔ Core Backend Logic & Algorithms (Python 3)
|
|
16
|
+
- **`.enlgf`** ➔ Structural Frontend Markup (HTML5)
|
|
17
|
+
- **`.enlgd`** ➔ Styling & Design Systems (CSS3)
|
|
18
|
+
- **`.enlgs`** ➔ Client Scripting & DOM Logic (JavaScript ES6+)
|
|
19
|
+
- **`.enlgdb`** ➔ Database Schemas & Queries (SQL)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🚀 Official Installation Methods
|
|
24
|
+
|
|
25
|
+
EnLang is distributed as a compiled distribution engine. You can install EnLang globally on your system using either of the following official methods:
|
|
26
|
+
|
|
27
|
+
### 1️⃣ Method 1: One-Click Windows GUI Installer (Recommended)
|
|
28
|
+
Download and launch the official compiled setup wizard:
|
|
29
|
+
👉 **[Download EnLangInstaller.exe](https://raw.githubusercontent.com/Aero99op/enlang/main/EnLangInstaller.exe)**
|
|
30
|
+
|
|
31
|
+
*The GUI Installer automatically extracts the core runtime binaries to `%USERPROFILE%\.enlang\` and registers the system `PATH` environment variable.*
|
|
32
|
+
|
|
33
|
+
### 2️⃣ Method 2: CLI Package Installation (`pip`)
|
|
34
|
+
Install EnLang directly into your Python CLI environment using `pip`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install enlang
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🛠️ Global CLI Tooling
|
|
43
|
+
|
|
44
|
+
Once installed via GUI or `pip`, open any command prompt or terminal and use:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
enlang run main.enlg # Compiles and executes EnLang program
|
|
48
|
+
enlang check main.enlg # Runs static analysis & syntax linter
|
|
49
|
+
enlang debug main.enlg # Launches step-by-step interactive debugger
|
|
50
|
+
enlang build index.enlgf # Transpiles source to native target file (.py, .html, .css, .js, .sql)
|
|
51
|
+
enlang server --port 8000 # Launches zero-config EnLang HTTP web server
|
|
52
|
+
epm init # Initializes a new EnLang project package
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 💡 Syntax Showcase
|
|
58
|
+
|
|
59
|
+
```enlang
|
|
60
|
+
define text username as "Spandan"
|
|
61
|
+
|
|
62
|
+
function numbers using n:
|
|
63
|
+
if n is greater than 10 then:
|
|
64
|
+
return
|
|
65
|
+
display n
|
|
66
|
+
call numbers with (n plus 1)
|
|
67
|
+
|
|
68
|
+
start numbers from 1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 📚 Official Specification & Book
|
|
74
|
+
The official specification book **"EnLang for Developers: Enterprise Specification Edition (v2.0)"** is available in this repository:
|
|
75
|
+
- 📄 [ENLANG_FOR_DEVELOPERS_BOOK.pdf](ENLANG_FOR_DEVELOPERS_BOOK.pdf)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 📜 Distribution & Rights
|
|
80
|
+
Copyright © 2026 Spandan Prayas Patra. All rights reserved.
|
|
81
|
+
Distributed via official GUI Standalone Binary & PyPI Package Manager (`pip`).
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: enlang
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: The Universal Natural English Programming Language Transpiler & Compiler Engine
|
|
5
|
+
Home-page: https://github.com/Aero99op/enlang
|
|
6
|
+
Author: Spandan Prayas Patra
|
|
7
|
+
Author-email: Spandan Prayas Patra <spandan@enlang.org>
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: home-page
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
|
|
17
|
+
# EnLang — The Universal Natural English Programming Language
|
|
18
|
+
### *Build Full-Stack Applications Using Natural English*
|
|
19
|
+
|
|
20
|
+
[](https://github.com/Aero99op/enlang)
|
|
21
|
+
[](LICENSE)
|
|
22
|
+
[](tests/)
|
|
23
|
+
|
|
24
|
+
Created and Authored by **Spandan Prayas Patra**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🌟 Overview
|
|
29
|
+
**EnLang** is a deterministic, universal multi-target programming language and transpilation engine that converts natural English into 1:1 clean, production-grade native targets:
|
|
30
|
+
|
|
31
|
+
- **`.enlg`** ➔ Core Backend Logic & Algorithms (Python 3)
|
|
32
|
+
- **`.enlgf`** ➔ Structural Frontend Markup (HTML5)
|
|
33
|
+
- **`.enlgd`** ➔ Styling & Design Systems (CSS3)
|
|
34
|
+
- **`.enlgs`** ➔ Client Scripting & DOM Logic (JavaScript ES6+)
|
|
35
|
+
- **`.enlgdb`** ➔ Database Schemas & Queries (SQL)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 Official Installation Methods
|
|
40
|
+
|
|
41
|
+
EnLang is distributed as a compiled distribution engine. You can install EnLang globally on your system using either of the following official methods:
|
|
42
|
+
|
|
43
|
+
### 1️⃣ Method 1: One-Click Windows GUI Installer (Recommended)
|
|
44
|
+
Download and launch the official compiled setup wizard:
|
|
45
|
+
👉 **[Download EnLangInstaller.exe](https://raw.githubusercontent.com/Aero99op/enlang/main/EnLangInstaller.exe)**
|
|
46
|
+
|
|
47
|
+
*The GUI Installer automatically extracts the core runtime binaries to `%USERPROFILE%\.enlang\` and registers the system `PATH` environment variable.*
|
|
48
|
+
|
|
49
|
+
### 2️⃣ Method 2: CLI Package Installation (`pip`)
|
|
50
|
+
Install EnLang directly into your Python CLI environment using `pip`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install enlang
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🛠️ Global CLI Tooling
|
|
59
|
+
|
|
60
|
+
Once installed via GUI or `pip`, open any command prompt or terminal and use:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
enlang run main.enlg # Compiles and executes EnLang program
|
|
64
|
+
enlang check main.enlg # Runs static analysis & syntax linter
|
|
65
|
+
enlang debug main.enlg # Launches step-by-step interactive debugger
|
|
66
|
+
enlang build index.enlgf # Transpiles source to native target file (.py, .html, .css, .js, .sql)
|
|
67
|
+
enlang server --port 8000 # Launches zero-config EnLang HTTP web server
|
|
68
|
+
epm init # Initializes a new EnLang project package
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 💡 Syntax Showcase
|
|
74
|
+
|
|
75
|
+
```enlang
|
|
76
|
+
define text username as "Spandan"
|
|
77
|
+
|
|
78
|
+
function numbers using n:
|
|
79
|
+
if n is greater than 10 then:
|
|
80
|
+
return
|
|
81
|
+
display n
|
|
82
|
+
call numbers with (n plus 1)
|
|
83
|
+
|
|
84
|
+
start numbers from 1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 📚 Official Specification & Book
|
|
90
|
+
The official specification book **"EnLang for Developers: Enterprise Specification Edition (v2.0)"** is available in this repository:
|
|
91
|
+
- 📄 [ENLANG_FOR_DEVELOPERS_BOOK.pdf](ENLANG_FOR_DEVELOPERS_BOOK.pdf)
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 📜 Distribution & Rights
|
|
96
|
+
Copyright © 2026 Spandan Prayas Patra. All rights reserved.
|
|
97
|
+
Distributed via official GUI Standalone Binary & PyPI Package Manager (`pip`).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
enlang.py
|
|
3
|
+
gui_installer.py
|
|
4
|
+
installer.py
|
|
5
|
+
pyproject.toml
|
|
6
|
+
setup.py
|
|
7
|
+
enlang.egg-info/PKG-INFO
|
|
8
|
+
enlang.egg-info/SOURCES.txt
|
|
9
|
+
enlang.egg-info/dependency_links.txt
|
|
10
|
+
enlang.egg-info/entry_points.txt
|
|
11
|
+
enlang.egg-info/top_level.txt
|
|
12
|
+
enlang_core/__init__.py
|
|
13
|
+
enlang_core/checker.py
|
|
14
|
+
enlang_core/cli.py
|
|
15
|
+
enlang_core/debugger.py
|
|
16
|
+
enlang_core/epm.py
|
|
17
|
+
enlang_core/grammar.py
|
|
18
|
+
enlang_core/interpreter.py
|
|
19
|
+
enlang_core/nlp_engine.py
|
|
20
|
+
enlang_core/transpiler.py
|
|
21
|
+
enlang_core/web_server.py
|
|
22
|
+
tests/test_comprehensive.py
|
|
23
|
+
tests/test_enlang.py
|
|
24
|
+
tests/test_mega_stress.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
enlang-2.0.0/enlang.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
EnLang Command Line Interface (CLI)
|
|
4
|
+
Natural English Programming Language Runner & Tooling.
|
|
5
|
+
Supports .enlg (Normal), .enlgd (Design UI), .enlgs (Script Automation), and .enlgdb (Database).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import os
|
|
10
|
+
import argparse
|
|
11
|
+
from enlang_core import EnLangInterpreter, EnLangTranspiler, __version__
|
|
12
|
+
|
|
13
|
+
SUPPORTED_EXTENSIONS = ['.enlg', '.enlgf', '.enlgd', '.enlgs', '.enlgdb', '.enl']
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
parser = argparse.ArgumentParser(
|
|
17
|
+
prog="enlang",
|
|
18
|
+
description="EnLang - Universal Natural English Programming Language (.enlg, .enlgd, .enlgs, .enlgdb)"
|
|
19
|
+
)
|
|
20
|
+
subparsers = parser.add_subparsers(dest="command", help="Available subcommands")
|
|
21
|
+
|
|
22
|
+
# Command: run
|
|
23
|
+
run_parser = subparsers.add_parser("run", help="Run an EnLang (.enlg / .enlgd / .enlgs / .enlgdb) script directly")
|
|
24
|
+
run_parser.add_argument("filename", help="Path to EnLang file")
|
|
25
|
+
run_parser.add_argument("--show-python", action="store_true", help="Print transpiled Python code before running")
|
|
26
|
+
|
|
27
|
+
# Command: build
|
|
28
|
+
build_parser = subparsers.add_parser("build", help="Transpile EnLang script to a Python (.py) file")
|
|
29
|
+
build_parser.add_argument("filename", help="Path to EnLang file")
|
|
30
|
+
build_parser.add_argument("-o", "--output", help="Output .py file path")
|
|
31
|
+
|
|
32
|
+
# Command: check
|
|
33
|
+
check_parser = subparsers.add_parser("check", help="Perform static analysis and linting on EnLang source file")
|
|
34
|
+
check_parser.add_argument("filename", help="Path to EnLang file")
|
|
35
|
+
|
|
36
|
+
# Command: debug
|
|
37
|
+
debug_parser = subparsers.add_parser("debug", help="Launch interactive step-by-step debugger")
|
|
38
|
+
debug_parser.add_argument("filename", help="Path to EnLang file")
|
|
39
|
+
|
|
40
|
+
# Command: repl / shell
|
|
41
|
+
subparsers.add_parser("repl", help="Start interactive EnLang English REPL shell")
|
|
42
|
+
subparsers.add_parser("shell", help="Start interactive EnLang English REPL shell")
|
|
43
|
+
|
|
44
|
+
# Command: version
|
|
45
|
+
subparsers.add_parser("version", help="Show EnLang version")
|
|
46
|
+
|
|
47
|
+
args = parser.parse_args()
|
|
48
|
+
|
|
49
|
+
interpreter = EnLangInterpreter()
|
|
50
|
+
transpiler = EnLangTranspiler()
|
|
51
|
+
|
|
52
|
+
if args.command == "run":
|
|
53
|
+
if not os.path.exists(args.filename):
|
|
54
|
+
print(f"Error: File '{args.filename}' not found.", file=sys.stderr)
|
|
55
|
+
sys.exit(1)
|
|
56
|
+
|
|
57
|
+
with open(args.filename, "r", encoding="utf-8") as f:
|
|
58
|
+
source = f.read()
|
|
59
|
+
|
|
60
|
+
if args.show_python:
|
|
61
|
+
py_code = transpiler.transpile(source, file_path=args.filename)
|
|
62
|
+
print(f"--- Generated Python Code ({args.filename}) ---")
|
|
63
|
+
print(py_code)
|
|
64
|
+
print("--- Execution Output ---")
|
|
65
|
+
|
|
66
|
+
success, stdout, stderr, _ = interpreter.run_code(source, file_path=args.filename)
|
|
67
|
+
if stdout:
|
|
68
|
+
print(stdout, end="")
|
|
69
|
+
if stderr:
|
|
70
|
+
print(stderr, file=sys.stderr, end="")
|
|
71
|
+
sys.exit(0 if success else 1)
|
|
72
|
+
|
|
73
|
+
elif args.command == "build":
|
|
74
|
+
if not os.path.exists(args.filename):
|
|
75
|
+
print(f"Error: File '{args.filename}' not found.", file=sys.stderr)
|
|
76
|
+
sys.exit(1)
|
|
77
|
+
|
|
78
|
+
with open(args.filename, "r", encoding="utf-8") as f:
|
|
79
|
+
source = f.read()
|
|
80
|
+
|
|
81
|
+
py_code = transpiler.transpile(source, file_path=args.filename)
|
|
82
|
+
out_path = args.output if args.output else os.path.splitext(args.filename)[0] + ".py"
|
|
83
|
+
|
|
84
|
+
with open(out_path, "w", encoding="utf-8") as f:
|
|
85
|
+
f.write(py_code)
|
|
86
|
+
|
|
87
|
+
print(f"Successfully compiled '{args.filename}' -> '{out_path}'")
|
|
88
|
+
|
|
89
|
+
elif args.command == "check":
|
|
90
|
+
from enlang_core.checker import check_file
|
|
91
|
+
ok = check_file(args.filename)
|
|
92
|
+
sys.exit(0 if ok else 1)
|
|
93
|
+
|
|
94
|
+
elif args.command == "debug":
|
|
95
|
+
from enlang_core.debugger import debug_file
|
|
96
|
+
debug_file(args.filename)
|
|
97
|
+
sys.exit(0)
|
|
98
|
+
|
|
99
|
+
elif args.command in ["repl", "shell"]:
|
|
100
|
+
start_repl(interpreter)
|
|
101
|
+
|
|
102
|
+
elif args.command == "version":
|
|
103
|
+
print(f"EnLang Version {__version__} (NLP Engine & Multi-Extension Support: .enlg, .enlgd, .enlgs, .enlgdb)")
|
|
104
|
+
|
|
105
|
+
else:
|
|
106
|
+
# Default behavior if file passed directly without subcommand
|
|
107
|
+
if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
|
|
108
|
+
success, stdout, stderr, _ = interpreter.run_file(sys.argv[1])
|
|
109
|
+
if stdout:
|
|
110
|
+
print(stdout, end="")
|
|
111
|
+
if stderr:
|
|
112
|
+
print(stderr, file=sys.stderr, end="")
|
|
113
|
+
sys.exit(0 if success else 1)
|
|
114
|
+
else:
|
|
115
|
+
parser.print_help()
|
|
116
|
+
|
|
117
|
+
def start_repl(interpreter: EnLangInterpreter):
|
|
118
|
+
"""Starts the interactive EnLang English Shell with NLP intent parsing."""
|
|
119
|
+
print(f"EnLang Interactive NLP English Shell v{__version__}")
|
|
120
|
+
print("Supports natural English phrasing & NLP commands. Type 'exit' to quit.\n")
|
|
121
|
+
|
|
122
|
+
repl_globals = {}
|
|
123
|
+
while True:
|
|
124
|
+
try:
|
|
125
|
+
line = input("enl> ")
|
|
126
|
+
if line.strip().lower() in ["exit", "quit", "exit()"]:
|
|
127
|
+
print("Bye!")
|
|
128
|
+
break
|
|
129
|
+
if not line.strip():
|
|
130
|
+
continue
|
|
131
|
+
|
|
132
|
+
success, stdout, stderr, py_code = interpreter.run_code(line, custom_globals=repl_globals)
|
|
133
|
+
if stdout:
|
|
134
|
+
print(stdout, end="")
|
|
135
|
+
if stderr:
|
|
136
|
+
print(f"[Error] {stderr}", end="")
|
|
137
|
+
except (KeyboardInterrupt, EOFError):
|
|
138
|
+
print("\nExiting EnLang shell. Bye!")
|
|
139
|
+
break
|
|
140
|
+
|
|
141
|
+
if __name__ == "__main__":
|
|
142
|
+
main()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EnLang Core Package
|
|
3
|
+
Natural English Programming Language Transpiler, Interpreter & Domain Helpers.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .transpiler import EnLangTranspiler
|
|
7
|
+
from .interpreter import EnLangInterpreter
|
|
8
|
+
|
|
9
|
+
__version__ = "1.0.0"
|
|
10
|
+
__all__ = ["EnLangTranspiler", "EnLangInterpreter"]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""
|
|
2
|
+
EnLang Syntax Checker & Linter
|
|
3
|
+
==============================
|
|
4
|
+
Performs static analysis and linting on EnLang source files (.enlg, .enlgf, .enlgd, .enlgs, .enlgdb)
|
|
5
|
+
without executing them.
|
|
6
|
+
|
|
7
|
+
Checks:
|
|
8
|
+
1. Indentation & Block boundary formatting (4-space rule)
|
|
9
|
+
2. Trailing colon (:) on block headers
|
|
10
|
+
3. Matched block closures (end match, end interface)
|
|
11
|
+
4. Unclosed string literals
|
|
12
|
+
5. Unsupported or ambiguous phrase warnings (e.g., 'is bigger than')
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import re
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
class Diagnostic:
|
|
20
|
+
def __init__(self, line_no: int, message: str, level: str = "ERROR", suggestion: str = ""):
|
|
21
|
+
self.line_no = line_no
|
|
22
|
+
self.message = message
|
|
23
|
+
self.level = level # ERROR, WARNING, INFO
|
|
24
|
+
self.suggestion = suggestion
|
|
25
|
+
|
|
26
|
+
def __str__(self):
|
|
27
|
+
prefix = f"[{self.level}] Line {self.line_no}: {self.message}"
|
|
28
|
+
if self.suggestion:
|
|
29
|
+
prefix += f" (Suggestion: {self.suggestion})"
|
|
30
|
+
return prefix
|
|
31
|
+
|
|
32
|
+
def _check_line(idx: int, raw_line: str, line: str, diagnostics: list):
|
|
33
|
+
lstripped = raw_line.lstrip()
|
|
34
|
+
indent_len = len(raw_line) - len(lstripped)
|
|
35
|
+
|
|
36
|
+
# Check 1: Indentation (Must be multiple of 4 spaces if indented)
|
|
37
|
+
if indent_len % 4 != 0:
|
|
38
|
+
diagnostics.append(Diagnostic(
|
|
39
|
+
idx,
|
|
40
|
+
f"Indentation is {indent_len} spaces. EnLang requires multiples of 4 spaces.",
|
|
41
|
+
level="WARNING",
|
|
42
|
+
suggestion=f"Adjust indentation to {(indent_len // 4 + 1) * 4} spaces"
|
|
43
|
+
))
|
|
44
|
+
|
|
45
|
+
# Check 2: Unclosed string literal
|
|
46
|
+
double_quotes = line.count('"') - line.count('\\"')
|
|
47
|
+
single_quotes = line.count("'") - line.count("\\'")
|
|
48
|
+
if double_quotes % 2 != 0 or single_quotes % 2 != 0:
|
|
49
|
+
diagnostics.append(Diagnostic(
|
|
50
|
+
idx,
|
|
51
|
+
"Unclosed string literal detected.",
|
|
52
|
+
level="ERROR",
|
|
53
|
+
suggestion="Ensure string quotes are closed properly"
|
|
54
|
+
))
|
|
55
|
+
|
|
56
|
+
# Check 3: Block header missing trailing colon
|
|
57
|
+
block_headers = (
|
|
58
|
+
r'^\s*(?:if|otherwise\s+if|elif|else|repeat|for|while|until|function|func|action|task|procedure|process|class|interface|match|switch|try|except|finally|style|on\s+screen|animate)\b'
|
|
59
|
+
)
|
|
60
|
+
if re.search(block_headers, raw_line, re.IGNORECASE):
|
|
61
|
+
if not line.endswith(":") and not re.search(r'\b(?:then|do)\b', line, re.IGNORECASE):
|
|
62
|
+
diagnostics.append(Diagnostic(
|
|
63
|
+
idx,
|
|
64
|
+
"Block header missing trailing colon ':'.",
|
|
65
|
+
level="ERROR",
|
|
66
|
+
suggestion="Add a colon ':' at the end of the line"
|
|
67
|
+
))
|
|
68
|
+
|
|
69
|
+
# Check 4: Unsupported English phrases
|
|
70
|
+
invalid_phrases = [
|
|
71
|
+
(r'\bis bigger than\b', "Use 'is greater than' instead of 'is bigger than'"),
|
|
72
|
+
(r'\bis same as\b', "Use 'is equal to' instead of 'is same as'"),
|
|
73
|
+
(r'\bassign\b.+\bto\b', "Use 'set <var> to <val>' or 'store <val> in <var>'"),
|
|
74
|
+
(r'\bput\b.+\binside\b', "Use 'store <val> in <var>'"),
|
|
75
|
+
]
|
|
76
|
+
for pattern, sugg in invalid_phrases:
|
|
77
|
+
if re.search(pattern, line, re.IGNORECASE):
|
|
78
|
+
diagnostics.append(Diagnostic(
|
|
79
|
+
idx,
|
|
80
|
+
"Unsupported natural phrase detected in statement.",
|
|
81
|
+
level="ERROR",
|
|
82
|
+
suggestion=sugg
|
|
83
|
+
))
|
|
84
|
+
|
|
85
|
+
def check_syntax(code: str, file_path: str = "main.enlg") -> list:
|
|
86
|
+
diagnostics = []
|
|
87
|
+
lines = code.splitlines()
|
|
88
|
+
|
|
89
|
+
in_match = False
|
|
90
|
+
in_interface = False
|
|
91
|
+
|
|
92
|
+
for idx, raw_line in enumerate(lines, start=1):
|
|
93
|
+
line = raw_line.strip()
|
|
94
|
+
if not line or line.startswith("#") or line.startswith("//"):
|
|
95
|
+
continue
|
|
96
|
+
|
|
97
|
+
_check_line(idx, raw_line, line, diagnostics)
|
|
98
|
+
|
|
99
|
+
# Block tracking
|
|
100
|
+
if re.match(r'^\s*(?:match|switch)\b', line, re.IGNORECASE):
|
|
101
|
+
in_match = True
|
|
102
|
+
elif re.match(r'^\s*end\s+match\b', line, re.IGNORECASE):
|
|
103
|
+
in_match = False
|
|
104
|
+
|
|
105
|
+
if re.match(r'^\s*interface\b', line, re.IGNORECASE):
|
|
106
|
+
in_interface = True
|
|
107
|
+
elif re.match(r'^\s*end\s+interface\b', line, re.IGNORECASE):
|
|
108
|
+
in_interface = False
|
|
109
|
+
|
|
110
|
+
if in_match:
|
|
111
|
+
diagnostics.append(Diagnostic(
|
|
112
|
+
len(lines),
|
|
113
|
+
f"Unclosed 'match' block in {file_path}. Missing 'end match'.",
|
|
114
|
+
level="ERROR",
|
|
115
|
+
suggestion="Add 'end match' at the end of the match block"
|
|
116
|
+
))
|
|
117
|
+
|
|
118
|
+
if in_interface:
|
|
119
|
+
diagnostics.append(Diagnostic(
|
|
120
|
+
len(lines),
|
|
121
|
+
f"Unclosed 'interface' block in {file_path}. Missing 'end interface'.",
|
|
122
|
+
level="ERROR",
|
|
123
|
+
suggestion="Add 'end interface' at the end of the interface block"
|
|
124
|
+
))
|
|
125
|
+
|
|
126
|
+
return diagnostics
|
|
127
|
+
|
|
128
|
+
def check_file(file_path: str):
|
|
129
|
+
if not os.path.exists(file_path):
|
|
130
|
+
print(f"[ERROR] File '{file_path}' not found.")
|
|
131
|
+
return False
|
|
132
|
+
|
|
133
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
134
|
+
code = f.read()
|
|
135
|
+
|
|
136
|
+
diagnostics = check_syntax(code, file_path)
|
|
137
|
+
|
|
138
|
+
print("=" * 65)
|
|
139
|
+
print(f" EnLang Syntax Checker & Linter — {file_path}")
|
|
140
|
+
print("=" * 65)
|
|
141
|
+
|
|
142
|
+
if not diagnostics:
|
|
143
|
+
print(" [PASS] No syntax errors or warnings found! Clean file.")
|
|
144
|
+
print("=" * 65)
|
|
145
|
+
return True
|
|
146
|
+
|
|
147
|
+
errors = [d for d in diagnostics if d.level == "ERROR"]
|
|
148
|
+
warnings = [d for d in diagnostics if d.level == "WARNING"]
|
|
149
|
+
|
|
150
|
+
for d in diagnostics:
|
|
151
|
+
print(f" {d}")
|
|
152
|
+
|
|
153
|
+
print("=" * 65)
|
|
154
|
+
print(f" Result: {len(errors)} Error(s), {len(warnings)} Warning(s)")
|
|
155
|
+
print("=" * 65)
|
|
156
|
+
return len(errors) == 0
|
|
157
|
+
|
|
158
|
+
if __name__ == "__main__":
|
|
159
|
+
if len(sys.argv) > 1:
|
|
160
|
+
check_file(sys.argv[1])
|
|
161
|
+
else:
|
|
162
|
+
print("Usage: python -m enlang_core.checker <filename.enlg>")
|