lucidaflow 1.0.5__py3-none-any.whl → 1.0.8__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/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
- def run_code(source_code, analyzer, interpreter):
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
- break
32
-
33
- if not line.strip():
34
- continue
35
-
36
- result = run_code(line, analyzer, interpreter)
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
- # Por agora, a nossa ferramenta de linha de comando inicia o REPL.
47
- start_repl()
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()
@@ -6,9 +6,9 @@ import time
6
6
  import os
7
7
  import datetime
8
8
 
9
- from lib.web import NATIVE_WEB_MODULE, register_semantics as register_web_semantics
10
- from lib.json import NATIVE_JSON_MODULE, register_semantics as register_json_semantics
11
- from lib.dado import NATIVE_DADO_MODULE, register_semantics as register_dado_semantics
9
+ from lucidaflow.lib.web import NATIVE_WEB_MODULE, register_semantics as register_web_semantics
10
+ from lucidaflow.lib.json import NATIVE_JSON_MODULE, register_semantics as register_json_semantics
11
+ from lucidaflow.lib.dado import NATIVE_DADO_MODULE, register_semantics as register_dado_semantics
12
12
 
13
13
  # --- Importações dos Símbolos da Lucida-Flow ---
14
14
  # (Necessário para a parte de descrição semântica)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lucidaflow
3
- Version: 1.0.5
3
+ Version: 1.0.8
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,20 +1,20 @@
1
1
  lucidaflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- lucidaflow/cli.py,sha256=J20FhsGuOiokNxPe6PpJdoYjDAumUxZS6BDnz5OHowM,1415
2
+ lucidaflow/cli.py,sha256=tix8le1L_ps4D93GxZCvzquRlWUfVBkqnkjXyiHQrj8,2820
3
3
  lucidaflow/lucida_analyzer.py,sha256=q8lvfUI2FbG5hfv_34c0VTnT-JNd6MjkPPmkMw1SDPA,50799
4
4
  lucidaflow/lucida_ast.py,sha256=TeomKhErVrXD9gdx3NpBivrXolK5j7qNWx-dbrlHHas,12302
5
5
  lucidaflow/lucida_errors.py,sha256=dw-wVE3nl7-Vaz5JeGlVaNx26xhQ5Ld7OBdpNJjDeK4,994
6
6
  lucidaflow/lucida_interpreter.py,sha256=ljPQ80FI6WCmTGngG9UY37VWp-T1YxVfXKcd31ib_B4,36656
7
7
  lucidaflow/lucida_lexer.py,sha256=gX2p_Qivf2O-vWIFPArKGzJP2xxvQq5FoNTYHSrlIEU,11583
8
8
  lucidaflow/lucida_parser.py,sha256=CJaAMWt-NgECcTHxZX3aS7KmqEhXUlmzlIi_w61D7b8,26002
9
- lucidaflow/lucida_stdlib.py,sha256=FdoqMtzUni3VvBz__Inz47VreCvGUClD9V4fIBh2e6k,9367
9
+ lucidaflow/lucida_stdlib.py,sha256=_PS0rNsESwIN7PRdCFRCC9N-nW24gvvhqt2Jh1L3LWI,9400
10
10
  lucidaflow/lucida_symbols.py,sha256=93Td58Anbst1HfbjunUFOsc9aWk3kQmfWOtUxKVoNjU,6677
11
11
  lucidaflow/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  lucidaflow/lib/dado.py,sha256=7rHJ1cXVCOmQ5x5sxArRhxSk-yCED7K1jXLCK1dSqgs,1145
13
13
  lucidaflow/lib/json.py,sha256=ZUHEBVAB6brH988u6zNQaN3ZB7SWOZ8iJkXYf8q9QsQ,1475
14
14
  lucidaflow/lib/web.py,sha256=lmzNgV2stcytsD6JGEuEdOs4Db5y8cUkrUx9EOeyRfk,1122
15
- lucidaflow-1.0.5.dist-info/licenses/LICENSE,sha256=Jh84joCKoVDVazEsQ-GeXr6K336bDgu5mGcjgFKM-RI,1088
16
- lucidaflow-1.0.5.dist-info/METADATA,sha256=VQ6nk0IosO5Brd5jR6PiOUUsx_MboWHmRwDrVV_Z-tA,64557
17
- lucidaflow-1.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- lucidaflow-1.0.5.dist-info/entry_points.txt,sha256=pHHq39ZoRw6PkeIohtiwf6vIBAvRpfwOVn5Tr9-2Rv8,51
19
- lucidaflow-1.0.5.dist-info/top_level.txt,sha256=QAnM_ZQla0_f0t2FDkQ_U1faUfaZ-rcS_L6C5JYG8T4,11
20
- lucidaflow-1.0.5.dist-info/RECORD,,
15
+ lucidaflow-1.0.8.dist-info/licenses/LICENSE,sha256=Jh84joCKoVDVazEsQ-GeXr6K336bDgu5mGcjgFKM-RI,1088
16
+ lucidaflow-1.0.8.dist-info/METADATA,sha256=98P3NxquDQyh_Yemair-5oYGrdhJAX0SrMIlOgA2VUY,64557
17
+ lucidaflow-1.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ lucidaflow-1.0.8.dist-info/entry_points.txt,sha256=pHHq39ZoRw6PkeIohtiwf6vIBAvRpfwOVn5Tr9-2Rv8,51
19
+ lucidaflow-1.0.8.dist-info/top_level.txt,sha256=QAnM_ZQla0_f0t2FDkQ_U1faUfaZ-rcS_L6C5JYG8T4,11
20
+ lucidaflow-1.0.8.dist-info/RECORD,,