lucidaflow 1.0.7__py3-none-any.whl → 1.0.9__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.
Potentially problematic release.
This version of lucidaflow might be problematic. Click here for more details.
- lucidaflow/__main__.py +21 -0
- lucidaflow/cli.py +49 -13
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/METADATA +1 -1
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/RECORD +8 -7
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/WHEEL +0 -0
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/entry_points.txt +0 -0
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/licenses/LICENSE +0 -0
- {lucidaflow-1.0.7.dist-info → lucidaflow-1.0.9.dist-info}/top_level.txt +0 -0
lucidaflow/__main__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# src/lucidaflow/__main__.py
|
|
2
|
+
import sys
|
|
3
|
+
from .cli import run_file, start_repl
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
"""
|
|
7
|
+
Verifica os argumentos da linha de comando e decide se executa
|
|
8
|
+
um ficheiro ou inicia o REPL.
|
|
9
|
+
"""
|
|
10
|
+
# sys.argv é a lista de argumentos da linha de comando.
|
|
11
|
+
# sys.argv[0] é o nome do módulo, o resto são os argumentos.
|
|
12
|
+
if len(sys.argv) > 1:
|
|
13
|
+
# Se um argumento foi passado, assumimos que é um nome de ficheiro
|
|
14
|
+
script_file = sys.argv[1]
|
|
15
|
+
run_file(script_file)
|
|
16
|
+
else:
|
|
17
|
+
# Se nenhum argumento foi passado, inicia o REPL
|
|
18
|
+
start_repl()
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
main()
|
lucidaflow/cli.py
CHANGED
|
@@ -8,33 +8,59 @@ from lucidaflow.lucida_interpreter import Interpreter
|
|
|
8
8
|
from lucidaflow.lucida_errors import LucidaError
|
|
9
9
|
from lucidaflow.lucida_ast import ProgramNode
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# --- Funções de Execução ---
|
|
12
|
+
|
|
13
|
+
def run_code(source_code):
|
|
14
|
+
"""Função que executa um trecho de código da Lucida-Flow."""
|
|
15
|
+
# Cada execução tem seu próprio ambiente limpo
|
|
16
|
+
analyzer = SemanticAnalyzer()
|
|
17
|
+
interpreter = Interpreter()
|
|
18
|
+
|
|
12
19
|
lexer = Lexer(source_code)
|
|
13
20
|
parser = Parser(lexer)
|
|
14
21
|
ast = parser.parse()
|
|
22
|
+
|
|
15
23
|
analyzer.visit(ast)
|
|
16
24
|
result = interpreter.visit(ast)
|
|
17
25
|
return result
|
|
18
26
|
|
|
27
|
+
def run_file(filename):
|
|
28
|
+
"""Lê e executa um ficheiro .lf."""
|
|
29
|
+
try:
|
|
30
|
+
with open(filename, 'r', encoding='utf-8') as f:
|
|
31
|
+
source_code = f.read()
|
|
32
|
+
run_code(source_code)
|
|
33
|
+
except FileNotFoundError:
|
|
34
|
+
print(f"Erro: O ficheiro '{filename}' não foi encontrado.")
|
|
35
|
+
except LucidaError as e:
|
|
36
|
+
print("--- OCORREU UM ERRO NA LUCIDA-FLOW ---")
|
|
37
|
+
print(e)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print("--- OCORREU UM ERRO INESPERADO NO SISTEMA ---")
|
|
40
|
+
print(e)
|
|
41
|
+
|
|
19
42
|
def start_repl():
|
|
43
|
+
"""Inicia o modo interativo (REPL)."""
|
|
20
44
|
print("Lucida-Flow REPL v1.0 (Instalado via pip)")
|
|
21
45
|
print("Digite 'exit' ou 'sair' para terminar.")
|
|
22
|
-
|
|
46
|
+
|
|
23
47
|
analyzer = SemanticAnalyzer()
|
|
24
48
|
interpreter = Interpreter()
|
|
25
49
|
analyzer.visit(ProgramNode([]))
|
|
26
|
-
|
|
50
|
+
|
|
27
51
|
while True:
|
|
28
52
|
try:
|
|
29
53
|
line = input("lf> ")
|
|
30
|
-
if line.strip().lower() in ('exit', 'sair'):
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
if line.strip().lower() in ('exit', 'sair'): break
|
|
55
|
+
if not line.strip(): continue
|
|
56
|
+
|
|
57
|
+
# Reutiliza o mesmo analyzer e interpreter para manter o estado no REPL
|
|
58
|
+
lexer = Lexer(line)
|
|
59
|
+
parser = Parser(lexer)
|
|
60
|
+
ast = parser.parse()
|
|
61
|
+
analyzer.visit(ast)
|
|
62
|
+
result = interpreter.visit(ast)
|
|
63
|
+
|
|
38
64
|
if result is not None:
|
|
39
65
|
print(result)
|
|
40
66
|
except LucidaError as e:
|
|
@@ -42,9 +68,19 @@ def start_repl():
|
|
|
42
68
|
except Exception as e:
|
|
43
69
|
print(f"Erro de sistema: {e}")
|
|
44
70
|
|
|
71
|
+
# --- Ponto de Entrada Principal ---
|
|
72
|
+
|
|
45
73
|
def main():
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
"""Verifica os argumentos e decide se executa um ficheiro ou inicia o REPL."""
|
|
75
|
+
# sys.argv é a lista de argumentos da linha de comando.
|
|
76
|
+
# sys.argv[0] é o nome do script, o resto são os argumentos.
|
|
77
|
+
if len(sys.argv) > 1:
|
|
78
|
+
# Se um argumento foi passado, assumimos que é um nome de ficheiro
|
|
79
|
+
script_file = sys.argv[1]
|
|
80
|
+
run_file(script_file)
|
|
81
|
+
else:
|
|
82
|
+
# Se nenhum argumento foi passado, inicia o REPL
|
|
83
|
+
start_repl()
|
|
48
84
|
|
|
49
85
|
if __name__ == '__main__':
|
|
50
86
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lucidaflow
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
4
4
|
Summary: Uma linguagem de script moderna, extensível e com tipagem gradual, implementada em Python.
|
|
5
5
|
Author-email: Marco Lago <marconeed2@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/marconeed/Lucida-Flow
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
lucidaflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
lucidaflow/
|
|
2
|
+
lucidaflow/__main__.py,sha256=TbiTNQbh64tTOVxiYTL9ua0TFykaY0pZxu3QyaR5aZI,649
|
|
3
|
+
lucidaflow/cli.py,sha256=tix8le1L_ps4D93GxZCvzquRlWUfVBkqnkjXyiHQrj8,2820
|
|
3
4
|
lucidaflow/lucida_analyzer.py,sha256=q8lvfUI2FbG5hfv_34c0VTnT-JNd6MjkPPmkMw1SDPA,50799
|
|
4
5
|
lucidaflow/lucida_ast.py,sha256=TeomKhErVrXD9gdx3NpBivrXolK5j7qNWx-dbrlHHas,12302
|
|
5
6
|
lucidaflow/lucida_errors.py,sha256=dw-wVE3nl7-Vaz5JeGlVaNx26xhQ5Ld7OBdpNJjDeK4,994
|
|
@@ -12,9 +13,9 @@ lucidaflow/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
12
13
|
lucidaflow/lib/dado.py,sha256=7rHJ1cXVCOmQ5x5sxArRhxSk-yCED7K1jXLCK1dSqgs,1145
|
|
13
14
|
lucidaflow/lib/json.py,sha256=ZUHEBVAB6brH988u6zNQaN3ZB7SWOZ8iJkXYf8q9QsQ,1475
|
|
14
15
|
lucidaflow/lib/web.py,sha256=lmzNgV2stcytsD6JGEuEdOs4Db5y8cUkrUx9EOeyRfk,1122
|
|
15
|
-
lucidaflow-1.0.
|
|
16
|
-
lucidaflow-1.0.
|
|
17
|
-
lucidaflow-1.0.
|
|
18
|
-
lucidaflow-1.0.
|
|
19
|
-
lucidaflow-1.0.
|
|
20
|
-
lucidaflow-1.0.
|
|
16
|
+
lucidaflow-1.0.9.dist-info/licenses/LICENSE,sha256=Jh84joCKoVDVazEsQ-GeXr6K336bDgu5mGcjgFKM-RI,1088
|
|
17
|
+
lucidaflow-1.0.9.dist-info/METADATA,sha256=PV6uCEQhvftKS_NFz0jssb4j29YJuE3EXoZ2v35-HIg,64557
|
|
18
|
+
lucidaflow-1.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
lucidaflow-1.0.9.dist-info/entry_points.txt,sha256=pHHq39ZoRw6PkeIohtiwf6vIBAvRpfwOVn5Tr9-2Rv8,51
|
|
20
|
+
lucidaflow-1.0.9.dist-info/top_level.txt,sha256=QAnM_ZQla0_f0t2FDkQ_U1faUfaZ-rcS_L6C5JYG8T4,11
|
|
21
|
+
lucidaflow-1.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|