radon-lang 1.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.
- radon_lang-1.0.0/PKG-INFO +25 -0
- radon_lang-1.0.0/README.md +17 -0
- radon_lang-1.0.0/pyproject.toml +19 -0
- radon_lang-1.0.0/radon/__init__.py +0 -0
- radon_lang-1.0.0/radon/ast.py +117 -0
- radon_lang-1.0.0/radon/cli.py +74 -0
- radon_lang-1.0.0/radon/errors.py +18 -0
- radon_lang-1.0.0/radon/interpreter.py +600 -0
- radon_lang-1.0.0/radon/lexer.py +348 -0
- radon_lang-1.0.0/radon/parser.py +800 -0
- radon_lang-1.0.0/radon_lang.egg-info/PKG-INFO +25 -0
- radon_lang-1.0.0/radon_lang.egg-info/SOURCES.txt +14 -0
- radon_lang-1.0.0/radon_lang.egg-info/dependency_links.txt +1 -0
- radon_lang-1.0.0/radon_lang.egg-info/entry_points.txt +2 -0
- radon_lang-1.0.0/radon_lang.egg-info/top_level.txt +1 -0
- radon_lang-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: radon-lang
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: RADON programming language
|
|
5
|
+
Author: Muhammed Aflah
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# RADON
|
|
10
|
+
|
|
11
|
+
RADON is a beginner-friendly programming language with readable syntax.
|
|
12
|
+
|
|
13
|
+
## Run
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
radon hello.rd
|
|
17
|
+
|
|
18
|
+
### 3. Build tools install ചെയ്യാം
|
|
19
|
+
|
|
20
|
+
Project root-ൽ:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python3 -m pip install --upgrade build
|
|
24
|
+
|
|
25
|
+
python3 -m build
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# RADON
|
|
2
|
+
|
|
3
|
+
RADON is a beginner-friendly programming language with readable syntax.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
radon hello.rd
|
|
9
|
+
|
|
10
|
+
### 3. Build tools install ചെയ്യാം
|
|
11
|
+
|
|
12
|
+
Project root-ൽ:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
python3 -m pip install --upgrade build
|
|
16
|
+
|
|
17
|
+
python3 -m build
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "radon-lang"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "RADON programming language"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Muhammed Aflah" }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
radon = "radon.cli:main"
|
|
17
|
+
|
|
18
|
+
[tool.setuptools]
|
|
19
|
+
packages = ["radon"]
|
|
File without changes
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
class NumberNode:
|
|
2
|
+
def __init__(self, value):
|
|
3
|
+
self.value = value
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StringNode:
|
|
7
|
+
def __init__(self, value):
|
|
8
|
+
self.value = value
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BooleanNode:
|
|
12
|
+
def __init__(self, value):
|
|
13
|
+
self.value = value
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NothingNode:
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.value = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class VariableNode:
|
|
22
|
+
def __init__(self, name):
|
|
23
|
+
self.name = name
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AssignmentNode:
|
|
27
|
+
def __init__(self, name, value):
|
|
28
|
+
self.name = name
|
|
29
|
+
self.value = value
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SayNode:
|
|
33
|
+
def __init__(self, value):
|
|
34
|
+
self.value = value
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AskNode:
|
|
38
|
+
def __init__(self, prompt):
|
|
39
|
+
self.prompt = prompt
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class BinaryNode:
|
|
43
|
+
def __init__(self, left, operator, right):
|
|
44
|
+
self.left = left
|
|
45
|
+
self.operator = operator
|
|
46
|
+
self.right = right
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class UnaryNode:
|
|
50
|
+
def __init__(self, operator, operand):
|
|
51
|
+
self.operator = operator
|
|
52
|
+
self.operand = operand
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class IfNode:
|
|
56
|
+
def __init__(self, condition, body, otherwise_body=None):
|
|
57
|
+
self.condition = condition
|
|
58
|
+
self.body = body
|
|
59
|
+
self.otherwise_body = otherwise_body
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ListNode:
|
|
63
|
+
def __init__(self, elements):
|
|
64
|
+
self.elements = elements
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class IndexNode:
|
|
68
|
+
def __init__(self, collection, index):
|
|
69
|
+
self.collection = collection
|
|
70
|
+
self.index = index
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ObjectNode:
|
|
74
|
+
def __init__(self, properties):
|
|
75
|
+
self.properties = properties
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class PropertyNode:
|
|
79
|
+
def __init__(self, object_node, property_name):
|
|
80
|
+
self.object_node = object_node
|
|
81
|
+
self.property_name = property_name
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class EachNode:
|
|
85
|
+
def __init__(self, variable, iterable, body):
|
|
86
|
+
self.variable = variable
|
|
87
|
+
self.iterable = iterable
|
|
88
|
+
self.body = body
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class WhileNode:
|
|
92
|
+
def __init__(self, condition, body):
|
|
93
|
+
self.condition = condition
|
|
94
|
+
self.body = body
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class FunctionNode:
|
|
98
|
+
def __init__(self, name, parameters, body):
|
|
99
|
+
self.name = name
|
|
100
|
+
self.parameters = parameters
|
|
101
|
+
self.body = body
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class CallNode:
|
|
105
|
+
def __init__(self, name, arguments):
|
|
106
|
+
self.name = name
|
|
107
|
+
self.arguments = arguments
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class GiveNode:
|
|
111
|
+
def __init__(self, value):
|
|
112
|
+
self.value = value
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class StringConversionNode:
|
|
116
|
+
def __init__(self, value):
|
|
117
|
+
self.value = value
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from .lexer import tokenize
|
|
4
|
+
from .parser import parse
|
|
5
|
+
from .interpreter import Interpreter
|
|
6
|
+
from .errors import RadonError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
VERSION = "1.0.0"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
# Version
|
|
14
|
+
if len(sys.argv) == 2 and sys.argv[1] in ("--version", "-v"):
|
|
15
|
+
print(f"RADON {VERSION}")
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
# Help
|
|
19
|
+
if len(sys.argv) == 2 and sys.argv[1] in ("--help", "-h"):
|
|
20
|
+
print("RADON Programming Language")
|
|
21
|
+
print()
|
|
22
|
+
print("Usage:")
|
|
23
|
+
print(" radon <file.rd>")
|
|
24
|
+
print()
|
|
25
|
+
print("Options:")
|
|
26
|
+
print(" -v, --version Show RADON version")
|
|
27
|
+
print(" -h, --help Show this help message")
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
# File argument check
|
|
31
|
+
if len(sys.argv) != 2:
|
|
32
|
+
print("Usage: radon <file.rd>")
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
filename = sys.argv[1]
|
|
36
|
+
|
|
37
|
+
# RADON file extension check
|
|
38
|
+
if not filename.endswith(".rd"):
|
|
39
|
+
print("RADON files must use the .rd extension")
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
# Read RADON source file
|
|
44
|
+
with open(filename, "r", encoding="utf-8") as file:
|
|
45
|
+
source = file.read()
|
|
46
|
+
|
|
47
|
+
# Lexer
|
|
48
|
+
tokens = tokenize(source)
|
|
49
|
+
|
|
50
|
+
# Parser
|
|
51
|
+
nodes = parse(tokens)
|
|
52
|
+
|
|
53
|
+
# Interpreter
|
|
54
|
+
interpreter = Interpreter()
|
|
55
|
+
interpreter.run(nodes)
|
|
56
|
+
|
|
57
|
+
except FileNotFoundError:
|
|
58
|
+
print(f"RADON ERROR: File not found: {filename}")
|
|
59
|
+
|
|
60
|
+
except PermissionError:
|
|
61
|
+
print(f"RADON ERROR: Permission denied: {filename}")
|
|
62
|
+
|
|
63
|
+
except RadonError as error:
|
|
64
|
+
print(f"RADON ERROR: {error}")
|
|
65
|
+
|
|
66
|
+
except KeyboardInterrupt:
|
|
67
|
+
print("\nRADON ERROR: Program interrupted")
|
|
68
|
+
|
|
69
|
+
except Exception as error:
|
|
70
|
+
print(f"RADON ERROR: Unexpected error: {error}")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
main()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class RadonError(Exception):
|
|
2
|
+
"""Base RADON error."""
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LexerError(RadonError):
|
|
7
|
+
"""Lexer error."""
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ParserError(RadonError):
|
|
12
|
+
"""Parser error."""
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class RadonRuntimeError(RadonError):
|
|
17
|
+
"""Runtime error."""
|
|
18
|
+
pass
|