enlang 2.0.0__py3-none-any.whl

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.
@@ -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
+ [![Version](https://img.shields.io/badge/version-2.0.0--Enterprise-indigo.svg)](https://github.com/Aero99op/enlang)
21
+ [![License](https://img.shields.io/badge/license-Proprietary%20%2F%20Enterprise-blue.svg)](LICENSE)
22
+ [![Tests](https://img.shields.io/badge/tests-154%2F154%20PASS-success.svg)](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,18 @@
1
+ enlang.py,sha256=DJTRbOuaLB4e6tfWcy8D482rARgQ0dMHT4OQqtJeUlk,5380
2
+ gui_installer.py,sha256=xHTbeEnWq8Smnu-ltq_pLiODNkfjIfZfAG0cxxiXH1M,11380
3
+ installer.py,sha256=LpCiXbtAv2wsJ4Y_-04eStCS9ayPLeWMcLQ65lFXQAs,5290
4
+ enlang_core/__init__.py,sha256=dYQ8sIdRcnRUgghwKtjYsna4U-0r1npQttM9RO4U6OI,267
5
+ enlang_core/checker.py,sha256=ZqQPCzaIGRZJbenYzby1hWHhuQIkFa48dDuUxf2tf4w,5653
6
+ enlang_core/cli.py,sha256=0SqgKFsKoXT0TJGCIdfF3h-mOFRKs0f4SjacbZ4him0,5762
7
+ enlang_core/debugger.py,sha256=oPQEvufDGD-zsYf6c5_aqc1FGJbqBwR-QEX7mnywHe8,5779
8
+ enlang_core/epm.py,sha256=26hN0GlowSidu8mCUka7-euR-Hd1BtVBVgkqHbowTYA,4884
9
+ enlang_core/grammar.py,sha256=eYWHq8L6bdRz9ZOfv2cdojKQ8U1LzbUEaCqJ9PfxWuU,58641
10
+ enlang_core/interpreter.py,sha256=ES8RVXSQW0hbLr1pfWmWaRkk8D3ObKgeDHxUyD0qGeM,1910
11
+ enlang_core/nlp_engine.py,sha256=mHWFtBKU_mbMarYrNJDqe2QMLyZq4kUwuqiH8U8V6qI,4879
12
+ enlang_core/transpiler.py,sha256=fVw-BRdmetTZydpw8MB_sYO22SaPQH6YJir243XBMTM,40573
13
+ enlang_core/web_server.py,sha256=L4HyhkSkYsrJJKBe65itAhsuRCoSsNhWwbjoB6ppXrs,9269
14
+ enlang-2.0.0.dist-info/METADATA,sha256=Jm4dQ19azLcz72rprnGtQo14qN_chiZ99B2PfG--tJg,3591
15
+ enlang-2.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
16
+ enlang-2.0.0.dist-info/entry_points.txt,sha256=MLXJeS95E76TSCZcV1amZsz5-2ZkO-eG_hEjr5xtWz4,75
17
+ enlang-2.0.0.dist-info/top_level.txt,sha256=cztgUOkeIwT6vw4FRFBW35mrhEUKW0jn6MEbH8T8n_M,43
18
+ enlang-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ enlang = enlang_core.cli:main
3
+ epm = enlang_core.epm:main
@@ -0,0 +1,4 @@
1
+ enlang
2
+ enlang_core
3
+ gui_installer
4
+ installer
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"]
enlang_core/checker.py ADDED
@@ -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>")
enlang_core/cli.py ADDED
@@ -0,0 +1,181 @@
1
+ """
2
+ EnLang Main CLI Interface
3
+ =========================
4
+ Command-line driver for running, building, and serving EnLang applications.
5
+
6
+ Commands:
7
+ enlang run <file> Compiles & executes an EnLang file (.enlg, .enlgf, .enlgd, .enlgs, .enlgdb)
8
+ enlang build <file> Transpiles EnLang source to native code file
9
+ enlang server [--port P] Launches zero-config EnLang HTTP Web Server
10
+ enlang version Displays installed EnLang version
11
+ enlang help Shows usage instructions
12
+ """
13
+
14
+ import sys
15
+ import os
16
+ import argparse
17
+
18
+ VERSION = "2.0.0 — Enterprise Specification Edition"
19
+
20
+ def main():
21
+ if len(sys.argv) < 2:
22
+ print_help()
23
+ sys.exit(0)
24
+
25
+ cmd = sys.argv[1].lower()
26
+
27
+ if cmd in ("--version", "-v", "version"):
28
+ print(f"EnLang Compiler Version {VERSION}")
29
+ print("Author: Spandan Prayas Patra")
30
+ sys.exit(0)
31
+
32
+ if cmd in ("--help", "-h", "help"):
33
+ print_help()
34
+ sys.exit(0)
35
+
36
+ if cmd == "run":
37
+ if len(sys.argv) < 3:
38
+ print("Error: Please specify a file to run.")
39
+ print("Usage: enlang run <filename.enlg|enlgf|enlgd|enlgs|enlgdb>")
40
+ sys.exit(1)
41
+ file_path = sys.argv[2]
42
+ run_file(file_path)
43
+
44
+ elif cmd == "build":
45
+ if len(sys.argv) < 3:
46
+ print("Error: Please specify a file to build.")
47
+ print("Usage: enlang build <filename.enlg|enlgf|enlgd|enlgs|enlgdb>")
48
+ sys.exit(1)
49
+ file_path = sys.argv[2]
50
+ build_file(file_path)
51
+
52
+ elif cmd in ("check", "lint"):
53
+ if len(sys.argv) < 3:
54
+ print("Error: Please specify a file to check.")
55
+ print("Usage: enlang check <filename.enlg>")
56
+ sys.exit(1)
57
+ file_path = sys.argv[2]
58
+ try:
59
+ from .checker import check_file
60
+ except ImportError:
61
+ from enlang_core.checker import check_file
62
+ check_file(file_path)
63
+
64
+ elif cmd in ("debug", "dbg"):
65
+ if len(sys.argv) < 3:
66
+ print("Error: Please specify a file to debug.")
67
+ print("Usage: enlang debug <filename.enlg>")
68
+ sys.exit(1)
69
+ file_path = sys.argv[2]
70
+ try:
71
+ from .debugger import debug_file
72
+ except ImportError:
73
+ from enlang_core.debugger import debug_file
74
+ debug_file(file_path)
75
+
76
+ elif cmd == "server":
77
+ port = 8000
78
+ if "--port" in sys.argv:
79
+ try:
80
+ idx = sys.argv.index("--port")
81
+ port = int(sys.argv[idx + 1])
82
+ except (ValueError, IndexError):
83
+ print("Warning: Invalid port specified, using default port 8000.")
84
+
85
+ print(f"[INFO] Launching EnLang Web Server on port {port}...")
86
+ try:
87
+ from .web_server import start_enlang_server
88
+ start_enlang_server(port)
89
+ except ImportError:
90
+ from enlang_core.web_server import start_enlang_server
91
+ start_enlang_server(port)
92
+
93
+ else:
94
+ # Fallback: Treat sys.argv[1] as a file to run directly (e.g. enlang app.enlg)
95
+ file_path = sys.argv[1]
96
+ if os.path.exists(file_path):
97
+ run_file(file_path)
98
+ else:
99
+ print(f"Unknown command or file not found: {cmd}")
100
+ print_help()
101
+ sys.exit(1)
102
+
103
+ def run_file(file_path: str):
104
+ if not os.path.exists(file_path):
105
+ print(f"Error: File '{file_path}' not found.")
106
+ sys.exit(1)
107
+
108
+ try:
109
+ from .interpreter import EnLangInterpreter
110
+ except ImportError:
111
+ from enlang_core.interpreter import EnLangInterpreter
112
+
113
+ interp = EnLangInterpreter()
114
+ with open(file_path, "r", encoding="utf-8") as f:
115
+ code = f.read()
116
+
117
+ ok, stdout, stderr, _ = interp.run_code(code, file_path=file_path)
118
+ if stdout.strip():
119
+ print(stdout)
120
+ if not ok:
121
+ print(f"[ERROR] EnLang Runtime Exception:\n{stderr}", file=sys.stderr)
122
+ sys.exit(1)
123
+
124
+ def build_file(file_path: str):
125
+ if not os.path.exists(file_path):
126
+ print(f"Error: File '{file_path}' not found.")
127
+ sys.exit(1)
128
+
129
+ try:
130
+ from .transpiler import EnLangTranspiler
131
+ except ImportError:
132
+ from enlang_core.transpiler import EnLangTranspiler
133
+
134
+ t = EnLangTranspiler()
135
+ with open(file_path, "r", encoding="utf-8") as f:
136
+ code = f.read()
137
+
138
+ transpiled = t.transpile(code, file_path=file_path)
139
+
140
+ ext = os.path.splitext(file_path)[1].lower()
141
+ target_ext_map = {
142
+ ".enlg": ".py",
143
+ ".enlgf": ".html",
144
+ ".enlgd": ".css",
145
+ ".enlgs": ".js",
146
+ ".enlgdb": ".sql"
147
+ }
148
+ target_ext = target_ext_map.get(ext, ".py")
149
+ out_file = os.path.splitext(file_path)[0] + target_ext
150
+
151
+ with open(out_file, "w", encoding="utf-8") as f:
152
+ f.write(transpiled)
153
+
154
+ print(f"[SUCCESS] Transpiled '{file_path}' -> '{out_file}'")
155
+
156
+ def print_help():
157
+ print("""
158
+ EnLang — Universal Natural English Compiler CLI (v2.0)
159
+
160
+ USAGE:
161
+ enlang <command> [options]
162
+
163
+ COMMANDS:
164
+ run <file> Compiles & executes an EnLang file (.enlg, .enlgf, .enlgd, .enlgs, .enlgdb)
165
+ build <file> Transpiles EnLang source file into native target code file (.py, .html, .css, .js, .sql)
166
+ check <file> Performs static analysis and linting without execution
167
+ debug <file> Launches interactive step-by-step debugger with live variable inspection
168
+ server [--port N] Launches EnLang HTTP Web Server on specified port (default: 8000)
169
+ version Displays installed compiler version & author info
170
+ help Shows this usage manual
171
+
172
+ EXAMPLES:
173
+ enlang run app.enlg
174
+ enlang check app.enlg
175
+ enlang debug app.enlg
176
+ enlang build index.enlgf
177
+ enlang server --port 8080
178
+ """)
179
+
180
+ if __name__ == "__main__":
181
+ main()