zexus 1.6.2
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.
- package/LICENSE +0 -0
- package/README.md +2513 -0
- package/bin/zexus +2 -0
- package/bin/zpics +2 -0
- package/bin/zpm +2 -0
- package/bin/zx +2 -0
- package/bin/zx-deploy +2 -0
- package/bin/zx-dev +2 -0
- package/bin/zx-run +2 -0
- package/package.json +66 -0
- package/scripts/README.md +24 -0
- package/scripts/postinstall.js +44 -0
- package/shared_config.json +24 -0
- package/src/README.md +1525 -0
- package/src/tests/run_zexus_tests.py +117 -0
- package/src/tests/test_all_phases.zx +346 -0
- package/src/tests/test_blockchain_features.zx +306 -0
- package/src/tests/test_complexity_features.zx +321 -0
- package/src/tests/test_core_integration.py +185 -0
- package/src/tests/test_phase10_ecosystem.zx +177 -0
- package/src/tests/test_phase1_modifiers.zx +87 -0
- package/src/tests/test_phase2_plugins.zx +80 -0
- package/src/tests/test_phase3_security.zx +97 -0
- package/src/tests/test_phase4_vfs.zx +116 -0
- package/src/tests/test_phase5_types.zx +117 -0
- package/src/tests/test_phase6_metaprogramming.zx +125 -0
- package/src/tests/test_phase7_optimization.zx +132 -0
- package/src/tests/test_phase9_advanced_types.zx +157 -0
- package/src/tests/test_security_features.py +419 -0
- package/src/tests/test_security_features.zx +276 -0
- package/src/tests/test_simple_zx.zx +1 -0
- package/src/tests/test_verification_simple.zx +69 -0
- package/src/zexus/__init__.py +28 -0
- package/src/zexus/__main__.py +5 -0
- package/src/zexus/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/advanced_types.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/builtin_modules.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/capability_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/complexity_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/concurrency_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/config.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/dependency_injection.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/ecosystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/environment.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/error_reporter.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/hybrid_orchestrator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/metaprogramming.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_cache.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/object.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/optimization.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/plugin_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/policy_engine.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/stdlib_integration.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/strategy_recovery.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/syntax_validator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/type_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/virtual_filesystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_token.cpython-312.pyc +0 -0
- package/src/zexus/advanced_types.py +401 -0
- package/src/zexus/blockchain/__init__.py +40 -0
- package/src/zexus/blockchain/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/crypto.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/ledger.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/transaction.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/crypto.py +463 -0
- package/src/zexus/blockchain/ledger.py +255 -0
- package/src/zexus/blockchain/transaction.py +267 -0
- package/src/zexus/builtin_modules.py +284 -0
- package/src/zexus/builtin_plugins.py +317 -0
- package/src/zexus/capability_system.py +372 -0
- package/src/zexus/cli/__init__.py +2 -0
- package/src/zexus/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/cli/__pycache__/main.cpython-312.pyc +0 -0
- package/src/zexus/cli/main.py +707 -0
- package/src/zexus/cli/zpm.py +203 -0
- package/src/zexus/compare_interpreter_compiler.py +146 -0
- package/src/zexus/compiler/__init__.py +169 -0
- package/src/zexus/compiler/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/compiler/bytecode.py +266 -0
- package/src/zexus/compiler/compat_runtime.py +277 -0
- package/src/zexus/compiler/lexer.py +257 -0
- package/src/zexus/compiler/parser.py +779 -0
- package/src/zexus/compiler/semantic.py +118 -0
- package/src/zexus/compiler/zexus_ast.py +454 -0
- package/src/zexus/complexity_system.py +575 -0
- package/src/zexus/concurrency_system.py +493 -0
- package/src/zexus/config.py +201 -0
- package/src/zexus/crypto_bridge.py +19 -0
- package/src/zexus/dependency_injection.py +423 -0
- package/src/zexus/ecosystem.py +434 -0
- package/src/zexus/environment.py +101 -0
- package/src/zexus/environment_manager.py +119 -0
- package/src/zexus/error_reporter.py +314 -0
- package/src/zexus/evaluator/__init__.py +12 -0
- package/src/zexus/evaluator/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/bytecode_compiler.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/core.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/expressions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/functions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/integration.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/statements.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/utils.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/bytecode_compiler.py +700 -0
- package/src/zexus/evaluator/core.py +891 -0
- package/src/zexus/evaluator/expressions.py +827 -0
- package/src/zexus/evaluator/functions.py +3989 -0
- package/src/zexus/evaluator/integration.py +396 -0
- package/src/zexus/evaluator/statements.py +4303 -0
- package/src/zexus/evaluator/utils.py +126 -0
- package/src/zexus/evaluator_original.py +2041 -0
- package/src/zexus/external_bridge.py +16 -0
- package/src/zexus/find_affected_imports.sh +155 -0
- package/src/zexus/hybrid_orchestrator.py +152 -0
- package/src/zexus/input_validation.py +259 -0
- package/src/zexus/lexer.py +571 -0
- package/src/zexus/logging.py +89 -0
- package/src/zexus/lsp/__init__.py +9 -0
- package/src/zexus/lsp/completion_provider.py +207 -0
- package/src/zexus/lsp/definition_provider.py +22 -0
- package/src/zexus/lsp/hover_provider.py +71 -0
- package/src/zexus/lsp/server.py +269 -0
- package/src/zexus/lsp/symbol_provider.py +31 -0
- package/src/zexus/metaprogramming.py +321 -0
- package/src/zexus/module_cache.py +89 -0
- package/src/zexus/module_manager.py +107 -0
- package/src/zexus/object.py +973 -0
- package/src/zexus/optimization.py +424 -0
- package/src/zexus/parser/__init__.py +31 -0
- package/src/zexus/parser/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_context.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_structural.cpython-312.pyc +0 -0
- package/src/zexus/parser/integration.py +86 -0
- package/src/zexus/parser/parser.py +3977 -0
- package/src/zexus/parser/strategy_context.py +7254 -0
- package/src/zexus/parser/strategy_structural.py +1033 -0
- package/src/zexus/persistence.py +391 -0
- package/src/zexus/plugin_system.py +290 -0
- package/src/zexus/policy_engine.py +365 -0
- package/src/zexus/profiler/__init__.py +5 -0
- package/src/zexus/profiler/profiler.py +233 -0
- package/src/zexus/purity_system.py +398 -0
- package/src/zexus/runtime/__init__.py +20 -0
- package/src/zexus/runtime/async_runtime.py +324 -0
- package/src/zexus/search_old_imports.sh +65 -0
- package/src/zexus/security.py +1407 -0
- package/src/zexus/stack_trace.py +233 -0
- package/src/zexus/stdlib/__init__.py +27 -0
- package/src/zexus/stdlib/blockchain.py +341 -0
- package/src/zexus/stdlib/compression.py +167 -0
- package/src/zexus/stdlib/crypto.py +124 -0
- package/src/zexus/stdlib/datetime.py +163 -0
- package/src/zexus/stdlib/db_mongo.py +199 -0
- package/src/zexus/stdlib/db_mysql.py +162 -0
- package/src/zexus/stdlib/db_postgres.py +163 -0
- package/src/zexus/stdlib/db_sqlite.py +133 -0
- package/src/zexus/stdlib/encoding.py +230 -0
- package/src/zexus/stdlib/fs.py +195 -0
- package/src/zexus/stdlib/http.py +219 -0
- package/src/zexus/stdlib/http_server.py +248 -0
- package/src/zexus/stdlib/json_module.py +61 -0
- package/src/zexus/stdlib/math.py +360 -0
- package/src/zexus/stdlib/os_module.py +265 -0
- package/src/zexus/stdlib/regex.py +148 -0
- package/src/zexus/stdlib/sockets.py +253 -0
- package/src/zexus/stdlib/test_framework.zx +208 -0
- package/src/zexus/stdlib/test_runner.zx +119 -0
- package/src/zexus/stdlib_integration.py +341 -0
- package/src/zexus/strategy_recovery.py +256 -0
- package/src/zexus/syntax_validator.py +356 -0
- package/src/zexus/testing/zpics.py +407 -0
- package/src/zexus/testing/zpics_runtime.py +369 -0
- package/src/zexus/type_system.py +374 -0
- package/src/zexus/validation_system.py +569 -0
- package/src/zexus/virtual_filesystem.py +355 -0
- package/src/zexus/vm/__init__.py +8 -0
- package/src/zexus/vm/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/async_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/cache.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/jit.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_manager.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_pool.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/parallel_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/peephole_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/profiler.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_allocator.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/ssa_converter.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/async_optimizer.py +420 -0
- package/src/zexus/vm/bytecode.py +428 -0
- package/src/zexus/vm/bytecode_converter.py +297 -0
- package/src/zexus/vm/cache.py +532 -0
- package/src/zexus/vm/jit.py +720 -0
- package/src/zexus/vm/memory_manager.py +520 -0
- package/src/zexus/vm/memory_pool.py +511 -0
- package/src/zexus/vm/optimizer.py +478 -0
- package/src/zexus/vm/parallel_vm.py +899 -0
- package/src/zexus/vm/peephole_optimizer.py +452 -0
- package/src/zexus/vm/profiler.py +527 -0
- package/src/zexus/vm/register_allocator.py +462 -0
- package/src/zexus/vm/register_vm.py +520 -0
- package/src/zexus/vm/ssa_converter.py +757 -0
- package/src/zexus/vm/vm.py +1392 -0
- package/src/zexus/zexus_ast.py +1782 -0
- package/src/zexus/zexus_token.py +253 -0
- package/src/zexus/zpm/__init__.py +15 -0
- package/src/zexus/zpm/installer.py +116 -0
- package/src/zexus/zpm/package_manager.py +208 -0
- package/src/zexus/zpm/publisher.py +98 -0
- package/src/zexus/zpm/registry.py +110 -0
- package/src/zexus.egg-info/PKG-INFO +2235 -0
- package/src/zexus.egg-info/SOURCES.txt +876 -0
- package/src/zexus.egg-info/dependency_links.txt +1 -0
- package/src/zexus.egg-info/entry_points.txt +3 -0
- package/src/zexus.egg-info/not-zip-safe +1 -0
- package/src/zexus.egg-info/requires.txt +14 -0
- package/src/zexus.egg-info/top_level.txt +2 -0
- package/zexus.json +14 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# src/zexus/compiler/lexer.py
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Enhanced Lexer for Zexus Compiler Phase
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ..zexus_token import *
|
|
8
|
+
|
|
9
|
+
class Lexer:
|
|
10
|
+
def __init__(self, source_code):
|
|
11
|
+
self.input = source_code
|
|
12
|
+
self.position = 0
|
|
13
|
+
self.read_position = 0
|
|
14
|
+
self.ch = ""
|
|
15
|
+
self.line = 1
|
|
16
|
+
self.column = 1
|
|
17
|
+
self.read_char()
|
|
18
|
+
|
|
19
|
+
def read_char(self):
|
|
20
|
+
if self.read_position >= len(self.input):
|
|
21
|
+
self.ch = ""
|
|
22
|
+
else:
|
|
23
|
+
self.ch = self.input[self.read_position]
|
|
24
|
+
|
|
25
|
+
# Update line and column tracking
|
|
26
|
+
if self.ch == '\n':
|
|
27
|
+
self.line += 1
|
|
28
|
+
self.column = 1
|
|
29
|
+
else:
|
|
30
|
+
self.column += 1
|
|
31
|
+
|
|
32
|
+
self.position = self.read_position
|
|
33
|
+
self.read_position += 1
|
|
34
|
+
|
|
35
|
+
def peek_char(self):
|
|
36
|
+
if self.read_position >= len(self.input):
|
|
37
|
+
return ""
|
|
38
|
+
else:
|
|
39
|
+
return self.input[self.read_position]
|
|
40
|
+
|
|
41
|
+
def next_token(self):
|
|
42
|
+
self.skip_whitespace()
|
|
43
|
+
|
|
44
|
+
# Skip single line comments
|
|
45
|
+
if self.ch == '#' and self.peek_char() != '{':
|
|
46
|
+
self.skip_comment()
|
|
47
|
+
return self.next_token()
|
|
48
|
+
|
|
49
|
+
tok = None
|
|
50
|
+
current_line = self.line
|
|
51
|
+
current_column = self.column
|
|
52
|
+
|
|
53
|
+
if self.ch == '=':
|
|
54
|
+
# Support '==' and arrow '=>' for compiler lexer as in interpreter
|
|
55
|
+
if self.peek_char() == '=':
|
|
56
|
+
ch = self.ch
|
|
57
|
+
self.read_char()
|
|
58
|
+
literal = ch + self.ch
|
|
59
|
+
tok = Token(EQ, literal, current_line, current_column)
|
|
60
|
+
elif self.peek_char() == '>':
|
|
61
|
+
ch = self.ch
|
|
62
|
+
self.read_char()
|
|
63
|
+
literal = ch + self.ch
|
|
64
|
+
tok = Token(LAMBDA, literal, current_line, current_column)
|
|
65
|
+
else:
|
|
66
|
+
tok = Token(ASSIGN, self.ch, current_line, current_column)
|
|
67
|
+
elif self.ch == '!':
|
|
68
|
+
if self.peek_char() == '=':
|
|
69
|
+
ch = self.ch
|
|
70
|
+
self.read_char()
|
|
71
|
+
literal = ch + self.ch
|
|
72
|
+
tok = Token(NOT_EQ, literal, current_line, current_column)
|
|
73
|
+
else:
|
|
74
|
+
tok = Token(BANG, self.ch, current_line, current_column)
|
|
75
|
+
elif self.ch == '&':
|
|
76
|
+
if self.peek_char() == '&':
|
|
77
|
+
ch = self.ch
|
|
78
|
+
self.read_char()
|
|
79
|
+
literal = ch + self.ch
|
|
80
|
+
tok = Token(AND, literal, current_line, current_column)
|
|
81
|
+
else:
|
|
82
|
+
tok = Token(ILLEGAL, self.ch, current_line, current_column)
|
|
83
|
+
elif self.ch == '|':
|
|
84
|
+
if self.peek_char() == '|':
|
|
85
|
+
ch = self.ch
|
|
86
|
+
self.read_char()
|
|
87
|
+
literal = ch + self.ch
|
|
88
|
+
tok = Token(OR, literal, current_line, current_column)
|
|
89
|
+
else:
|
|
90
|
+
tok = Token(ILLEGAL, self.ch, current_line, current_column)
|
|
91
|
+
elif self.ch == '<':
|
|
92
|
+
if self.peek_char() == '=':
|
|
93
|
+
ch = self.ch
|
|
94
|
+
self.read_char()
|
|
95
|
+
literal = ch + self.ch
|
|
96
|
+
tok = Token(LTE, literal, current_line, current_column)
|
|
97
|
+
else:
|
|
98
|
+
tok = Token(LT, self.ch, current_line, current_column)
|
|
99
|
+
elif self.ch == '>':
|
|
100
|
+
if self.peek_char() == '=':
|
|
101
|
+
ch = self.ch
|
|
102
|
+
self.read_char()
|
|
103
|
+
literal = ch + self.ch
|
|
104
|
+
tok = Token(GTE, literal, current_line, current_column)
|
|
105
|
+
else:
|
|
106
|
+
tok = Token(GT, self.ch, current_line, current_column)
|
|
107
|
+
elif self.ch == '"':
|
|
108
|
+
string_literal = self.read_string()
|
|
109
|
+
tok = Token(STRING, string_literal, current_line, current_column)
|
|
110
|
+
elif self.ch == '[':
|
|
111
|
+
tok = Token(LBRACKET, self.ch, current_line, current_column)
|
|
112
|
+
elif self.ch == ']':
|
|
113
|
+
tok = Token(RBRACKET, self.ch, current_line, current_column)
|
|
114
|
+
elif self.ch == '(':
|
|
115
|
+
tok = Token(LPAREN, self.ch, current_line, current_column)
|
|
116
|
+
elif self.ch == ')':
|
|
117
|
+
tok = Token(RPAREN, self.ch, current_line, current_column)
|
|
118
|
+
elif self.ch == '{':
|
|
119
|
+
tok = Token(LBRACE, self.ch, current_line, current_column)
|
|
120
|
+
elif self.ch == '}':
|
|
121
|
+
tok = Token(RBRACE, self.ch, current_line, current_column)
|
|
122
|
+
elif self.ch == ',':
|
|
123
|
+
tok = Token(COMMA, self.ch, current_line, current_column)
|
|
124
|
+
elif self.ch == ';':
|
|
125
|
+
tok = Token(SEMICOLON, self.ch, current_line, current_column)
|
|
126
|
+
elif self.ch == ':':
|
|
127
|
+
tok = Token(COLON, self.ch, current_line, current_column)
|
|
128
|
+
elif self.ch == '+':
|
|
129
|
+
tok = Token(PLUS, self.ch, current_line, current_column)
|
|
130
|
+
elif self.ch == '-':
|
|
131
|
+
tok = Token(MINUS, self.ch, current_line, current_column)
|
|
132
|
+
elif self.ch == '*':
|
|
133
|
+
tok = Token(STAR, self.ch, current_line, current_column)
|
|
134
|
+
elif self.ch == '/':
|
|
135
|
+
tok = Token(SLASH, self.ch, current_line, current_column)
|
|
136
|
+
elif self.ch == '%':
|
|
137
|
+
tok = Token(MOD, self.ch, current_line, current_column)
|
|
138
|
+
elif self.ch == '.':
|
|
139
|
+
tok = Token(DOT, self.ch, current_line, current_column)
|
|
140
|
+
elif self.ch == "":
|
|
141
|
+
tok = Token(EOF, "", current_line, current_column)
|
|
142
|
+
else:
|
|
143
|
+
if self.is_letter(self.ch):
|
|
144
|
+
literal = self.read_identifier()
|
|
145
|
+
token_type = self.lookup_ident(literal)
|
|
146
|
+
tok = Token(token_type, literal, current_line, current_column)
|
|
147
|
+
return tok
|
|
148
|
+
elif self.is_digit(self.ch):
|
|
149
|
+
num_literal = self.read_number()
|
|
150
|
+
if '.' in num_literal:
|
|
151
|
+
tok = Token(FLOAT, num_literal, current_line, current_column)
|
|
152
|
+
else:
|
|
153
|
+
tok = Token(INT, num_literal, current_line, current_column)
|
|
154
|
+
return tok
|
|
155
|
+
else:
|
|
156
|
+
tok = Token(ILLEGAL, self.ch, current_line, current_column)
|
|
157
|
+
|
|
158
|
+
self.read_char()
|
|
159
|
+
return tok
|
|
160
|
+
|
|
161
|
+
def skip_comment(self):
|
|
162
|
+
while self.ch != '\n' and self.ch != "":
|
|
163
|
+
self.read_char()
|
|
164
|
+
self.skip_whitespace()
|
|
165
|
+
|
|
166
|
+
def read_string(self):
|
|
167
|
+
start_position = self.position + 1
|
|
168
|
+
while True:
|
|
169
|
+
self.read_char()
|
|
170
|
+
if self.ch == '"' or self.ch == "":
|
|
171
|
+
break
|
|
172
|
+
return self.input[start_position:self.position]
|
|
173
|
+
|
|
174
|
+
def read_identifier(self):
|
|
175
|
+
start_position = self.position
|
|
176
|
+
while self.is_letter(self.ch) or self.is_digit(self.ch):
|
|
177
|
+
self.read_char()
|
|
178
|
+
return self.input[start_position:self.position]
|
|
179
|
+
|
|
180
|
+
def read_number(self):
|
|
181
|
+
start_position = self.position
|
|
182
|
+
is_float = False
|
|
183
|
+
|
|
184
|
+
# Read integer part
|
|
185
|
+
while self.is_digit(self.ch):
|
|
186
|
+
self.read_char()
|
|
187
|
+
|
|
188
|
+
# Check for decimal point
|
|
189
|
+
if self.ch == '.':
|
|
190
|
+
is_float = True
|
|
191
|
+
self.read_char()
|
|
192
|
+
# Read fractional part
|
|
193
|
+
while self.is_digit(self.ch):
|
|
194
|
+
self.read_char()
|
|
195
|
+
|
|
196
|
+
number_str = self.input[start_position:self.position]
|
|
197
|
+
return number_str
|
|
198
|
+
|
|
199
|
+
def lookup_ident(self, ident):
|
|
200
|
+
keywords = {
|
|
201
|
+
"let": LET,
|
|
202
|
+
"print": PRINT,
|
|
203
|
+
"if": IF,
|
|
204
|
+
"else": ELSE,
|
|
205
|
+
"true": TRUE,
|
|
206
|
+
"false": FALSE,
|
|
207
|
+
"return": RETURN,
|
|
208
|
+
"for": FOR,
|
|
209
|
+
"each": EACH,
|
|
210
|
+
"in": IN,
|
|
211
|
+
"action": ACTION,
|
|
212
|
+
"async": ASYNC,
|
|
213
|
+
"await": AWAIT,
|
|
214
|
+
"enum": ENUM,
|
|
215
|
+
"protocol": PROTOCOL,
|
|
216
|
+
"interface": INTERFACE,
|
|
217
|
+
"capability": CAPABILITY,
|
|
218
|
+
"grant": GRANT,
|
|
219
|
+
"revoke": REVOKE,
|
|
220
|
+
"module": MODULE,
|
|
221
|
+
"package": PACKAGE,
|
|
222
|
+
"using": USING,
|
|
223
|
+
"type_alias": TYPE_ALIAS,
|
|
224
|
+
"while": WHILE,
|
|
225
|
+
"use": USE,
|
|
226
|
+
"exactly": EXACTLY,
|
|
227
|
+
"embedded": EMBEDDED,
|
|
228
|
+
"export": EXPORT,
|
|
229
|
+
"lambda": LAMBDA,
|
|
230
|
+
"debug": DEBUG,
|
|
231
|
+
"try": TRY,
|
|
232
|
+
"catch": CATCH,
|
|
233
|
+
"external": EXTERNAL,
|
|
234
|
+
"from": FROM,
|
|
235
|
+
# Blockchain & Smart Contract keywords
|
|
236
|
+
"ledger": LEDGER,
|
|
237
|
+
"state": STATE,
|
|
238
|
+
"tx": TX,
|
|
239
|
+
"revert": REVERT,
|
|
240
|
+
"hash": HASH,
|
|
241
|
+
"signature": SIGNATURE,
|
|
242
|
+
"verify_sig": VERIFY_SIG,
|
|
243
|
+
"limit": LIMIT,
|
|
244
|
+
"gas": GAS,
|
|
245
|
+
"require": REQUIRE,
|
|
246
|
+
}
|
|
247
|
+
return keywords.get(ident, IDENT)
|
|
248
|
+
|
|
249
|
+
def is_letter(self, char):
|
|
250
|
+
return 'a' <= char <= 'z' or 'A' <= char <= 'Z' or char == '_'
|
|
251
|
+
|
|
252
|
+
def is_digit(self, char):
|
|
253
|
+
return '0' <= char <= '9'
|
|
254
|
+
|
|
255
|
+
def skip_whitespace(self):
|
|
256
|
+
while self.ch in [' ', '\t', '\n', '\r']:
|
|
257
|
+
self.read_char()
|