PRIMER COMMIT
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__
|
||||
161
README.txt
Normal file
161
README.txt
Normal file
@@ -0,0 +1,161 @@
|
||||
================================================================================
|
||||
ZAPLANG
|
||||
Lenguaje de programación con sintaxis en español
|
||||
================================================================================
|
||||
|
||||
DESCRIPCIÓN
|
||||
-----------
|
||||
zaplang es un lenguaje de programación interpretado cuya sintaxis está inspirada
|
||||
en C pero con palabras clave completamente en español. Está construido con ANTLR4
|
||||
(gramática dividida en Lexer y Parser) y un intérprete escrito en Python que
|
||||
ejecuta el árbol de análisis mediante el patrón Visitor.
|
||||
|
||||
El objetivo es facilitar el aprendizaje de programación a hispanohablantes,
|
||||
eliminando la barrera del inglés en las palabras reservadas del lenguaje.
|
||||
|
||||
|
||||
ARCHIVOS DEL PROYECTO
|
||||
---------------------
|
||||
zaplangLexer.g4 Gramática del analizador léxico (ANTLR4)
|
||||
zaplangParser.g4 Gramática del analizador sintáctico (ANTLR4)
|
||||
zaplangLexer.py Código generado por ANTLR4 (lexer)
|
||||
zaplangParser.py Código generado por ANTLR4 (parser)
|
||||
zaplangParserListener.py Listener generado por ANTLR4
|
||||
zaplangParserVisitor.py Visitor generado por ANTLR4
|
||||
zaplangLexer.tokens Tabla de tokens del lexer
|
||||
zaplangParser.tokens Tabla de tokens del parser
|
||||
zaplangLexer.interp Archivo de interpretación del lexer
|
||||
zaplangParser.interp Archivo de interpretación del parser
|
||||
interprete.py Intérprete principal (ejecuta programas .zap)
|
||||
demo.zap Programa de demostración
|
||||
|
||||
|
||||
REQUISITOS
|
||||
----------
|
||||
- Python 3.8 o superior
|
||||
- ANTLR4 runtime para Python:
|
||||
|
||||
pip install antlr4-python3-runtime
|
||||
|
||||
(Nota: no es necesario regenerar los archivos .py desde las gramáticas a menos
|
||||
que se modifiquen los archivos .g4)
|
||||
|
||||
|
||||
CÓMO EJECUTAR UN PROGRAMA
|
||||
--------------------------
|
||||
python interprete.py <archivo.zap>
|
||||
|
||||
Ejemplo con el programa de demostración incluido:
|
||||
|
||||
python interprete.py demo.zap
|
||||
|
||||
Salida esperada:
|
||||
|
||||
=== Demo zaplang ===
|
||||
Cuadrados: 1 4 9 16 25
|
||||
x es mayor que 10
|
||||
Factorial de 6: 720
|
||||
Arreglo: 10 20 30 40 50
|
||||
Cuenta regresiva: 3 2 1 ¡Ya!
|
||||
¡Hola desde zaplang!
|
||||
|
||||
|
||||
PALABRAS RESERVADAS
|
||||
-------------------
|
||||
Tipos de datos:
|
||||
Ent → entero (int)
|
||||
doble → doble precisión (double)
|
||||
flot → flotante (float)
|
||||
carac → carácter (char)
|
||||
cf → con firma (signed)
|
||||
sf → sin firma (unsigned)
|
||||
vacio → sin retorno (void)
|
||||
|
||||
Control de flujo:
|
||||
si → if
|
||||
sino → else
|
||||
mientras → while
|
||||
por → for
|
||||
caso → case / switch
|
||||
pordef → default
|
||||
retornar → return
|
||||
fin → break
|
||||
interrup → continue
|
||||
|
||||
Estructuras:
|
||||
estruct → struct
|
||||
enum → enum
|
||||
|
||||
Literales booleanos:
|
||||
verdadero → true
|
||||
falso → false
|
||||
|
||||
Especial:
|
||||
bul → marca de punto de entrada en estructuras caso/switch
|
||||
|
||||
|
||||
FUNCIONES DE ENTRADA/SALIDA INTEGRADAS
|
||||
---------------------------------------
|
||||
imprimir(valor) Imprime un valor sin salto de línea
|
||||
imprimirln(valor) Imprime un valor con salto de línea
|
||||
leer() Lee una línea como cadena de texto
|
||||
leerEnt() Lee un número entero desde la entrada estándar
|
||||
leerFlot() Lee un número flotante desde la entrada estándar
|
||||
leerCarac() Lee un carácter desde la entrada estándar
|
||||
longitud(cadena) Devuelve la longitud de una cadena
|
||||
|
||||
|
||||
CARACTERÍSTICAS DEL LENGUAJE
|
||||
-----------------------------
|
||||
- Funciones con parámetros y valor de retorno
|
||||
- Variables locales y globales con scoping léxico
|
||||
- Arreglos de tamaño fijo con inicialización literal
|
||||
- Estructuras (estruct) y enumeraciones (enum)
|
||||
- Punteros (sintaxis soportada, comportamiento simplificado)
|
||||
- Operadores aritméticos, lógicos, relacionales y de bits
|
||||
- Operadores de asignación compuesta (+=, -=, *=, etc.)
|
||||
- Operadores de incremento/decremento prefijos y postfijos (++/--)
|
||||
- Sentencia condicional (si/sino)
|
||||
- Estructura tipo switch (caso bul)
|
||||
- Bucles mientras y por (while y for)
|
||||
- Expresión ternaria (condicion ? valor_si : valor_no)
|
||||
- Comentarios de línea (//) y de bloque (/* */)
|
||||
- Punto de entrada obligatorio: función main()
|
||||
|
||||
|
||||
EJEMPLO DE PROGRAMA
|
||||
-------------------
|
||||
Ent factorial(Ent n) {
|
||||
si (n <= 1) retornar 1;
|
||||
retornar n * factorial(n - 1);
|
||||
}
|
||||
|
||||
vacio main() {
|
||||
Ent resultado = factorial(6);
|
||||
imprimirln(resultado); // Imprime: 720
|
||||
}
|
||||
|
||||
|
||||
REGENERAR LOS ARCHIVOS DE ANTLR4 (OPCIONAL)
|
||||
--------------------------------------------
|
||||
Si se modifican las gramáticas (.g4), regenerar con:
|
||||
|
||||
antlr4 -Dlanguage=Python3 zaplangLexer.g4
|
||||
antlr4 -Dlanguage=Python3 zaplangParser.g4
|
||||
|
||||
Requiere tener instalado ANTLR4 (herramienta de línea de comandos).
|
||||
Descarga: https://www.antlr.org/
|
||||
|
||||
|
||||
ARQUITECTURA INTERNA
|
||||
--------------------
|
||||
1. El código fuente (.zap) se lee como texto plano.
|
||||
2. zaplangLexer tokeniza el flujo de caracteres.
|
||||
3. zaplangParser construye el árbol de análisis sintáctico (AST).
|
||||
4. El intérprete (interprete.py) recorre el AST usando el patrón Visitor,
|
||||
administrando un entorno de variables con scoping por cadena de entornos
|
||||
(clase Entorno con referencia al padre).
|
||||
5. El control de flujo (retornar, fin, interrup) se implementa mediante
|
||||
excepciones de Python (RetornarSenal, FinSenal, InterrupSenal).
|
||||
|
||||
================================================================================
|
||||
54
demo.zap
Normal file
54
demo.zap
Normal file
@@ -0,0 +1,54 @@
|
||||
// Demo zaplang — declaraciones antes de sentencias en cada bloque
|
||||
|
||||
Ent factorial(Ent n) {
|
||||
si (n <= 1) retornar 1;
|
||||
retornar n * factorial(n - 1);
|
||||
}
|
||||
|
||||
vacio saludar() {
|
||||
imprimirln("¡Hola desde zaplang!");
|
||||
}
|
||||
|
||||
vacio main() {
|
||||
Ent cuenta;
|
||||
Ent nums[5] = {10, 20, 30, 40, 50};
|
||||
|
||||
imprimirln("=== Demo zaplang ===");
|
||||
|
||||
imprimir("Cuadrados: ");
|
||||
Ent i = 1;
|
||||
por (; i <= 5; i++) {
|
||||
imprimir(i * i);
|
||||
imprimir(" ");
|
||||
}
|
||||
imprimirln("");
|
||||
|
||||
Ent x = 42;
|
||||
si (x > 10) {
|
||||
imprimirln("x es mayor que 10");
|
||||
} sino {
|
||||
imprimirln("x es menor o igual a 10");
|
||||
}
|
||||
|
||||
imprimir("Factorial de 6: ");
|
||||
imprimirln(factorial(6));
|
||||
|
||||
imprimir("Arreglo: ");
|
||||
i = 0;
|
||||
por (; i < 5; i++) {
|
||||
imprimir(nums[i]);
|
||||
imprimir(" ");
|
||||
}
|
||||
imprimirln("");
|
||||
|
||||
cuenta = 3;
|
||||
imprimir("Cuenta regresiva: ");
|
||||
mientras (cuenta > 0) {
|
||||
imprimir(cuenta);
|
||||
imprimir(" ");
|
||||
cuenta--;
|
||||
}
|
||||
imprimirln("¡Ya!");
|
||||
|
||||
saludar();
|
||||
}
|
||||
555
interprete.py
Normal file
555
interprete.py
Normal file
@@ -0,0 +1,555 @@
|
||||
"""
|
||||
Intérprete de zaplang usando ANTLR4 (visitor pattern).
|
||||
Incluye funciones IO integradas: imprimir, imprimirln, leer, leerEnt, leerFlot.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import math
|
||||
from antlr4 import *
|
||||
from antlr4.error.ErrorListener import ErrorListener
|
||||
|
||||
from zaplangLexer import zaplangLexer
|
||||
from zaplangParser import zaplangParser
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Señales de control de flujo
|
||||
# ─────────────────────────────────────────────
|
||||
class RetornarSenal(Exception):
|
||||
def __init__(self, valor): self.valor = valor
|
||||
|
||||
class FinSenal(Exception): pass # break
|
||||
class InterrupSenal(Exception): pass # continue
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Entorno (scoping)
|
||||
# ─────────────────────────────────────────────
|
||||
class Entorno:
|
||||
def __init__(self, padre=None):
|
||||
self.vars = {}
|
||||
self.padre = padre
|
||||
|
||||
def definir(self, nombre, valor):
|
||||
self.vars[nombre] = valor
|
||||
|
||||
def obtener(self, nombre):
|
||||
if nombre in self.vars:
|
||||
return self.vars[nombre]
|
||||
if self.padre:
|
||||
return self.padre.obtener(nombre)
|
||||
raise NameError(f"Variable no definida: '{nombre}'")
|
||||
|
||||
def asignar(self, nombre, valor):
|
||||
if nombre in self.vars:
|
||||
self.vars[nombre] = valor
|
||||
return
|
||||
if self.padre:
|
||||
self.padre.asignar(nombre, valor)
|
||||
return
|
||||
raise NameError(f"Variable no definida: '{nombre}'")
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Funciones IO integradas
|
||||
# ─────────────────────────────────────────────
|
||||
def _procesar_cadena(s):
|
||||
"""Interpreta secuencias de escape en cadenas."""
|
||||
return s.encode('raw_unicode_escape').decode('unicode_escape')
|
||||
|
||||
FUNCIONES_IO = {
|
||||
# imprimir(val, ...) → imprime sin salto de línea
|
||||
"imprimir": lambda args: print(*[_fmt(a) for a in args], end=""),
|
||||
# imprimirln(val, ...) → imprime con salto de línea
|
||||
"imprimirln": lambda args: print(*[_fmt(a) for a in args]),
|
||||
# leer() → lee una línea como cadena
|
||||
"leer": lambda args: input(),
|
||||
# leerEnt() → lee un entero
|
||||
"leerEnt": lambda args: int(input()),
|
||||
# leerFlot() → lee un flotante
|
||||
"leerFlot": lambda args: float(input()),
|
||||
# leerCarac() → lee un carácter
|
||||
"leerCarac": lambda args: input()[0] if input() else '\0',
|
||||
# longitud(s) → len de cadena
|
||||
"longitud": lambda args: len(str(args[0])),
|
||||
}
|
||||
|
||||
def _fmt(v):
|
||||
if isinstance(v, bool): return "verdadero" if v else "falso"
|
||||
if isinstance(v, float) and v == int(v): return str(int(v))
|
||||
return str(v)
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Visitor / Intérprete
|
||||
# ─────────────────────────────────────────────
|
||||
class Interprete:
|
||||
def __init__(self):
|
||||
self.global_env = Entorno()
|
||||
self.funciones = {} # nombre → ctx de declaracionFuncion
|
||||
self._registrar_io()
|
||||
|
||||
def _registrar_io(self):
|
||||
"""Registra las funciones IO como callables nativos."""
|
||||
for nombre, fn in FUNCIONES_IO.items():
|
||||
self.funciones[nombre] = fn # callable nativo
|
||||
|
||||
# ── Entrada principal ──────────────────────────────────────
|
||||
def ejecutar(self, arbol):
|
||||
self.visitar_unidad(arbol, self.global_env)
|
||||
|
||||
def visitar_unidad(self, ctx, env):
|
||||
for decl in ctx.declaracionExterna():
|
||||
self.visitar_declaracion_externa(decl, env)
|
||||
# Buscar y ejecutar main
|
||||
if "main" not in self.funciones:
|
||||
raise RuntimeError("No se encontró la función 'main'")
|
||||
self.llamar_funcion("main", [], env)
|
||||
|
||||
def visitar_declaracion_externa(self, ctx, env):
|
||||
if ctx.declaracionFuncion():
|
||||
self.registrar_funcion(ctx.declaracionFuncion())
|
||||
elif ctx.declaracionVariable():
|
||||
self.visitar_decl_variable(ctx.declaracionVariable(), env)
|
||||
elif ctx.declaracionEstruct():
|
||||
pass # extensible
|
||||
elif ctx.declaracionEnum():
|
||||
self.visitar_decl_enum(ctx.declaracionEnum(), env)
|
||||
|
||||
# ── Funciones ──────────────────────────────────────────────
|
||||
def registrar_funcion(self, ctx):
|
||||
nombre = ctx.identificadorFuncion().Identificador().getText()
|
||||
self.funciones[nombre] = ctx
|
||||
|
||||
def llamar_funcion(self, nombre, args, env):
|
||||
fn = self.funciones.get(nombre)
|
||||
if fn is None:
|
||||
raise RuntimeError(f"Función no definida: '{nombre}'")
|
||||
# Nativa (IO)
|
||||
if callable(fn) and not hasattr(fn, 'listaParametros'):
|
||||
return fn(args)
|
||||
# Definida en zaplang
|
||||
local = Entorno(self.global_env)
|
||||
params = fn.listaParametros()
|
||||
if params:
|
||||
param_list = params.declaracionParametro()
|
||||
for i, param in enumerate(param_list):
|
||||
pnombre = param.Identificador().getText()
|
||||
valor = args[i] if i < len(args) else None
|
||||
local.definir(pnombre, valor)
|
||||
try:
|
||||
self.visitar_bloque(fn.bloque(), local)
|
||||
except RetornarSenal as r:
|
||||
return r.valor
|
||||
return None
|
||||
|
||||
# ── Bloque y sentencias ────────────────────────────────────
|
||||
def visitar_bloque(self, ctx, env):
|
||||
if ctx.LlaveIzq():
|
||||
for dv in ctx.declaracionVariable():
|
||||
self.visitar_decl_variable(dv, env)
|
||||
for sent in ctx.sentencia():
|
||||
self.visitar_sentencia(sent, env)
|
||||
else:
|
||||
self.visitar_sentencia(ctx.sentencia(), env)
|
||||
|
||||
def visitar_sentencia(self, ctx, env):
|
||||
if ctx.sentenciaCompuesta():
|
||||
inner = Entorno(env)
|
||||
for s in ctx.sentenciaCompuesta().sentencia():
|
||||
self.visitar_sentencia(s, inner)
|
||||
elif ctx.sentenciaDeclaracion():
|
||||
self.visitar_decl_variable(ctx.sentenciaDeclaracion().declaracionVariable(), env)
|
||||
elif ctx.sentenciaExpresion():
|
||||
se = ctx.sentenciaExpresion()
|
||||
if se.expresion():
|
||||
self.visitar_expresion(se.expresion(), env)
|
||||
elif ctx.sentenciaSeleccion():
|
||||
self.visitar_seleccion(ctx.sentenciaSeleccion(), env)
|
||||
elif ctx.sentenciaIteracion():
|
||||
self.visitar_iteracion(ctx.sentenciaIteracion(), env)
|
||||
elif ctx.sentenciaSalto():
|
||||
self.visitar_salto(ctx.sentenciaSalto(), env)
|
||||
|
||||
# ── Declaración de variables ───────────────────────────────
|
||||
def visitar_decl_variable(self, ctx, env):
|
||||
for init_var in ctx.inicializadorVariable():
|
||||
nombre = init_var.Identificador().getText()
|
||||
if init_var.inicializadorArreglo():
|
||||
items = []
|
||||
la = init_var.inicializadorArreglo().listaInitializers()
|
||||
if la:
|
||||
for ae in la.asignacionExpresion():
|
||||
items.append(self.visitar_asignacion(ae, env))
|
||||
env.definir(nombre, items)
|
||||
elif init_var.inicializador():
|
||||
val = self.visitar_asignacion(
|
||||
init_var.inicializador().asignacionExpresion(), env)
|
||||
env.definir(nombre, val)
|
||||
elif init_var.ConstanteEntera():
|
||||
tamaño = int(init_var.ConstanteEntera().getText())
|
||||
env.definir(nombre, [None] * tamaño)
|
||||
else:
|
||||
env.definir(nombre, None)
|
||||
|
||||
# ── Enum ───────────────────────────────────────────────────
|
||||
def visitar_decl_enum(self, ctx, env):
|
||||
contador = 0
|
||||
for en in ctx.listaEnumeradores().enumerador():
|
||||
nombre = en.Identificador().getText()
|
||||
if en.ConstanteEntera():
|
||||
contador = int(en.ConstanteEntera().getText())
|
||||
env.definir(nombre, contador)
|
||||
self.global_env.definir(nombre, contador)
|
||||
contador += 1
|
||||
|
||||
# ── Selección ──────────────────────────────────────────────
|
||||
def visitar_seleccion(self, ctx, env):
|
||||
if ctx.Si():
|
||||
cond = self.visitar_expresion(ctx.expresion(), env)
|
||||
sentencias = ctx.sentencia()
|
||||
if cond:
|
||||
self.visitar_sentencia(sentencias[0], Entorno(env))
|
||||
elif len(sentencias) > 1:
|
||||
self.visitar_sentencia(sentencias[1], Entorno(env))
|
||||
elif ctx.Caso():
|
||||
# switch-like: caso bul { caso X: ... pordef: ... }
|
||||
val_bul = self.visitar_expresion(ctx.expresion(), env) if ctx.expresion() else None
|
||||
ejecutando = False
|
||||
for etiqueta in ctx.casoEtiqueta():
|
||||
val = self.visitar_constante(etiqueta.constanteExpresion(), env)
|
||||
if val == val_bul or ejecutando:
|
||||
ejecutando = True
|
||||
try:
|
||||
for s in etiqueta.sentencia():
|
||||
self.visitar_sentencia(s, env)
|
||||
except FinSenal:
|
||||
return
|
||||
if ctx.etiquetaPorDef() and ejecutando is False:
|
||||
try:
|
||||
for s in ctx.etiquetaPorDef().sentencia():
|
||||
self.visitar_sentencia(s, env)
|
||||
except FinSenal:
|
||||
pass
|
||||
|
||||
# ── Iteración ──────────────────────────────────────────────
|
||||
def visitar_iteracion(self, ctx, env):
|
||||
if ctx.Mientras():
|
||||
while self.visitar_expresion(ctx.expresion()[0], env):
|
||||
try:
|
||||
self.visitar_sentencia(ctx.sentencia(), Entorno(env))
|
||||
except FinSenal:
|
||||
break
|
||||
except InterrupSenal:
|
||||
continue
|
||||
elif ctx.Por():
|
||||
# Gramática: Por ( sentenciaExpresion? ; expresion? ; expresion? ) sentencia
|
||||
# sentenciaExpresion ya tiene su propio ';', luego viene ';' cond ';' paso
|
||||
loop_env = Entorno(env)
|
||||
# init: sentenciaExpresion opcional (tiene su ';')
|
||||
se = ctx.sentenciaExpresion()
|
||||
if se and se.expresion():
|
||||
self.visitar_expresion(se.expresion(), loop_env)
|
||||
# cond y paso: expresion(0) y expresion(1) — pueden ser None
|
||||
exprs = ctx.expresion()
|
||||
cond_expr = exprs[0] if len(exprs) > 0 else None
|
||||
paso_expr = exprs[1] if len(exprs) > 1 else None
|
||||
while True:
|
||||
if cond_expr is not None and not self.visitar_expresion(cond_expr, loop_env):
|
||||
break
|
||||
try:
|
||||
self.visitar_sentencia(ctx.sentencia(), Entorno(loop_env))
|
||||
except FinSenal:
|
||||
break
|
||||
except InterrupSenal:
|
||||
pass
|
||||
if paso_expr:
|
||||
self.visitar_expresion(paso_expr, loop_env)
|
||||
|
||||
# ── Salto ─────────────────────────────────────────────────
|
||||
def visitar_salto(self, ctx, env):
|
||||
if ctx.Retornar():
|
||||
val = self.visitar_expresion(ctx.expresion(), env) if ctx.expresion() else None
|
||||
raise RetornarSenal(val)
|
||||
elif ctx.Fin():
|
||||
raise FinSenal()
|
||||
elif ctx.Interrup():
|
||||
raise InterrupSenal()
|
||||
|
||||
# ── Expresiones ────────────────────────────────────────────
|
||||
def visitar_expresion(self, ctx, env):
|
||||
# expresion: asignacionExpresion | expresion Coma asignacionExpresion
|
||||
# En el árbol: puede haber asignacionExpresion() como hijo único o múltiples
|
||||
if hasattr(ctx, 'asignacionExpresion') and ctx.asignacionExpresion() is not None:
|
||||
ae = ctx.asignacionExpresion()
|
||||
val = self.visitar_asignacion(ae, env)
|
||||
# Si hay expresion hija (caso con coma), procesarla primero
|
||||
if ctx.expresion():
|
||||
val = self.visitar_expresion(ctx.expresion(), env)
|
||||
val = self.visitar_asignacion(ae, env)
|
||||
return val
|
||||
return None
|
||||
|
||||
def visitar_asignacion(self, ctx, env):
|
||||
if ctx.expresionCondicional():
|
||||
return self.visitar_condicional(ctx.expresionCondicional(), env)
|
||||
# Asignación
|
||||
lhs = ctx.expresionUnaria()
|
||||
op = ctx.operadorAsignacion().getText()
|
||||
rhs = self.visitar_asignacion(ctx.asignacionExpresion(), env)
|
||||
nombre, idx = self._resolver_lvalue(lhs, env)
|
||||
if idx is not None:
|
||||
arr = env.obtener(nombre)
|
||||
viejo = arr[idx]
|
||||
arr[idx] = self._aplicar_op_asign(op, viejo, rhs)
|
||||
else:
|
||||
viejo = None
|
||||
try: viejo = env.obtener(nombre)
|
||||
except: pass
|
||||
env.asignar(nombre, self._aplicar_op_asign(op, viejo, rhs))
|
||||
return rhs
|
||||
|
||||
def _aplicar_op_asign(self, op, viejo, nuevo):
|
||||
if op == '=': return nuevo
|
||||
if op == '+=': return (viejo or 0) + nuevo
|
||||
if op == '-=': return (viejo or 0) - nuevo
|
||||
if op == '*=': return (viejo or 0) * nuevo
|
||||
if op == '/=': return (viejo or 0) / nuevo
|
||||
if op == '%=': return (viejo or 0) % nuevo
|
||||
if op == '&=': return int(viejo or 0) & int(nuevo)
|
||||
if op == '|=': return int(viejo or 0) | int(nuevo)
|
||||
if op == '^=': return int(viejo or 0) ^ int(nuevo)
|
||||
if op == '<<=': return int(viejo or 0) << int(nuevo)
|
||||
if op == '>>=': return int(viejo or 0) >> int(nuevo)
|
||||
return nuevo
|
||||
|
||||
def _resolver_lvalue(self, ctx_unaria, env):
|
||||
"""Devuelve (nombre, índice_o_None)."""
|
||||
pf = ctx_unaria.expresionPostfija()
|
||||
if pf and pf.expresionPostfija() and pf.CorcheteIzq():
|
||||
nombre = pf.expresionPostfija().expresionPrimaria().Identificador().getText()
|
||||
idx = int(self.visitar_expresion(pf.expresion(), env))
|
||||
return nombre, idx
|
||||
elif pf and pf.expresionPrimaria() and pf.expresionPrimaria().Identificador():
|
||||
return pf.expresionPrimaria().Identificador().getText(), None
|
||||
return None, None
|
||||
|
||||
def visitar_condicional(self, ctx, env):
|
||||
val = self.visitar_logica_o(ctx.expresionLogicaO(), env)
|
||||
if ctx.Pregunta():
|
||||
if val:
|
||||
return self.visitar_expresion(ctx.expresion(), env)
|
||||
else:
|
||||
return self.visitar_condicional(ctx.expresionCondicional(), env)
|
||||
return val
|
||||
|
||||
def visitar_logica_o(self, ctx, env):
|
||||
items = ctx.expresionLogicaY()
|
||||
val = self.visitar_logica_y(items[0], env)
|
||||
for i in range(1, len(items)):
|
||||
if val: return True
|
||||
val = self.visitar_logica_y(items[i], env)
|
||||
if len(items) == 1:
|
||||
return val # no convertir a bool si es expresión simple
|
||||
return bool(val)
|
||||
|
||||
def visitar_logica_y(self, ctx, env):
|
||||
items = ctx.expresionIgualacion()
|
||||
val = self.visitar_igualacion(items[0], env)
|
||||
for i in range(1, len(items)):
|
||||
if not val: return False
|
||||
val = self.visitar_igualacion(items[i], env)
|
||||
if len(items) == 1:
|
||||
return val
|
||||
return bool(val)
|
||||
|
||||
def visitar_igualacion(self, ctx, env):
|
||||
val = self.visitar_relacional(ctx.expresionRelacional(0), env)
|
||||
ops = [t.getText() for t in ctx.getChildren()
|
||||
if hasattr(t, 'getText') and t.getText() in ('==', '!=')]
|
||||
for i, op in enumerate(ops):
|
||||
r = self.visitar_relacional(ctx.expresionRelacional(i + 1), env)
|
||||
val = (val == r) if op == '==' else (val != r)
|
||||
return val
|
||||
|
||||
def visitar_relacional(self, ctx, env):
|
||||
val = self.visitar_desplaz(ctx.expresionDesplazamiento(0), env)
|
||||
ops = [t.getText() for t in ctx.getChildren()
|
||||
if hasattr(t, 'getText') and t.getText() in ('<', '>', '<=', '>=')]
|
||||
for i, op in enumerate(ops):
|
||||
r = self.visitar_desplaz(ctx.expresionDesplazamiento(i + 1), env)
|
||||
if op == '<': val = val < r
|
||||
elif op == '>': val = val > r
|
||||
elif op == '<=': val = val <= r
|
||||
elif op == '>=': val = val >= r
|
||||
return val
|
||||
|
||||
def visitar_desplaz(self, ctx, env):
|
||||
val = self.visitar_aditiva(ctx.expresionAditiva(0), env)
|
||||
ops = [t.getText() for t in ctx.getChildren()
|
||||
if hasattr(t, 'getText') and t.getText() in ('<<', '>>')]
|
||||
for i, op in enumerate(ops):
|
||||
r = self.visitar_aditiva(ctx.expresionAditiva(i + 1), env)
|
||||
val = (int(val) << int(r)) if op == '<<' else (int(val) >> int(r))
|
||||
return val
|
||||
|
||||
def visitar_aditiva(self, ctx, env):
|
||||
val = self.visitar_mult(ctx.expresionMultiplicativa(0), env)
|
||||
ops = [t.getText() for t in ctx.getChildren()
|
||||
if hasattr(t, 'getText') and t.getText() in ('+', '-')]
|
||||
for i, op in enumerate(ops):
|
||||
r = self.visitar_mult(ctx.expresionMultiplicativa(i + 1), env)
|
||||
val = val + r if op == '+' else val - r
|
||||
return val
|
||||
|
||||
def visitar_mult(self, ctx, env):
|
||||
val = self.visitar_unaria(ctx.expresionUnaria(0), env)
|
||||
ops = [t.getText() for t in ctx.getChildren()
|
||||
if hasattr(t, 'getText') and t.getText() in ('*', '/', '%')]
|
||||
for i, op in enumerate(ops):
|
||||
r = self.visitar_unaria(ctx.expresionUnaria(i + 1), env)
|
||||
if op == '*': val = val * r
|
||||
elif op == '/':
|
||||
val = val // r if isinstance(val, int) and isinstance(r, int) else val / r
|
||||
elif op == '%': val = val % r
|
||||
return val
|
||||
|
||||
def visitar_unaria(self, ctx, env):
|
||||
if ctx.operadorUnario():
|
||||
op = ctx.operadorUnario().getText()
|
||||
inner = ctx.expresionUnaria()
|
||||
if op == '-': return -self.visitar_unaria(inner, env)
|
||||
if op == '+': return +self.visitar_unaria(inner, env)
|
||||
if op == '!': return not self.visitar_unaria(inner, env)
|
||||
if op == '~': return ~int(self.visitar_unaria(inner, env))
|
||||
if op == '++':
|
||||
nombre, idx = self._resolver_lvalue(inner, env)
|
||||
v = self._get_lvalue(nombre, idx, env) + 1
|
||||
self._set_lvalue(nombre, idx, v, env)
|
||||
return v
|
||||
if op == '--':
|
||||
nombre, idx = self._resolver_lvalue(inner, env)
|
||||
v = self._get_lvalue(nombre, idx, env) - 1
|
||||
self._set_lvalue(nombre, idx, v, env)
|
||||
return v
|
||||
if op == '&': return self.visitar_unaria(inner, env) # simplificado
|
||||
if op == '*': return self.visitar_unaria(inner, env) # simplificado
|
||||
return self.visitar_postfija(ctx.expresionPostfija(), env)
|
||||
|
||||
def _get_lvalue(self, nombre, idx, env):
|
||||
v = env.obtener(nombre)
|
||||
return v[idx] if idx is not None else v
|
||||
|
||||
def _set_lvalue(self, nombre, idx, val, env):
|
||||
if idx is not None:
|
||||
env.obtener(nombre)[idx] = val
|
||||
else:
|
||||
env.asignar(nombre, val)
|
||||
|
||||
def visitar_postfija(self, ctx, env):
|
||||
# Llamada a función
|
||||
if ctx.expresionPostfija() and ctx.ParenIzq():
|
||||
nombre_fn = ctx.expresionPostfija().expresionPrimaria().Identificador().getText()
|
||||
args = []
|
||||
if ctx.listaArgumentos():
|
||||
for ae in ctx.listaArgumentos().asignacionExpresion():
|
||||
args.append(self.visitar_asignacion(ae, env))
|
||||
return self.llamar_funcion(nombre_fn, args, env)
|
||||
# Índice arreglo
|
||||
if ctx.expresionPostfija() and ctx.CorcheteIzq():
|
||||
arr = self.visitar_postfija(ctx.expresionPostfija(), env)
|
||||
idx = int(self.visitar_expresion(ctx.expresion(), env))
|
||||
return arr[idx]
|
||||
# Acceso miembro
|
||||
if ctx.expresionPostfija() and ctx.Punto():
|
||||
obj = self.visitar_postfija(ctx.expresionPostfija(), env)
|
||||
campo = ctx.Identificador().getText()
|
||||
return obj.get(campo)
|
||||
# Postfix ++/--
|
||||
if ctx.expresionPostfija() and ctx.MasMas():
|
||||
nombre, idx = self._resolver_lvalue_pf(ctx.expresionPostfija(), env)
|
||||
v = self._get_lvalue(nombre, idx, env)
|
||||
self._set_lvalue(nombre, idx, v + 1, env)
|
||||
return v
|
||||
if ctx.expresionPostfija() and ctx.MenosMenos():
|
||||
nombre, idx = self._resolver_lvalue_pf(ctx.expresionPostfija(), env)
|
||||
v = self._get_lvalue(nombre, idx, env)
|
||||
self._set_lvalue(nombre, idx, v - 1, env)
|
||||
return v
|
||||
return self.visitar_primaria(ctx.expresionPrimaria(), env)
|
||||
|
||||
def _resolver_lvalue_pf(self, ctx_pf, env):
|
||||
if ctx_pf.expresionPrimaria() and ctx_pf.expresionPrimaria().Identificador():
|
||||
return ctx_pf.expresionPrimaria().Identificador().getText(), None
|
||||
return None, None
|
||||
|
||||
def visitar_primaria(self, ctx, env):
|
||||
if ctx.Identificador():
|
||||
return env.obtener(ctx.Identificador().getText())
|
||||
if ctx.constanteExpresion():
|
||||
return self.visitar_constante(ctx.constanteExpresion(), env)
|
||||
if ctx.CadenaLiteral():
|
||||
raw = ctx.CadenaLiteral().getText()[1:-1] # quitar comillas
|
||||
return raw.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
||||
if ctx.expresion():
|
||||
return self.visitar_expresion(ctx.expresion(), env)
|
||||
return None
|
||||
|
||||
def visitar_constante(self, ctx, env):
|
||||
if ctx.ConstanteEntera():
|
||||
txt = ctx.ConstanteEntera().getText()
|
||||
return int(txt, 0)
|
||||
if ctx.ConstanteFlotante():
|
||||
return float(ctx.ConstanteFlotante().getText())
|
||||
if ctx.ConstanteCaracteres():
|
||||
c = ctx.ConstanteCaracteres().getText()[1:-1]
|
||||
return ord(c.encode('raw_unicode_escape').decode('unicode_escape'))
|
||||
if ctx.Verdadero():
|
||||
return True
|
||||
if ctx.Falso():
|
||||
return False
|
||||
return None
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Error listener
|
||||
# ─────────────────────────────────────────────
|
||||
class ErrorZap(ErrorListener):
|
||||
def syntaxError(self, recognizer, offendingSymbol, line, col, msg, e):
|
||||
raise SyntaxError(f"[Línea {line}:{col}] {msg}")
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Punto de entrada
|
||||
# ─────────────────────────────────────────────
|
||||
def ejecutar_archivo(ruta):
|
||||
with open(ruta, 'r', encoding='utf-8') as f:
|
||||
codigo = f.read()
|
||||
|
||||
flujo = InputStream(codigo)
|
||||
lexer = zaplangLexer(flujo)
|
||||
lexer.removeErrorListeners()
|
||||
lexer.addErrorListener(ErrorZap())
|
||||
|
||||
tokens = CommonTokenStream(lexer)
|
||||
parser = zaplangParser(tokens)
|
||||
parser.removeErrorListeners()
|
||||
parser.addErrorListener(ErrorZap())
|
||||
|
||||
arbol = parser.unidadTraduccion()
|
||||
interprete = Interprete()
|
||||
interprete.ejecutar(arbol)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Uso: python interprete.py <archivo.zap>")
|
||||
sys.exit(1)
|
||||
try:
|
||||
ejecutar_archivo(sys.argv[1])
|
||||
except SyntaxError as e:
|
||||
print(f"Error de sintaxis: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
antlr4
|
||||
406
zaplangLexer.g4
Normal file
406
zaplangLexer.g4
Normal file
@@ -0,0 +1,406 @@
|
||||
lexer grammar zaplangLexer;
|
||||
|
||||
Bul
|
||||
: 'bul'
|
||||
;
|
||||
|
||||
Func
|
||||
: 'func'
|
||||
;
|
||||
|
||||
Fin //break
|
||||
: 'fin'
|
||||
;
|
||||
|
||||
Caso
|
||||
: 'caso'
|
||||
;
|
||||
|
||||
Carac
|
||||
: 'carac'
|
||||
;
|
||||
|
||||
Pordef //default
|
||||
: 'pordef'
|
||||
;
|
||||
|
||||
Hacer
|
||||
: 'hacer'
|
||||
;
|
||||
|
||||
Doble
|
||||
: 'doble'
|
||||
;
|
||||
|
||||
Sino
|
||||
: 'sino'
|
||||
;
|
||||
|
||||
Enum
|
||||
: 'enum'
|
||||
;
|
||||
|
||||
Falso
|
||||
: 'falso'
|
||||
;
|
||||
|
||||
Flot
|
||||
: 'flot'
|
||||
;
|
||||
|
||||
Por
|
||||
: 'por'
|
||||
;
|
||||
|
||||
Si
|
||||
: 'si'
|
||||
;
|
||||
|
||||
|
||||
Ent
|
||||
: 'Ent'
|
||||
;
|
||||
|
||||
//Nulptr
|
||||
// : 'nullptr'
|
||||
// ;
|
||||
|
||||
Retornar
|
||||
: 'retornar'
|
||||
;
|
||||
|
||||
|
||||
ConFirma
|
||||
: 'cf'
|
||||
;
|
||||
|
||||
Estruct
|
||||
: 'estruct'
|
||||
;
|
||||
|
||||
Interrup
|
||||
: 'interrup'
|
||||
;
|
||||
|
||||
Verdadero
|
||||
: 'verdadero'
|
||||
;
|
||||
|
||||
SinFirma
|
||||
: 'sf'
|
||||
;
|
||||
|
||||
Vacio
|
||||
: 'vacio'
|
||||
;
|
||||
|
||||
Mientras // While
|
||||
: 'mientras'
|
||||
;
|
||||
|
||||
ParenIzq
|
||||
: '('
|
||||
;
|
||||
|
||||
ParenDer
|
||||
: ')'
|
||||
;
|
||||
|
||||
CorcheteIzq
|
||||
: '['
|
||||
;
|
||||
|
||||
CorcheteDer
|
||||
: ']'
|
||||
;
|
||||
|
||||
LlaveIzq
|
||||
: '{'
|
||||
;
|
||||
|
||||
LlaveDer
|
||||
: '}'
|
||||
;
|
||||
|
||||
MenorQue
|
||||
: '<'
|
||||
;
|
||||
|
||||
MenorOIgualQue
|
||||
: '<='
|
||||
;
|
||||
|
||||
MayorQue
|
||||
: '>'
|
||||
;
|
||||
|
||||
MayorOIgualQue
|
||||
: '>='
|
||||
;
|
||||
|
||||
Mas
|
||||
: '+'
|
||||
;
|
||||
|
||||
MasMas
|
||||
: '++'
|
||||
;
|
||||
|
||||
Menos
|
||||
: '-'
|
||||
;
|
||||
|
||||
MenosMenos
|
||||
: '--'
|
||||
;
|
||||
|
||||
Estrella
|
||||
: '*'
|
||||
;
|
||||
|
||||
Div
|
||||
: '/'
|
||||
;
|
||||
|
||||
Mod
|
||||
: '%'
|
||||
;
|
||||
|
||||
Y
|
||||
: '&'
|
||||
;
|
||||
|
||||
O
|
||||
: '|'
|
||||
;
|
||||
|
||||
DesplazIzq
|
||||
: '<<'
|
||||
;
|
||||
|
||||
DesplazDer
|
||||
: '>>'
|
||||
;
|
||||
|
||||
Xor
|
||||
: '^'
|
||||
;
|
||||
|
||||
Complemento
|
||||
: '~'
|
||||
;
|
||||
|
||||
YY
|
||||
: '&&'
|
||||
;
|
||||
|
||||
OO
|
||||
: '||'
|
||||
;
|
||||
|
||||
Not
|
||||
: '!'
|
||||
;
|
||||
|
||||
Pregunta
|
||||
: '?'
|
||||
;
|
||||
|
||||
DosPuntos
|
||||
: ':'
|
||||
;
|
||||
|
||||
PuntoYComa
|
||||
: ';'
|
||||
;
|
||||
|
||||
Coma
|
||||
: ','
|
||||
;
|
||||
|
||||
Asignar
|
||||
: '='
|
||||
;
|
||||
|
||||
// Operadores de asignación compuesta
|
||||
EstrellaAsignacion
|
||||
: '*='
|
||||
;
|
||||
|
||||
DivAsignacion
|
||||
: '/='
|
||||
;
|
||||
|
||||
ModAsignacion
|
||||
: '%='
|
||||
;
|
||||
|
||||
MasAsignacion
|
||||
: '+='
|
||||
;
|
||||
|
||||
MenosAsignacion
|
||||
: '-='
|
||||
;
|
||||
|
||||
|
||||
YAsignacion
|
||||
: '&='
|
||||
;
|
||||
|
||||
OAsignacion
|
||||
: '|='
|
||||
;
|
||||
|
||||
DesplazIzqAsignacion
|
||||
: '<<='
|
||||
;
|
||||
|
||||
DesplazDerAsignacion
|
||||
: '>>='
|
||||
;
|
||||
|
||||
XorAsignacion
|
||||
: '^='
|
||||
;
|
||||
|
||||
Igual
|
||||
: '=='
|
||||
;
|
||||
|
||||
Diferente
|
||||
: '!='
|
||||
;
|
||||
|
||||
Flecha
|
||||
: '->'
|
||||
;
|
||||
|
||||
Punto
|
||||
: '.'
|
||||
;
|
||||
|
||||
Identificador
|
||||
: IdentificadorSindigito (IdentificadorSindigito | Digito)*
|
||||
;
|
||||
|
||||
fragment IdentificadorSindigito
|
||||
: Nodigito
|
||||
;
|
||||
|
||||
fragment Nodigito
|
||||
: [a-zA-Z_]
|
||||
;
|
||||
|
||||
fragment Digito
|
||||
: [0-9]
|
||||
;
|
||||
|
||||
ConstanteEntera
|
||||
: ConstanteDecimal
|
||||
| ConstanteOctal
|
||||
| HexaConstanteDecimal
|
||||
;
|
||||
|
||||
fragment ConstanteDecimal
|
||||
: DigitoNoCero Digito*
|
||||
;
|
||||
|
||||
fragment ConstanteOctal
|
||||
: '0' DigitoOctal*
|
||||
;
|
||||
|
||||
fragment HexaConstanteDecimal
|
||||
: PrefijoHexadecimal DigitoHexadecimal+
|
||||
;
|
||||
|
||||
fragment PrefijoHexadecimal
|
||||
: '0' [xX]
|
||||
;
|
||||
|
||||
fragment DigitoNoCero
|
||||
: [1-9]
|
||||
;
|
||||
|
||||
fragment DigitoOctal
|
||||
: [0-7]
|
||||
;
|
||||
|
||||
fragment DigitoHexadecimal
|
||||
: [0-9a-fA-F]
|
||||
;
|
||||
|
||||
fragment SufijoEntero
|
||||
: [uUlL]+
|
||||
;
|
||||
|
||||
ConstanteFlotante
|
||||
: (Digito+ '.' Digito* | Digito* '.' Digito+) ([eE] [+-]? Digito+)? [fFdD]?
|
||||
| Digito+ [eE] [+-]? Digito+ [fFdD]?
|
||||
;
|
||||
|
||||
ConstanteCaracteres
|
||||
: '\'' CCharSequence '\''
|
||||
;
|
||||
|
||||
fragment CCharSequence
|
||||
: CChar+
|
||||
;
|
||||
|
||||
fragment CChar
|
||||
: ~['\\\r\n]
|
||||
| SecuenciaEscape
|
||||
;
|
||||
|
||||
fragment SecuenciaEscape
|
||||
: SecuenciaEscapeSimple
|
||||
| SecuenciaEscapeOctal
|
||||
| SecuenciaEscapeHexadecimal
|
||||
;
|
||||
|
||||
fragment SecuenciaEscapeSimple
|
||||
: '\\' ['"?abfnrtv\\]
|
||||
;
|
||||
|
||||
fragment SecuenciaEscapeOctal
|
||||
: '\\' DigitoOctal DigitoOctal? DigitoOctal?
|
||||
;
|
||||
|
||||
fragment SecuenciaEscapeHexadecimal
|
||||
: '\\x' DigitoHexadecimal+
|
||||
;
|
||||
|
||||
CadenaLiteral
|
||||
: '"' SSecuenciaCaracteres? '"'
|
||||
;
|
||||
|
||||
fragment SSecuenciaCaracteres
|
||||
: SCaracter+
|
||||
;
|
||||
|
||||
fragment SCaracter
|
||||
: ~["\\\r\n]
|
||||
| SecuenciaEscape
|
||||
| '\\\n'
|
||||
| '\\\r\n'
|
||||
;
|
||||
|
||||
Whitespace
|
||||
: [ \t]+ -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
Newline
|
||||
: ('\r' '\n'? | '\n') -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
BlockComment
|
||||
: '/*' .*? '*/' -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
LineComment
|
||||
: '//' ~[\r\n]* -> channel(HIDDEN)
|
||||
;
|
||||
|
||||
LineCommentHash
|
||||
: '#' ~[\r\n]* -> channel(HIDDEN)
|
||||
;
|
||||
270
zaplangLexer.interp
Normal file
270
zaplangLexer.interp
Normal file
File diff suppressed because one or more lines are too long
405
zaplangLexer.py
Normal file
405
zaplangLexer.py
Normal file
@@ -0,0 +1,405 @@
|
||||
# Generated from zaplangLexer.g4 by ANTLR 4.13.2
|
||||
from antlr4 import *
|
||||
from io import StringIO
|
||||
import sys
|
||||
if sys.version_info[1] > 5:
|
||||
from typing import TextIO
|
||||
else:
|
||||
from typing.io import TextIO
|
||||
|
||||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,78,659,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
||||
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
||||
26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,
|
||||
32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,
|
||||
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,
|
||||
45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,
|
||||
52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,
|
||||
58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,
|
||||
65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,
|
||||
71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,
|
||||
78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,
|
||||
84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,
|
||||
91,7,91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,1,0,1,
|
||||
0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,
|
||||
3,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,
|
||||
6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,
|
||||
9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,
|
||||
1,11,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,15,
|
||||
1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,
|
||||
1,17,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,
|
||||
1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,20,
|
||||
1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,
|
||||
1,22,1,22,1,22,1,22,1,23,1,23,1,24,1,24,1,25,1,25,1,26,1,26,1,27,
|
||||
1,27,1,28,1,28,1,29,1,29,1,30,1,30,1,30,1,31,1,31,1,32,1,32,1,32,
|
||||
1,33,1,33,1,34,1,34,1,34,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,38,
|
||||
1,38,1,39,1,39,1,40,1,40,1,41,1,41,1,42,1,42,1,42,1,43,1,43,1,43,
|
||||
1,44,1,44,1,45,1,45,1,46,1,46,1,46,1,47,1,47,1,47,1,48,1,48,1,49,
|
||||
1,49,1,50,1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,54,1,54,1,54,1,55,
|
||||
1,55,1,55,1,56,1,56,1,56,1,57,1,57,1,57,1,58,1,58,1,58,1,59,1,59,
|
||||
1,59,1,60,1,60,1,60,1,61,1,61,1,61,1,61,1,62,1,62,1,62,1,62,1,63,
|
||||
1,63,1,63,1,64,1,64,1,64,1,65,1,65,1,65,1,66,1,66,1,66,1,67,1,67,
|
||||
1,68,1,68,1,68,5,68,444,8,68,10,68,12,68,447,9,68,1,69,1,69,1,70,
|
||||
1,70,1,71,1,71,1,72,1,72,1,72,3,72,458,8,72,1,73,1,73,5,73,462,8,
|
||||
73,10,73,12,73,465,9,73,1,74,1,74,5,74,469,8,74,10,74,12,74,472,
|
||||
9,74,1,75,1,75,4,75,476,8,75,11,75,12,75,477,1,76,1,76,1,76,1,77,
|
||||
1,77,1,78,1,78,1,79,1,79,1,80,4,80,490,8,80,11,80,12,80,491,1,81,
|
||||
4,81,495,8,81,11,81,12,81,496,1,81,1,81,5,81,501,8,81,10,81,12,81,
|
||||
504,9,81,1,81,5,81,507,8,81,10,81,12,81,510,9,81,1,81,1,81,4,81,
|
||||
514,8,81,11,81,12,81,515,3,81,518,8,81,1,81,1,81,3,81,522,8,81,1,
|
||||
81,4,81,525,8,81,11,81,12,81,526,3,81,529,8,81,1,81,3,81,532,8,81,
|
||||
1,81,4,81,535,8,81,11,81,12,81,536,1,81,1,81,3,81,541,8,81,1,81,
|
||||
4,81,544,8,81,11,81,12,81,545,1,81,3,81,549,8,81,3,81,551,8,81,1,
|
||||
82,1,82,1,82,1,82,1,83,4,83,558,8,83,11,83,12,83,559,1,84,1,84,3,
|
||||
84,564,8,84,1,85,1,85,1,85,3,85,569,8,85,1,86,1,86,1,86,1,87,1,87,
|
||||
1,87,3,87,577,8,87,1,87,3,87,580,8,87,1,88,1,88,1,88,1,88,4,88,586,
|
||||
8,88,11,88,12,88,587,1,89,1,89,3,89,592,8,89,1,89,1,89,1,90,4,90,
|
||||
597,8,90,11,90,12,90,598,1,91,1,91,1,91,1,91,1,91,1,91,1,91,3,91,
|
||||
608,8,91,1,92,4,92,611,8,92,11,92,12,92,612,1,92,1,92,1,93,1,93,
|
||||
3,93,619,8,93,1,93,3,93,622,8,93,1,93,1,93,1,94,1,94,1,94,1,94,5,
|
||||
94,630,8,94,10,94,12,94,633,9,94,1,94,1,94,1,94,1,94,1,94,1,95,1,
|
||||
95,1,95,1,95,5,95,644,8,95,10,95,12,95,647,9,95,1,95,1,95,1,96,1,
|
||||
96,5,96,653,8,96,10,96,12,96,656,9,96,1,96,1,96,1,631,0,97,1,1,3,
|
||||
2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,
|
||||
29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,
|
||||
51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,
|
||||
73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,
|
||||
95,48,97,49,99,50,101,51,103,52,105,53,107,54,109,55,111,56,113,
|
||||
57,115,58,117,59,119,60,121,61,123,62,125,63,127,64,129,65,131,66,
|
||||
133,67,135,68,137,69,139,0,141,0,143,0,145,70,147,0,149,0,151,0,
|
||||
153,0,155,0,157,0,159,0,161,0,163,71,165,72,167,0,169,0,171,0,173,
|
||||
0,175,0,177,0,179,73,181,0,183,0,185,74,187,75,189,76,191,77,193,
|
||||
78,1,0,15,3,0,65,90,95,95,97,122,1,0,48,57,2,0,88,88,120,120,1,0,
|
||||
49,57,1,0,48,55,3,0,48,57,65,70,97,102,4,0,76,76,85,85,108,108,117,
|
||||
117,2,0,69,69,101,101,2,0,43,43,45,45,4,0,68,68,70,70,100,100,102,
|
||||
102,4,0,10,10,13,13,39,39,92,92,10,0,34,34,39,39,63,63,92,92,97,
|
||||
98,102,102,110,110,114,114,116,116,118,118,4,0,10,10,13,13,34,34,
|
||||
92,92,2,0,9,9,32,32,2,0,10,10,13,13,679,0,1,1,0,0,0,0,3,1,0,0,0,
|
||||
0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,
|
||||
15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,
|
||||
25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,
|
||||
35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,
|
||||
45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,
|
||||
55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,
|
||||
65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,
|
||||
75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,
|
||||
85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,
|
||||
95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,
|
||||
0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,
|
||||
0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,
|
||||
123,1,0,0,0,0,125,1,0,0,0,0,127,1,0,0,0,0,129,1,0,0,0,0,131,1,0,
|
||||
0,0,0,133,1,0,0,0,0,135,1,0,0,0,0,137,1,0,0,0,0,145,1,0,0,0,0,163,
|
||||
1,0,0,0,0,165,1,0,0,0,0,179,1,0,0,0,0,185,1,0,0,0,0,187,1,0,0,0,
|
||||
0,189,1,0,0,0,0,191,1,0,0,0,0,193,1,0,0,0,1,195,1,0,0,0,3,199,1,
|
||||
0,0,0,5,204,1,0,0,0,7,208,1,0,0,0,9,213,1,0,0,0,11,219,1,0,0,0,13,
|
||||
226,1,0,0,0,15,232,1,0,0,0,17,238,1,0,0,0,19,243,1,0,0,0,21,248,
|
||||
1,0,0,0,23,254,1,0,0,0,25,259,1,0,0,0,27,263,1,0,0,0,29,266,1,0,
|
||||
0,0,31,270,1,0,0,0,33,279,1,0,0,0,35,282,1,0,0,0,37,290,1,0,0,0,
|
||||
39,299,1,0,0,0,41,309,1,0,0,0,43,312,1,0,0,0,45,318,1,0,0,0,47,327,
|
||||
1,0,0,0,49,329,1,0,0,0,51,331,1,0,0,0,53,333,1,0,0,0,55,335,1,0,
|
||||
0,0,57,337,1,0,0,0,59,339,1,0,0,0,61,341,1,0,0,0,63,344,1,0,0,0,
|
||||
65,346,1,0,0,0,67,349,1,0,0,0,69,351,1,0,0,0,71,354,1,0,0,0,73,356,
|
||||
1,0,0,0,75,359,1,0,0,0,77,361,1,0,0,0,79,363,1,0,0,0,81,365,1,0,
|
||||
0,0,83,367,1,0,0,0,85,369,1,0,0,0,87,372,1,0,0,0,89,375,1,0,0,0,
|
||||
91,377,1,0,0,0,93,379,1,0,0,0,95,382,1,0,0,0,97,385,1,0,0,0,99,387,
|
||||
1,0,0,0,101,389,1,0,0,0,103,391,1,0,0,0,105,393,1,0,0,0,107,395,
|
||||
1,0,0,0,109,397,1,0,0,0,111,400,1,0,0,0,113,403,1,0,0,0,115,406,
|
||||
1,0,0,0,117,409,1,0,0,0,119,412,1,0,0,0,121,415,1,0,0,0,123,418,
|
||||
1,0,0,0,125,422,1,0,0,0,127,426,1,0,0,0,129,429,1,0,0,0,131,432,
|
||||
1,0,0,0,133,435,1,0,0,0,135,438,1,0,0,0,137,440,1,0,0,0,139,448,
|
||||
1,0,0,0,141,450,1,0,0,0,143,452,1,0,0,0,145,457,1,0,0,0,147,459,
|
||||
1,0,0,0,149,466,1,0,0,0,151,473,1,0,0,0,153,479,1,0,0,0,155,482,
|
||||
1,0,0,0,157,484,1,0,0,0,159,486,1,0,0,0,161,489,1,0,0,0,163,550,
|
||||
1,0,0,0,165,552,1,0,0,0,167,557,1,0,0,0,169,563,1,0,0,0,171,568,
|
||||
1,0,0,0,173,570,1,0,0,0,175,573,1,0,0,0,177,581,1,0,0,0,179,589,
|
||||
1,0,0,0,181,596,1,0,0,0,183,607,1,0,0,0,185,610,1,0,0,0,187,621,
|
||||
1,0,0,0,189,625,1,0,0,0,191,639,1,0,0,0,193,650,1,0,0,0,195,196,
|
||||
5,98,0,0,196,197,5,117,0,0,197,198,5,108,0,0,198,2,1,0,0,0,199,200,
|
||||
5,102,0,0,200,201,5,117,0,0,201,202,5,110,0,0,202,203,5,99,0,0,203,
|
||||
4,1,0,0,0,204,205,5,102,0,0,205,206,5,105,0,0,206,207,5,110,0,0,
|
||||
207,6,1,0,0,0,208,209,5,99,0,0,209,210,5,97,0,0,210,211,5,115,0,
|
||||
0,211,212,5,111,0,0,212,8,1,0,0,0,213,214,5,99,0,0,214,215,5,97,
|
||||
0,0,215,216,5,114,0,0,216,217,5,97,0,0,217,218,5,99,0,0,218,10,1,
|
||||
0,0,0,219,220,5,112,0,0,220,221,5,111,0,0,221,222,5,114,0,0,222,
|
||||
223,5,100,0,0,223,224,5,101,0,0,224,225,5,102,0,0,225,12,1,0,0,0,
|
||||
226,227,5,104,0,0,227,228,5,97,0,0,228,229,5,99,0,0,229,230,5,101,
|
||||
0,0,230,231,5,114,0,0,231,14,1,0,0,0,232,233,5,100,0,0,233,234,5,
|
||||
111,0,0,234,235,5,98,0,0,235,236,5,108,0,0,236,237,5,101,0,0,237,
|
||||
16,1,0,0,0,238,239,5,115,0,0,239,240,5,105,0,0,240,241,5,110,0,0,
|
||||
241,242,5,111,0,0,242,18,1,0,0,0,243,244,5,101,0,0,244,245,5,110,
|
||||
0,0,245,246,5,117,0,0,246,247,5,109,0,0,247,20,1,0,0,0,248,249,5,
|
||||
102,0,0,249,250,5,97,0,0,250,251,5,108,0,0,251,252,5,115,0,0,252,
|
||||
253,5,111,0,0,253,22,1,0,0,0,254,255,5,102,0,0,255,256,5,108,0,0,
|
||||
256,257,5,111,0,0,257,258,5,116,0,0,258,24,1,0,0,0,259,260,5,112,
|
||||
0,0,260,261,5,111,0,0,261,262,5,114,0,0,262,26,1,0,0,0,263,264,5,
|
||||
115,0,0,264,265,5,105,0,0,265,28,1,0,0,0,266,267,5,69,0,0,267,268,
|
||||
5,110,0,0,268,269,5,116,0,0,269,30,1,0,0,0,270,271,5,114,0,0,271,
|
||||
272,5,101,0,0,272,273,5,116,0,0,273,274,5,111,0,0,274,275,5,114,
|
||||
0,0,275,276,5,110,0,0,276,277,5,97,0,0,277,278,5,114,0,0,278,32,
|
||||
1,0,0,0,279,280,5,99,0,0,280,281,5,102,0,0,281,34,1,0,0,0,282,283,
|
||||
5,101,0,0,283,284,5,115,0,0,284,285,5,116,0,0,285,286,5,114,0,0,
|
||||
286,287,5,117,0,0,287,288,5,99,0,0,288,289,5,116,0,0,289,36,1,0,
|
||||
0,0,290,291,5,105,0,0,291,292,5,110,0,0,292,293,5,116,0,0,293,294,
|
||||
5,101,0,0,294,295,5,114,0,0,295,296,5,114,0,0,296,297,5,117,0,0,
|
||||
297,298,5,112,0,0,298,38,1,0,0,0,299,300,5,118,0,0,300,301,5,101,
|
||||
0,0,301,302,5,114,0,0,302,303,5,100,0,0,303,304,5,97,0,0,304,305,
|
||||
5,100,0,0,305,306,5,101,0,0,306,307,5,114,0,0,307,308,5,111,0,0,
|
||||
308,40,1,0,0,0,309,310,5,115,0,0,310,311,5,102,0,0,311,42,1,0,0,
|
||||
0,312,313,5,118,0,0,313,314,5,97,0,0,314,315,5,99,0,0,315,316,5,
|
||||
105,0,0,316,317,5,111,0,0,317,44,1,0,0,0,318,319,5,109,0,0,319,320,
|
||||
5,105,0,0,320,321,5,101,0,0,321,322,5,110,0,0,322,323,5,116,0,0,
|
||||
323,324,5,114,0,0,324,325,5,97,0,0,325,326,5,115,0,0,326,46,1,0,
|
||||
0,0,327,328,5,40,0,0,328,48,1,0,0,0,329,330,5,41,0,0,330,50,1,0,
|
||||
0,0,331,332,5,91,0,0,332,52,1,0,0,0,333,334,5,93,0,0,334,54,1,0,
|
||||
0,0,335,336,5,123,0,0,336,56,1,0,0,0,337,338,5,125,0,0,338,58,1,
|
||||
0,0,0,339,340,5,60,0,0,340,60,1,0,0,0,341,342,5,60,0,0,342,343,5,
|
||||
61,0,0,343,62,1,0,0,0,344,345,5,62,0,0,345,64,1,0,0,0,346,347,5,
|
||||
62,0,0,347,348,5,61,0,0,348,66,1,0,0,0,349,350,5,43,0,0,350,68,1,
|
||||
0,0,0,351,352,5,43,0,0,352,353,5,43,0,0,353,70,1,0,0,0,354,355,5,
|
||||
45,0,0,355,72,1,0,0,0,356,357,5,45,0,0,357,358,5,45,0,0,358,74,1,
|
||||
0,0,0,359,360,5,42,0,0,360,76,1,0,0,0,361,362,5,47,0,0,362,78,1,
|
||||
0,0,0,363,364,5,37,0,0,364,80,1,0,0,0,365,366,5,38,0,0,366,82,1,
|
||||
0,0,0,367,368,5,124,0,0,368,84,1,0,0,0,369,370,5,60,0,0,370,371,
|
||||
5,60,0,0,371,86,1,0,0,0,372,373,5,62,0,0,373,374,5,62,0,0,374,88,
|
||||
1,0,0,0,375,376,5,94,0,0,376,90,1,0,0,0,377,378,5,126,0,0,378,92,
|
||||
1,0,0,0,379,380,5,38,0,0,380,381,5,38,0,0,381,94,1,0,0,0,382,383,
|
||||
5,124,0,0,383,384,5,124,0,0,384,96,1,0,0,0,385,386,5,33,0,0,386,
|
||||
98,1,0,0,0,387,388,5,63,0,0,388,100,1,0,0,0,389,390,5,58,0,0,390,
|
||||
102,1,0,0,0,391,392,5,59,0,0,392,104,1,0,0,0,393,394,5,44,0,0,394,
|
||||
106,1,0,0,0,395,396,5,61,0,0,396,108,1,0,0,0,397,398,5,42,0,0,398,
|
||||
399,5,61,0,0,399,110,1,0,0,0,400,401,5,47,0,0,401,402,5,61,0,0,402,
|
||||
112,1,0,0,0,403,404,5,37,0,0,404,405,5,61,0,0,405,114,1,0,0,0,406,
|
||||
407,5,43,0,0,407,408,5,61,0,0,408,116,1,0,0,0,409,410,5,45,0,0,410,
|
||||
411,5,61,0,0,411,118,1,0,0,0,412,413,5,38,0,0,413,414,5,61,0,0,414,
|
||||
120,1,0,0,0,415,416,5,124,0,0,416,417,5,61,0,0,417,122,1,0,0,0,418,
|
||||
419,5,60,0,0,419,420,5,60,0,0,420,421,5,61,0,0,421,124,1,0,0,0,422,
|
||||
423,5,62,0,0,423,424,5,62,0,0,424,425,5,61,0,0,425,126,1,0,0,0,426,
|
||||
427,5,94,0,0,427,428,5,61,0,0,428,128,1,0,0,0,429,430,5,61,0,0,430,
|
||||
431,5,61,0,0,431,130,1,0,0,0,432,433,5,33,0,0,433,434,5,61,0,0,434,
|
||||
132,1,0,0,0,435,436,5,45,0,0,436,437,5,62,0,0,437,134,1,0,0,0,438,
|
||||
439,5,46,0,0,439,136,1,0,0,0,440,445,3,139,69,0,441,444,3,139,69,
|
||||
0,442,444,3,143,71,0,443,441,1,0,0,0,443,442,1,0,0,0,444,447,1,0,
|
||||
0,0,445,443,1,0,0,0,445,446,1,0,0,0,446,138,1,0,0,0,447,445,1,0,
|
||||
0,0,448,449,3,141,70,0,449,140,1,0,0,0,450,451,7,0,0,0,451,142,1,
|
||||
0,0,0,452,453,7,1,0,0,453,144,1,0,0,0,454,458,3,147,73,0,455,458,
|
||||
3,149,74,0,456,458,3,151,75,0,457,454,1,0,0,0,457,455,1,0,0,0,457,
|
||||
456,1,0,0,0,458,146,1,0,0,0,459,463,3,155,77,0,460,462,3,143,71,
|
||||
0,461,460,1,0,0,0,462,465,1,0,0,0,463,461,1,0,0,0,463,464,1,0,0,
|
||||
0,464,148,1,0,0,0,465,463,1,0,0,0,466,470,5,48,0,0,467,469,3,157,
|
||||
78,0,468,467,1,0,0,0,469,472,1,0,0,0,470,468,1,0,0,0,470,471,1,0,
|
||||
0,0,471,150,1,0,0,0,472,470,1,0,0,0,473,475,3,153,76,0,474,476,3,
|
||||
159,79,0,475,474,1,0,0,0,476,477,1,0,0,0,477,475,1,0,0,0,477,478,
|
||||
1,0,0,0,478,152,1,0,0,0,479,480,5,48,0,0,480,481,7,2,0,0,481,154,
|
||||
1,0,0,0,482,483,7,3,0,0,483,156,1,0,0,0,484,485,7,4,0,0,485,158,
|
||||
1,0,0,0,486,487,7,5,0,0,487,160,1,0,0,0,488,490,7,6,0,0,489,488,
|
||||
1,0,0,0,490,491,1,0,0,0,491,489,1,0,0,0,491,492,1,0,0,0,492,162,
|
||||
1,0,0,0,493,495,3,143,71,0,494,493,1,0,0,0,495,496,1,0,0,0,496,494,
|
||||
1,0,0,0,496,497,1,0,0,0,497,498,1,0,0,0,498,502,5,46,0,0,499,501,
|
||||
3,143,71,0,500,499,1,0,0,0,501,504,1,0,0,0,502,500,1,0,0,0,502,503,
|
||||
1,0,0,0,503,518,1,0,0,0,504,502,1,0,0,0,505,507,3,143,71,0,506,505,
|
||||
1,0,0,0,507,510,1,0,0,0,508,506,1,0,0,0,508,509,1,0,0,0,509,511,
|
||||
1,0,0,0,510,508,1,0,0,0,511,513,5,46,0,0,512,514,3,143,71,0,513,
|
||||
512,1,0,0,0,514,515,1,0,0,0,515,513,1,0,0,0,515,516,1,0,0,0,516,
|
||||
518,1,0,0,0,517,494,1,0,0,0,517,508,1,0,0,0,518,528,1,0,0,0,519,
|
||||
521,7,7,0,0,520,522,7,8,0,0,521,520,1,0,0,0,521,522,1,0,0,0,522,
|
||||
524,1,0,0,0,523,525,3,143,71,0,524,523,1,0,0,0,525,526,1,0,0,0,526,
|
||||
524,1,0,0,0,526,527,1,0,0,0,527,529,1,0,0,0,528,519,1,0,0,0,528,
|
||||
529,1,0,0,0,529,531,1,0,0,0,530,532,7,9,0,0,531,530,1,0,0,0,531,
|
||||
532,1,0,0,0,532,551,1,0,0,0,533,535,3,143,71,0,534,533,1,0,0,0,535,
|
||||
536,1,0,0,0,536,534,1,0,0,0,536,537,1,0,0,0,537,538,1,0,0,0,538,
|
||||
540,7,7,0,0,539,541,7,8,0,0,540,539,1,0,0,0,540,541,1,0,0,0,541,
|
||||
543,1,0,0,0,542,544,3,143,71,0,543,542,1,0,0,0,544,545,1,0,0,0,545,
|
||||
543,1,0,0,0,545,546,1,0,0,0,546,548,1,0,0,0,547,549,7,9,0,0,548,
|
||||
547,1,0,0,0,548,549,1,0,0,0,549,551,1,0,0,0,550,517,1,0,0,0,550,
|
||||
534,1,0,0,0,551,164,1,0,0,0,552,553,5,39,0,0,553,554,3,167,83,0,
|
||||
554,555,5,39,0,0,555,166,1,0,0,0,556,558,3,169,84,0,557,556,1,0,
|
||||
0,0,558,559,1,0,0,0,559,557,1,0,0,0,559,560,1,0,0,0,560,168,1,0,
|
||||
0,0,561,564,8,10,0,0,562,564,3,171,85,0,563,561,1,0,0,0,563,562,
|
||||
1,0,0,0,564,170,1,0,0,0,565,569,3,173,86,0,566,569,3,175,87,0,567,
|
||||
569,3,177,88,0,568,565,1,0,0,0,568,566,1,0,0,0,568,567,1,0,0,0,569,
|
||||
172,1,0,0,0,570,571,5,92,0,0,571,572,7,11,0,0,572,174,1,0,0,0,573,
|
||||
574,5,92,0,0,574,576,3,157,78,0,575,577,3,157,78,0,576,575,1,0,0,
|
||||
0,576,577,1,0,0,0,577,579,1,0,0,0,578,580,3,157,78,0,579,578,1,0,
|
||||
0,0,579,580,1,0,0,0,580,176,1,0,0,0,581,582,5,92,0,0,582,583,5,120,
|
||||
0,0,583,585,1,0,0,0,584,586,3,159,79,0,585,584,1,0,0,0,586,587,1,
|
||||
0,0,0,587,585,1,0,0,0,587,588,1,0,0,0,588,178,1,0,0,0,589,591,5,
|
||||
34,0,0,590,592,3,181,90,0,591,590,1,0,0,0,591,592,1,0,0,0,592,593,
|
||||
1,0,0,0,593,594,5,34,0,0,594,180,1,0,0,0,595,597,3,183,91,0,596,
|
||||
595,1,0,0,0,597,598,1,0,0,0,598,596,1,0,0,0,598,599,1,0,0,0,599,
|
||||
182,1,0,0,0,600,608,8,12,0,0,601,608,3,171,85,0,602,603,5,92,0,0,
|
||||
603,608,5,10,0,0,604,605,5,92,0,0,605,606,5,13,0,0,606,608,5,10,
|
||||
0,0,607,600,1,0,0,0,607,601,1,0,0,0,607,602,1,0,0,0,607,604,1,0,
|
||||
0,0,608,184,1,0,0,0,609,611,7,13,0,0,610,609,1,0,0,0,611,612,1,0,
|
||||
0,0,612,610,1,0,0,0,612,613,1,0,0,0,613,614,1,0,0,0,614,615,6,92,
|
||||
0,0,615,186,1,0,0,0,616,618,5,13,0,0,617,619,5,10,0,0,618,617,1,
|
||||
0,0,0,618,619,1,0,0,0,619,622,1,0,0,0,620,622,5,10,0,0,621,616,1,
|
||||
0,0,0,621,620,1,0,0,0,622,623,1,0,0,0,623,624,6,93,0,0,624,188,1,
|
||||
0,0,0,625,626,5,47,0,0,626,627,5,42,0,0,627,631,1,0,0,0,628,630,
|
||||
9,0,0,0,629,628,1,0,0,0,630,633,1,0,0,0,631,632,1,0,0,0,631,629,
|
||||
1,0,0,0,632,634,1,0,0,0,633,631,1,0,0,0,634,635,5,42,0,0,635,636,
|
||||
5,47,0,0,636,637,1,0,0,0,637,638,6,94,0,0,638,190,1,0,0,0,639,640,
|
||||
5,47,0,0,640,641,5,47,0,0,641,645,1,0,0,0,642,644,8,14,0,0,643,642,
|
||||
1,0,0,0,644,647,1,0,0,0,645,643,1,0,0,0,645,646,1,0,0,0,646,648,
|
||||
1,0,0,0,647,645,1,0,0,0,648,649,6,95,0,0,649,192,1,0,0,0,650,654,
|
||||
5,35,0,0,651,653,8,14,0,0,652,651,1,0,0,0,653,656,1,0,0,0,654,652,
|
||||
1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656,654,1,0,0,0,657,658,
|
||||
6,96,0,0,658,194,1,0,0,0,37,0,443,445,457,463,470,477,491,496,502,
|
||||
508,515,517,521,526,528,531,536,540,545,548,550,559,563,568,576,
|
||||
579,587,591,598,607,612,618,621,631,645,654,1,0,1,0
|
||||
]
|
||||
|
||||
class zaplangLexer(Lexer):
|
||||
|
||||
atn = ATNDeserializer().deserialize(serializedATN())
|
||||
|
||||
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
||||
|
||||
Bul = 1
|
||||
Func = 2
|
||||
Fin = 3
|
||||
Caso = 4
|
||||
Carac = 5
|
||||
Pordef = 6
|
||||
Hacer = 7
|
||||
Doble = 8
|
||||
Sino = 9
|
||||
Enum = 10
|
||||
Falso = 11
|
||||
Flot = 12
|
||||
Por = 13
|
||||
Si = 14
|
||||
Ent = 15
|
||||
Retornar = 16
|
||||
ConFirma = 17
|
||||
Estruct = 18
|
||||
Interrup = 19
|
||||
Verdadero = 20
|
||||
SinFirma = 21
|
||||
Vacio = 22
|
||||
Mientras = 23
|
||||
ParenIzq = 24
|
||||
ParenDer = 25
|
||||
CorcheteIzq = 26
|
||||
CorcheteDer = 27
|
||||
LlaveIzq = 28
|
||||
LlaveDer = 29
|
||||
MenorQue = 30
|
||||
MenorOIgualQue = 31
|
||||
MayorQue = 32
|
||||
MayorOIgualQue = 33
|
||||
Mas = 34
|
||||
MasMas = 35
|
||||
Menos = 36
|
||||
MenosMenos = 37
|
||||
Estrella = 38
|
||||
Div = 39
|
||||
Mod = 40
|
||||
Y = 41
|
||||
O = 42
|
||||
DesplazIzq = 43
|
||||
DesplazDer = 44
|
||||
Xor = 45
|
||||
Complemento = 46
|
||||
YY = 47
|
||||
OO = 48
|
||||
Not = 49
|
||||
Pregunta = 50
|
||||
DosPuntos = 51
|
||||
PuntoYComa = 52
|
||||
Coma = 53
|
||||
Asignar = 54
|
||||
EstrellaAsignacion = 55
|
||||
DivAsignacion = 56
|
||||
ModAsignacion = 57
|
||||
MasAsignacion = 58
|
||||
MenosAsignacion = 59
|
||||
YAsignacion = 60
|
||||
OAsignacion = 61
|
||||
DesplazIzqAsignacion = 62
|
||||
DesplazDerAsignacion = 63
|
||||
XorAsignacion = 64
|
||||
Igual = 65
|
||||
Diferente = 66
|
||||
Flecha = 67
|
||||
Punto = 68
|
||||
Identificador = 69
|
||||
ConstanteEntera = 70
|
||||
ConstanteFlotante = 71
|
||||
ConstanteCaracteres = 72
|
||||
CadenaLiteral = 73
|
||||
Whitespace = 74
|
||||
Newline = 75
|
||||
BlockComment = 76
|
||||
LineComment = 77
|
||||
LineCommentHash = 78
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
modeNames = [ "DEFAULT_MODE" ]
|
||||
|
||||
literalNames = [ "<INVALID>",
|
||||
"'bul'", "'func'", "'fin'", "'caso'", "'carac'", "'pordef'",
|
||||
"'hacer'", "'doble'", "'sino'", "'enum'", "'falso'", "'flot'",
|
||||
"'por'", "'si'", "'Ent'", "'retornar'", "'cf'", "'estruct'",
|
||||
"'interrup'", "'verdadero'", "'sf'", "'vacio'", "'mientras'",
|
||||
"'('", "')'", "'['", "']'", "'{'", "'}'", "'<'", "'<='", "'>'",
|
||||
"'>='", "'+'", "'++'", "'-'", "'--'", "'*'", "'/'", "'%'", "'&'",
|
||||
"'|'", "'<<'", "'>>'", "'^'", "'~'", "'&&'", "'||'", "'!'",
|
||||
"'?'", "':'", "';'", "','", "'='", "'*='", "'/='", "'%='", "'+='",
|
||||
"'-='", "'&='", "'|='", "'<<='", "'>>='", "'^='", "'=='", "'!='",
|
||||
"'->'", "'.'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"Bul", "Func", "Fin", "Caso", "Carac", "Pordef", "Hacer", "Doble",
|
||||
"Sino", "Enum", "Falso", "Flot", "Por", "Si", "Ent", "Retornar",
|
||||
"ConFirma", "Estruct", "Interrup", "Verdadero", "SinFirma",
|
||||
"Vacio", "Mientras", "ParenIzq", "ParenDer", "CorcheteIzq",
|
||||
"CorcheteDer", "LlaveIzq", "LlaveDer", "MenorQue", "MenorOIgualQue",
|
||||
"MayorQue", "MayorOIgualQue", "Mas", "MasMas", "Menos", "MenosMenos",
|
||||
"Estrella", "Div", "Mod", "Y", "O", "DesplazIzq", "DesplazDer",
|
||||
"Xor", "Complemento", "YY", "OO", "Not", "Pregunta", "DosPuntos",
|
||||
"PuntoYComa", "Coma", "Asignar", "EstrellaAsignacion", "DivAsignacion",
|
||||
"ModAsignacion", "MasAsignacion", "MenosAsignacion", "YAsignacion",
|
||||
"OAsignacion", "DesplazIzqAsignacion", "DesplazDerAsignacion",
|
||||
"XorAsignacion", "Igual", "Diferente", "Flecha", "Punto", "Identificador",
|
||||
"ConstanteEntera", "ConstanteFlotante", "ConstanteCaracteres",
|
||||
"CadenaLiteral", "Whitespace", "Newline", "BlockComment", "LineComment",
|
||||
"LineCommentHash" ]
|
||||
|
||||
ruleNames = [ "Bul", "Func", "Fin", "Caso", "Carac", "Pordef", "Hacer",
|
||||
"Doble", "Sino", "Enum", "Falso", "Flot", "Por", "Si",
|
||||
"Ent", "Retornar", "ConFirma", "Estruct", "Interrup",
|
||||
"Verdadero", "SinFirma", "Vacio", "Mientras", "ParenIzq",
|
||||
"ParenDer", "CorcheteIzq", "CorcheteDer", "LlaveIzq",
|
||||
"LlaveDer", "MenorQue", "MenorOIgualQue", "MayorQue",
|
||||
"MayorOIgualQue", "Mas", "MasMas", "Menos", "MenosMenos",
|
||||
"Estrella", "Div", "Mod", "Y", "O", "DesplazIzq", "DesplazDer",
|
||||
"Xor", "Complemento", "YY", "OO", "Not", "Pregunta", "DosPuntos",
|
||||
"PuntoYComa", "Coma", "Asignar", "EstrellaAsignacion",
|
||||
"DivAsignacion", "ModAsignacion", "MasAsignacion", "MenosAsignacion",
|
||||
"YAsignacion", "OAsignacion", "DesplazIzqAsignacion",
|
||||
"DesplazDerAsignacion", "XorAsignacion", "Igual", "Diferente",
|
||||
"Flecha", "Punto", "Identificador", "IdentificadorSindigito",
|
||||
"Nodigito", "Digito", "ConstanteEntera", "ConstanteDecimal",
|
||||
"ConstanteOctal", "HexaConstanteDecimal", "PrefijoHexadecimal",
|
||||
"DigitoNoCero", "DigitoOctal", "DigitoHexadecimal", "SufijoEntero",
|
||||
"ConstanteFlotante", "ConstanteCaracteres", "CCharSequence",
|
||||
"CChar", "SecuenciaEscape", "SecuenciaEscapeSimple", "SecuenciaEscapeOctal",
|
||||
"SecuenciaEscapeHexadecimal", "CadenaLiteral", "SSecuenciaCaracteres",
|
||||
"SCaracter", "Whitespace", "Newline", "BlockComment",
|
||||
"LineComment", "LineCommentHash" ]
|
||||
|
||||
grammarFileName = "zaplangLexer.g4"
|
||||
|
||||
def __init__(self, input=None, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
self.checkVersion("4.13.2")
|
||||
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
|
||||
self._actions = None
|
||||
self._predicates = None
|
||||
|
||||
|
||||
146
zaplangLexer.tokens
Normal file
146
zaplangLexer.tokens
Normal file
@@ -0,0 +1,146 @@
|
||||
Bul=1
|
||||
Func=2
|
||||
Fin=3
|
||||
Caso=4
|
||||
Carac=5
|
||||
Pordef=6
|
||||
Hacer=7
|
||||
Doble=8
|
||||
Sino=9
|
||||
Enum=10
|
||||
Falso=11
|
||||
Flot=12
|
||||
Por=13
|
||||
Si=14
|
||||
Ent=15
|
||||
Retornar=16
|
||||
ConFirma=17
|
||||
Estruct=18
|
||||
Interrup=19
|
||||
Verdadero=20
|
||||
SinFirma=21
|
||||
Vacio=22
|
||||
Mientras=23
|
||||
ParenIzq=24
|
||||
ParenDer=25
|
||||
CorcheteIzq=26
|
||||
CorcheteDer=27
|
||||
LlaveIzq=28
|
||||
LlaveDer=29
|
||||
MenorQue=30
|
||||
MenorOIgualQue=31
|
||||
MayorQue=32
|
||||
MayorOIgualQue=33
|
||||
Mas=34
|
||||
MasMas=35
|
||||
Menos=36
|
||||
MenosMenos=37
|
||||
Estrella=38
|
||||
Div=39
|
||||
Mod=40
|
||||
Y=41
|
||||
O=42
|
||||
DesplazIzq=43
|
||||
DesplazDer=44
|
||||
Xor=45
|
||||
Complemento=46
|
||||
YY=47
|
||||
OO=48
|
||||
Not=49
|
||||
Pregunta=50
|
||||
DosPuntos=51
|
||||
PuntoYComa=52
|
||||
Coma=53
|
||||
Asignar=54
|
||||
EstrellaAsignacion=55
|
||||
DivAsignacion=56
|
||||
ModAsignacion=57
|
||||
MasAsignacion=58
|
||||
MenosAsignacion=59
|
||||
YAsignacion=60
|
||||
OAsignacion=61
|
||||
DesplazIzqAsignacion=62
|
||||
DesplazDerAsignacion=63
|
||||
XorAsignacion=64
|
||||
Igual=65
|
||||
Diferente=66
|
||||
Flecha=67
|
||||
Punto=68
|
||||
Identificador=69
|
||||
ConstanteEntera=70
|
||||
ConstanteFlotante=71
|
||||
ConstanteCaracteres=72
|
||||
CadenaLiteral=73
|
||||
Whitespace=74
|
||||
Newline=75
|
||||
BlockComment=76
|
||||
LineComment=77
|
||||
LineCommentHash=78
|
||||
'bul'=1
|
||||
'func'=2
|
||||
'fin'=3
|
||||
'caso'=4
|
||||
'carac'=5
|
||||
'pordef'=6
|
||||
'hacer'=7
|
||||
'doble'=8
|
||||
'sino'=9
|
||||
'enum'=10
|
||||
'falso'=11
|
||||
'flot'=12
|
||||
'por'=13
|
||||
'si'=14
|
||||
'Ent'=15
|
||||
'retornar'=16
|
||||
'cf'=17
|
||||
'estruct'=18
|
||||
'interrup'=19
|
||||
'verdadero'=20
|
||||
'sf'=21
|
||||
'vacio'=22
|
||||
'mientras'=23
|
||||
'('=24
|
||||
')'=25
|
||||
'['=26
|
||||
']'=27
|
||||
'{'=28
|
||||
'}'=29
|
||||
'<'=30
|
||||
'<='=31
|
||||
'>'=32
|
||||
'>='=33
|
||||
'+'=34
|
||||
'++'=35
|
||||
'-'=36
|
||||
'--'=37
|
||||
'*'=38
|
||||
'/'=39
|
||||
'%'=40
|
||||
'&'=41
|
||||
'|'=42
|
||||
'<<'=43
|
||||
'>>'=44
|
||||
'^'=45
|
||||
'~'=46
|
||||
'&&'=47
|
||||
'||'=48
|
||||
'!'=49
|
||||
'?'=50
|
||||
':'=51
|
||||
';'=52
|
||||
','=53
|
||||
'='=54
|
||||
'*='=55
|
||||
'/='=56
|
||||
'%='=57
|
||||
'+='=58
|
||||
'-='=59
|
||||
'&='=60
|
||||
'|='=61
|
||||
'<<='=62
|
||||
'>>='=63
|
||||
'^='=64
|
||||
'=='=65
|
||||
'!='=66
|
||||
'->'=67
|
||||
'.'=68
|
||||
308
zaplangParser.g4
Normal file
308
zaplangParser.g4
Normal file
@@ -0,0 +1,308 @@
|
||||
parser grammar zaplangParser;
|
||||
|
||||
options {
|
||||
tokenVocab = zaplangLexer;
|
||||
language = Python3;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PUNTO DE ENTRADA DEL PROGRAMA
|
||||
// ============================================================================
|
||||
|
||||
unidadTraduccion
|
||||
: declaracionExterna*
|
||||
;
|
||||
|
||||
declaracionExterna
|
||||
: declaracionFuncion
|
||||
| declaracionVariable
|
||||
| declaracionEstruct
|
||||
| declaracionEnum
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// DECLARACIONES DE FUNCIONES
|
||||
// ============================================================================
|
||||
|
||||
declaracionFuncion
|
||||
: tipoRetorno identificadorFuncion
|
||||
ParenIzq listaParametros? ParenDer
|
||||
bloque
|
||||
;
|
||||
|
||||
tipoRetorno
|
||||
: especificadorTipo
|
||||
| Vacio
|
||||
;
|
||||
|
||||
identificadorFuncion
|
||||
: Identificador
|
||||
;
|
||||
|
||||
listaParametros
|
||||
: declaracionParametro (Coma declaracionParametro)*
|
||||
;
|
||||
|
||||
declaracionParametro
|
||||
: especificadorTipo Identificador
|
||||
| especificadorTipo Identificador CorcheteIzq ConstanteEntera CorcheteDer
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// ESPECIFICADORES DE TIPO
|
||||
// ============================================================================
|
||||
|
||||
especificadorTipo
|
||||
: tipoBasico (CorcheteIzq ConstanteEntera? CorcheteDer)*
|
||||
| tipoEstructurado (CorcheteIzq ConstanteEntera? CorcheteDer)*
|
||||
;
|
||||
|
||||
tipoBasico
|
||||
: Ent
|
||||
| Doble
|
||||
| Flot
|
||||
| Carac
|
||||
| ConFirma
|
||||
| SinFirma
|
||||
| puntero
|
||||
;
|
||||
|
||||
puntero
|
||||
: Estrella
|
||||
| Estrella Estrella
|
||||
| Estrella Estrella Estrella
|
||||
;
|
||||
|
||||
tipoEstructurado
|
||||
: Estruct Identificador
|
||||
| Enum Identificador
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// DECLARACIONES DE ESTRUCTURAS
|
||||
// ============================================================================
|
||||
|
||||
declaracionEstruct
|
||||
: Estruct Identificador LlaveIzq miembroEstruct* LlaveDer PuntoYComa
|
||||
;
|
||||
|
||||
miembroEstruct
|
||||
: especificadorTipo Identificador PuntoYComa
|
||||
| especificadorTipo Identificador CorcheteIzq ConstanteEntera CorcheteDer PuntoYComa
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// DECLARACIONES DE ENUMERACIONES
|
||||
// ============================================================================
|
||||
|
||||
declaracionEnum
|
||||
: Enum Identificador LlaveIzq listaEnumeradores LlaveDer PuntoYComa
|
||||
;
|
||||
|
||||
listaEnumeradores
|
||||
: enumerador (Coma enumerador)*
|
||||
;
|
||||
|
||||
enumerador
|
||||
: Identificador
|
||||
| Identificador Asignar ConstanteEntera
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// DECLARACIONES DE VARIABLES Y ASIGNACIONES
|
||||
// ============================================================================
|
||||
|
||||
declaracionVariable
|
||||
: especificadorTipo inicializadorVariable (Coma inicializadorVariable)* PuntoYComa
|
||||
;
|
||||
|
||||
inicializadorVariable
|
||||
: Identificador
|
||||
| Identificador Asignar inicializador
|
||||
| Identificador CorcheteIzq ConstanteEntera CorcheteDer
|
||||
| Identificador CorcheteIzq ConstanteEntera CorcheteDer Asignar inicializadorArreglo
|
||||
;
|
||||
|
||||
inicializador
|
||||
: asignacionExpresion
|
||||
;
|
||||
|
||||
inicializadorArreglo
|
||||
: LlaveIzq listaInitializers? LlaveDer
|
||||
;
|
||||
|
||||
listaInitializers
|
||||
: asignacionExpresion (Coma asignacionExpresion)*
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// SENTENCIAS
|
||||
// ============================================================================
|
||||
|
||||
sentencia
|
||||
: sentenciaCompuesta
|
||||
| sentenciaDeclaracion
|
||||
| sentenciaExpresion
|
||||
| sentenciaSeleccion
|
||||
| sentenciaIteracion
|
||||
| sentenciaSalto
|
||||
;
|
||||
|
||||
sentenciaCompuesta
|
||||
: LlaveIzq sentencia* LlaveDer
|
||||
;
|
||||
|
||||
sentenciaDeclaracion
|
||||
: declaracionVariable
|
||||
;
|
||||
|
||||
sentenciaExpresion
|
||||
: expresion PuntoYComa
|
||||
| PuntoYComa
|
||||
;
|
||||
|
||||
sentenciaSeleccion
|
||||
: Si ParenIzq expresion ParenDer sentencia
|
||||
| Si ParenIzq expresion ParenDer sentencia Sino sentencia
|
||||
| Caso Bul LlaveIzq casoEtiqueta* etiquetaPorDef? LlaveDer
|
||||
;
|
||||
|
||||
casoEtiqueta
|
||||
: Caso constanteExpresion DosPuntos sentencia*
|
||||
;
|
||||
|
||||
etiquetaPorDef
|
||||
: Pordef DosPuntos sentencia*
|
||||
;
|
||||
|
||||
sentenciaIteracion
|
||||
: Mientras ParenIzq expresion ParenDer sentencia
|
||||
| Por ParenIzq sentenciaExpresion? PuntoYComa expresion? PuntoYComa expresion? ParenDer sentencia
|
||||
;
|
||||
|
||||
sentenciaSalto
|
||||
: Retornar expresion? PuntoYComa
|
||||
| Fin PuntoYComa
|
||||
| Interrup PuntoYComa
|
||||
;
|
||||
|
||||
bloque
|
||||
: LlaveIzq declaracionVariable* sentencia* LlaveDer
|
||||
| sentencia
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// EXPRESIONES
|
||||
// ============================================================================
|
||||
|
||||
expresion
|
||||
: asignacionExpresion
|
||||
| expresion Coma asignacionExpresion
|
||||
;
|
||||
|
||||
asignacionExpresion
|
||||
: expresionCondicional
|
||||
| expresionUnaria operadorAsignacion asignacionExpresion
|
||||
;
|
||||
|
||||
operadorAsignacion
|
||||
: Asignar
|
||||
| MasAsignacion
|
||||
| MenosAsignacion
|
||||
| EstrellaAsignacion
|
||||
| DivAsignacion
|
||||
| ModAsignacion
|
||||
| DesplazIzqAsignacion
|
||||
| DesplazDerAsignacion
|
||||
| YAsignacion
|
||||
| XorAsignacion
|
||||
| OAsignacion
|
||||
;
|
||||
|
||||
expresionCondicional
|
||||
: expresionLogicaO
|
||||
| expresionLogicaO Pregunta expresion DosPuntos expresionCondicional
|
||||
;
|
||||
|
||||
expresionLogicaO
|
||||
: expresionLogicaY (OO expresionLogicaY)*
|
||||
;
|
||||
|
||||
expresionLogicaY
|
||||
: expresionIgualacion (YY expresionIgualacion)*
|
||||
;
|
||||
|
||||
expresionIgualacion
|
||||
: expresionRelacional ((Igual | Diferente) expresionRelacional)*
|
||||
;
|
||||
|
||||
expresionRelacional
|
||||
: expresionDesplazamiento ((MenorQue | MayorQue | MenorOIgualQue | MayorOIgualQue) expresionDesplazamiento)*
|
||||
;
|
||||
|
||||
expresionDesplazamiento
|
||||
: expresionAditiva ((DesplazIzq | DesplazDer) expresionAditiva)*
|
||||
;
|
||||
|
||||
expresionAditiva
|
||||
: expresionMultiplicativa ((Mas | Menos) expresionMultiplicativa)*
|
||||
;
|
||||
|
||||
expresionMultiplicativa
|
||||
: expresionUnaria ((Estrella | Div | Mod) expresionUnaria)*
|
||||
;
|
||||
|
||||
expresionUnaria
|
||||
: operadorUnario expresionUnaria
|
||||
| expresionPostfija
|
||||
;
|
||||
|
||||
operadorUnario
|
||||
: Y
|
||||
| Estrella
|
||||
| Mas
|
||||
| Menos
|
||||
| Complemento
|
||||
| Not
|
||||
| MasMas
|
||||
| MenosMenos
|
||||
;
|
||||
|
||||
expresionPostfija
|
||||
: expresionPrimaria
|
||||
| expresionPostfija CorcheteIzq expresion CorcheteDer
|
||||
| expresionPostfija ParenIzq listaArgumentos? ParenDer
|
||||
| expresionPostfija Punto Identificador
|
||||
| expresionPostfija Flecha Identificador
|
||||
| expresionPostfija MasMas
|
||||
| expresionPostfija MenosMenos
|
||||
;
|
||||
|
||||
expresionPrimaria
|
||||
: Identificador
|
||||
| constanteExpresion
|
||||
| CadenaLiteral
|
||||
| ParenIzq expresion ParenDer
|
||||
| ParenIzq especificadorTipo ParenDer expresionUnaria
|
||||
;
|
||||
|
||||
constanteExpresion
|
||||
: ConstanteEntera
|
||||
| ConstanteFlotante
|
||||
| ConstanteCaracteres
|
||||
| Verdadero
|
||||
| Falso
|
||||
;
|
||||
|
||||
listaArgumentos
|
||||
: asignacionExpresion (Coma asignacionExpresion)*
|
||||
;
|
||||
|
||||
// ============================================================================
|
||||
// REGLAS AUXILIARES
|
||||
// ============================================================================
|
||||
|
||||
// Palabra clave utilizada para marcar puntos de entrada opcionales
|
||||
marcaPunto
|
||||
: Bul
|
||||
;
|
||||
216
zaplangParser.interp
Normal file
216
zaplangParser.interp
Normal file
File diff suppressed because one or more lines are too long
4523
zaplangParser.py
Normal file
4523
zaplangParser.py
Normal file
File diff suppressed because it is too large
Load Diff
146
zaplangParser.tokens
Normal file
146
zaplangParser.tokens
Normal file
@@ -0,0 +1,146 @@
|
||||
Bul=1
|
||||
Func=2
|
||||
Fin=3
|
||||
Caso=4
|
||||
Carac=5
|
||||
Pordef=6
|
||||
Hacer=7
|
||||
Doble=8
|
||||
Sino=9
|
||||
Enum=10
|
||||
Falso=11
|
||||
Flot=12
|
||||
Por=13
|
||||
Si=14
|
||||
Ent=15
|
||||
Retornar=16
|
||||
ConFirma=17
|
||||
Estruct=18
|
||||
Interrup=19
|
||||
Verdadero=20
|
||||
SinFirma=21
|
||||
Vacio=22
|
||||
Mientras=23
|
||||
ParenIzq=24
|
||||
ParenDer=25
|
||||
CorcheteIzq=26
|
||||
CorcheteDer=27
|
||||
LlaveIzq=28
|
||||
LlaveDer=29
|
||||
MenorQue=30
|
||||
MenorOIgualQue=31
|
||||
MayorQue=32
|
||||
MayorOIgualQue=33
|
||||
Mas=34
|
||||
MasMas=35
|
||||
Menos=36
|
||||
MenosMenos=37
|
||||
Estrella=38
|
||||
Div=39
|
||||
Mod=40
|
||||
Y=41
|
||||
O=42
|
||||
DesplazIzq=43
|
||||
DesplazDer=44
|
||||
Xor=45
|
||||
Complemento=46
|
||||
YY=47
|
||||
OO=48
|
||||
Not=49
|
||||
Pregunta=50
|
||||
DosPuntos=51
|
||||
PuntoYComa=52
|
||||
Coma=53
|
||||
Asignar=54
|
||||
EstrellaAsignacion=55
|
||||
DivAsignacion=56
|
||||
ModAsignacion=57
|
||||
MasAsignacion=58
|
||||
MenosAsignacion=59
|
||||
YAsignacion=60
|
||||
OAsignacion=61
|
||||
DesplazIzqAsignacion=62
|
||||
DesplazDerAsignacion=63
|
||||
XorAsignacion=64
|
||||
Igual=65
|
||||
Diferente=66
|
||||
Flecha=67
|
||||
Punto=68
|
||||
Identificador=69
|
||||
ConstanteEntera=70
|
||||
ConstanteFlotante=71
|
||||
ConstanteCaracteres=72
|
||||
CadenaLiteral=73
|
||||
Whitespace=74
|
||||
Newline=75
|
||||
BlockComment=76
|
||||
LineComment=77
|
||||
LineCommentHash=78
|
||||
'bul'=1
|
||||
'func'=2
|
||||
'fin'=3
|
||||
'caso'=4
|
||||
'carac'=5
|
||||
'pordef'=6
|
||||
'hacer'=7
|
||||
'doble'=8
|
||||
'sino'=9
|
||||
'enum'=10
|
||||
'falso'=11
|
||||
'flot'=12
|
||||
'por'=13
|
||||
'si'=14
|
||||
'Ent'=15
|
||||
'retornar'=16
|
||||
'cf'=17
|
||||
'estruct'=18
|
||||
'interrup'=19
|
||||
'verdadero'=20
|
||||
'sf'=21
|
||||
'vacio'=22
|
||||
'mientras'=23
|
||||
'('=24
|
||||
')'=25
|
||||
'['=26
|
||||
']'=27
|
||||
'{'=28
|
||||
'}'=29
|
||||
'<'=30
|
||||
'<='=31
|
||||
'>'=32
|
||||
'>='=33
|
||||
'+'=34
|
||||
'++'=35
|
||||
'-'=36
|
||||
'--'=37
|
||||
'*'=38
|
||||
'/'=39
|
||||
'%'=40
|
||||
'&'=41
|
||||
'|'=42
|
||||
'<<'=43
|
||||
'>>'=44
|
||||
'^'=45
|
||||
'~'=46
|
||||
'&&'=47
|
||||
'||'=48
|
||||
'!'=49
|
||||
'?'=50
|
||||
':'=51
|
||||
';'=52
|
||||
','=53
|
||||
'='=54
|
||||
'*='=55
|
||||
'/='=56
|
||||
'%='=57
|
||||
'+='=58
|
||||
'-='=59
|
||||
'&='=60
|
||||
'|='=61
|
||||
'<<='=62
|
||||
'>>='=63
|
||||
'^='=64
|
||||
'=='=65
|
||||
'!='=66
|
||||
'->'=67
|
||||
'.'=68
|
||||
453
zaplangParserListener.py
Normal file
453
zaplangParserListener.py
Normal file
@@ -0,0 +1,453 @@
|
||||
# Generated from zaplangParser.g4 by ANTLR 4.13.2
|
||||
from antlr4 import *
|
||||
if "." in __name__:
|
||||
from .zaplangParser import zaplangParser
|
||||
else:
|
||||
from zaplangParser import zaplangParser
|
||||
|
||||
# This class defines a complete listener for a parse tree produced by zaplangParser.
|
||||
class zaplangParserListener(ParseTreeListener):
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#unidadTraduccion.
|
||||
def enterUnidadTraduccion(self, ctx:zaplangParser.UnidadTraduccionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#unidadTraduccion.
|
||||
def exitUnidadTraduccion(self, ctx:zaplangParser.UnidadTraduccionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionExterna.
|
||||
def enterDeclaracionExterna(self, ctx:zaplangParser.DeclaracionExternaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionExterna.
|
||||
def exitDeclaracionExterna(self, ctx:zaplangParser.DeclaracionExternaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionFuncion.
|
||||
def enterDeclaracionFuncion(self, ctx:zaplangParser.DeclaracionFuncionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionFuncion.
|
||||
def exitDeclaracionFuncion(self, ctx:zaplangParser.DeclaracionFuncionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#tipoRetorno.
|
||||
def enterTipoRetorno(self, ctx:zaplangParser.TipoRetornoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#tipoRetorno.
|
||||
def exitTipoRetorno(self, ctx:zaplangParser.TipoRetornoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#identificadorFuncion.
|
||||
def enterIdentificadorFuncion(self, ctx:zaplangParser.IdentificadorFuncionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#identificadorFuncion.
|
||||
def exitIdentificadorFuncion(self, ctx:zaplangParser.IdentificadorFuncionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#listaParametros.
|
||||
def enterListaParametros(self, ctx:zaplangParser.ListaParametrosContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#listaParametros.
|
||||
def exitListaParametros(self, ctx:zaplangParser.ListaParametrosContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionParametro.
|
||||
def enterDeclaracionParametro(self, ctx:zaplangParser.DeclaracionParametroContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionParametro.
|
||||
def exitDeclaracionParametro(self, ctx:zaplangParser.DeclaracionParametroContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#especificadorTipo.
|
||||
def enterEspecificadorTipo(self, ctx:zaplangParser.EspecificadorTipoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#especificadorTipo.
|
||||
def exitEspecificadorTipo(self, ctx:zaplangParser.EspecificadorTipoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#tipoBasico.
|
||||
def enterTipoBasico(self, ctx:zaplangParser.TipoBasicoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#tipoBasico.
|
||||
def exitTipoBasico(self, ctx:zaplangParser.TipoBasicoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#puntero.
|
||||
def enterPuntero(self, ctx:zaplangParser.PunteroContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#puntero.
|
||||
def exitPuntero(self, ctx:zaplangParser.PunteroContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#tipoEstructurado.
|
||||
def enterTipoEstructurado(self, ctx:zaplangParser.TipoEstructuradoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#tipoEstructurado.
|
||||
def exitTipoEstructurado(self, ctx:zaplangParser.TipoEstructuradoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionEstruct.
|
||||
def enterDeclaracionEstruct(self, ctx:zaplangParser.DeclaracionEstructContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionEstruct.
|
||||
def exitDeclaracionEstruct(self, ctx:zaplangParser.DeclaracionEstructContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#miembroEstruct.
|
||||
def enterMiembroEstruct(self, ctx:zaplangParser.MiembroEstructContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#miembroEstruct.
|
||||
def exitMiembroEstruct(self, ctx:zaplangParser.MiembroEstructContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionEnum.
|
||||
def enterDeclaracionEnum(self, ctx:zaplangParser.DeclaracionEnumContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionEnum.
|
||||
def exitDeclaracionEnum(self, ctx:zaplangParser.DeclaracionEnumContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#listaEnumeradores.
|
||||
def enterListaEnumeradores(self, ctx:zaplangParser.ListaEnumeradoresContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#listaEnumeradores.
|
||||
def exitListaEnumeradores(self, ctx:zaplangParser.ListaEnumeradoresContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#enumerador.
|
||||
def enterEnumerador(self, ctx:zaplangParser.EnumeradorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#enumerador.
|
||||
def exitEnumerador(self, ctx:zaplangParser.EnumeradorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#declaracionVariable.
|
||||
def enterDeclaracionVariable(self, ctx:zaplangParser.DeclaracionVariableContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#declaracionVariable.
|
||||
def exitDeclaracionVariable(self, ctx:zaplangParser.DeclaracionVariableContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#inicializadorVariable.
|
||||
def enterInicializadorVariable(self, ctx:zaplangParser.InicializadorVariableContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#inicializadorVariable.
|
||||
def exitInicializadorVariable(self, ctx:zaplangParser.InicializadorVariableContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#inicializador.
|
||||
def enterInicializador(self, ctx:zaplangParser.InicializadorContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#inicializador.
|
||||
def exitInicializador(self, ctx:zaplangParser.InicializadorContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#inicializadorArreglo.
|
||||
def enterInicializadorArreglo(self, ctx:zaplangParser.InicializadorArregloContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#inicializadorArreglo.
|
||||
def exitInicializadorArreglo(self, ctx:zaplangParser.InicializadorArregloContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#listaInitializers.
|
||||
def enterListaInitializers(self, ctx:zaplangParser.ListaInitializersContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#listaInitializers.
|
||||
def exitListaInitializers(self, ctx:zaplangParser.ListaInitializersContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentencia.
|
||||
def enterSentencia(self, ctx:zaplangParser.SentenciaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentencia.
|
||||
def exitSentencia(self, ctx:zaplangParser.SentenciaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaCompuesta.
|
||||
def enterSentenciaCompuesta(self, ctx:zaplangParser.SentenciaCompuestaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaCompuesta.
|
||||
def exitSentenciaCompuesta(self, ctx:zaplangParser.SentenciaCompuestaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaDeclaracion.
|
||||
def enterSentenciaDeclaracion(self, ctx:zaplangParser.SentenciaDeclaracionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaDeclaracion.
|
||||
def exitSentenciaDeclaracion(self, ctx:zaplangParser.SentenciaDeclaracionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaExpresion.
|
||||
def enterSentenciaExpresion(self, ctx:zaplangParser.SentenciaExpresionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaExpresion.
|
||||
def exitSentenciaExpresion(self, ctx:zaplangParser.SentenciaExpresionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaSeleccion.
|
||||
def enterSentenciaSeleccion(self, ctx:zaplangParser.SentenciaSeleccionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaSeleccion.
|
||||
def exitSentenciaSeleccion(self, ctx:zaplangParser.SentenciaSeleccionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#casoEtiqueta.
|
||||
def enterCasoEtiqueta(self, ctx:zaplangParser.CasoEtiquetaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#casoEtiqueta.
|
||||
def exitCasoEtiqueta(self, ctx:zaplangParser.CasoEtiquetaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#etiquetaPorDef.
|
||||
def enterEtiquetaPorDef(self, ctx:zaplangParser.EtiquetaPorDefContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#etiquetaPorDef.
|
||||
def exitEtiquetaPorDef(self, ctx:zaplangParser.EtiquetaPorDefContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaIteracion.
|
||||
def enterSentenciaIteracion(self, ctx:zaplangParser.SentenciaIteracionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaIteracion.
|
||||
def exitSentenciaIteracion(self, ctx:zaplangParser.SentenciaIteracionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#sentenciaSalto.
|
||||
def enterSentenciaSalto(self, ctx:zaplangParser.SentenciaSaltoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#sentenciaSalto.
|
||||
def exitSentenciaSalto(self, ctx:zaplangParser.SentenciaSaltoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#bloque.
|
||||
def enterBloque(self, ctx:zaplangParser.BloqueContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#bloque.
|
||||
def exitBloque(self, ctx:zaplangParser.BloqueContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresion.
|
||||
def enterExpresion(self, ctx:zaplangParser.ExpresionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresion.
|
||||
def exitExpresion(self, ctx:zaplangParser.ExpresionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#asignacionExpresion.
|
||||
def enterAsignacionExpresion(self, ctx:zaplangParser.AsignacionExpresionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#asignacionExpresion.
|
||||
def exitAsignacionExpresion(self, ctx:zaplangParser.AsignacionExpresionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#operadorAsignacion.
|
||||
def enterOperadorAsignacion(self, ctx:zaplangParser.OperadorAsignacionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#operadorAsignacion.
|
||||
def exitOperadorAsignacion(self, ctx:zaplangParser.OperadorAsignacionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionCondicional.
|
||||
def enterExpresionCondicional(self, ctx:zaplangParser.ExpresionCondicionalContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionCondicional.
|
||||
def exitExpresionCondicional(self, ctx:zaplangParser.ExpresionCondicionalContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionLogicaO.
|
||||
def enterExpresionLogicaO(self, ctx:zaplangParser.ExpresionLogicaOContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionLogicaO.
|
||||
def exitExpresionLogicaO(self, ctx:zaplangParser.ExpresionLogicaOContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionLogicaY.
|
||||
def enterExpresionLogicaY(self, ctx:zaplangParser.ExpresionLogicaYContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionLogicaY.
|
||||
def exitExpresionLogicaY(self, ctx:zaplangParser.ExpresionLogicaYContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionIgualacion.
|
||||
def enterExpresionIgualacion(self, ctx:zaplangParser.ExpresionIgualacionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionIgualacion.
|
||||
def exitExpresionIgualacion(self, ctx:zaplangParser.ExpresionIgualacionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionRelacional.
|
||||
def enterExpresionRelacional(self, ctx:zaplangParser.ExpresionRelacionalContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionRelacional.
|
||||
def exitExpresionRelacional(self, ctx:zaplangParser.ExpresionRelacionalContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionDesplazamiento.
|
||||
def enterExpresionDesplazamiento(self, ctx:zaplangParser.ExpresionDesplazamientoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionDesplazamiento.
|
||||
def exitExpresionDesplazamiento(self, ctx:zaplangParser.ExpresionDesplazamientoContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionAditiva.
|
||||
def enterExpresionAditiva(self, ctx:zaplangParser.ExpresionAditivaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionAditiva.
|
||||
def exitExpresionAditiva(self, ctx:zaplangParser.ExpresionAditivaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionMultiplicativa.
|
||||
def enterExpresionMultiplicativa(self, ctx:zaplangParser.ExpresionMultiplicativaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionMultiplicativa.
|
||||
def exitExpresionMultiplicativa(self, ctx:zaplangParser.ExpresionMultiplicativaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionUnaria.
|
||||
def enterExpresionUnaria(self, ctx:zaplangParser.ExpresionUnariaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionUnaria.
|
||||
def exitExpresionUnaria(self, ctx:zaplangParser.ExpresionUnariaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#operadorUnario.
|
||||
def enterOperadorUnario(self, ctx:zaplangParser.OperadorUnarioContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#operadorUnario.
|
||||
def exitOperadorUnario(self, ctx:zaplangParser.OperadorUnarioContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionPostfija.
|
||||
def enterExpresionPostfija(self, ctx:zaplangParser.ExpresionPostfijaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionPostfija.
|
||||
def exitExpresionPostfija(self, ctx:zaplangParser.ExpresionPostfijaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#expresionPrimaria.
|
||||
def enterExpresionPrimaria(self, ctx:zaplangParser.ExpresionPrimariaContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#expresionPrimaria.
|
||||
def exitExpresionPrimaria(self, ctx:zaplangParser.ExpresionPrimariaContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#constanteExpresion.
|
||||
def enterConstanteExpresion(self, ctx:zaplangParser.ConstanteExpresionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#constanteExpresion.
|
||||
def exitConstanteExpresion(self, ctx:zaplangParser.ConstanteExpresionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#listaArgumentos.
|
||||
def enterListaArgumentos(self, ctx:zaplangParser.ListaArgumentosContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#listaArgumentos.
|
||||
def exitListaArgumentos(self, ctx:zaplangParser.ListaArgumentosContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by zaplangParser#marcaPunto.
|
||||
def enterMarcaPunto(self, ctx:zaplangParser.MarcaPuntoContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by zaplangParser#marcaPunto.
|
||||
def exitMarcaPunto(self, ctx:zaplangParser.MarcaPuntoContext):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
del zaplangParser
|
||||
258
zaplangParserVisitor.py
Normal file
258
zaplangParserVisitor.py
Normal file
@@ -0,0 +1,258 @@
|
||||
# Generated from zaplangParser.g4 by ANTLR 4.13.2
|
||||
from antlr4 import *
|
||||
if "." in __name__:
|
||||
from .zaplangParser import zaplangParser
|
||||
else:
|
||||
from zaplangParser import zaplangParser
|
||||
|
||||
# This class defines a complete generic visitor for a parse tree produced by zaplangParser.
|
||||
|
||||
class zaplangParserVisitor(ParseTreeVisitor):
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#unidadTraduccion.
|
||||
def visitUnidadTraduccion(self, ctx:zaplangParser.UnidadTraduccionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionExterna.
|
||||
def visitDeclaracionExterna(self, ctx:zaplangParser.DeclaracionExternaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionFuncion.
|
||||
def visitDeclaracionFuncion(self, ctx:zaplangParser.DeclaracionFuncionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#tipoRetorno.
|
||||
def visitTipoRetorno(self, ctx:zaplangParser.TipoRetornoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#identificadorFuncion.
|
||||
def visitIdentificadorFuncion(self, ctx:zaplangParser.IdentificadorFuncionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#listaParametros.
|
||||
def visitListaParametros(self, ctx:zaplangParser.ListaParametrosContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionParametro.
|
||||
def visitDeclaracionParametro(self, ctx:zaplangParser.DeclaracionParametroContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#especificadorTipo.
|
||||
def visitEspecificadorTipo(self, ctx:zaplangParser.EspecificadorTipoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#tipoBasico.
|
||||
def visitTipoBasico(self, ctx:zaplangParser.TipoBasicoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#puntero.
|
||||
def visitPuntero(self, ctx:zaplangParser.PunteroContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#tipoEstructurado.
|
||||
def visitTipoEstructurado(self, ctx:zaplangParser.TipoEstructuradoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionEstruct.
|
||||
def visitDeclaracionEstruct(self, ctx:zaplangParser.DeclaracionEstructContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#miembroEstruct.
|
||||
def visitMiembroEstruct(self, ctx:zaplangParser.MiembroEstructContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionEnum.
|
||||
def visitDeclaracionEnum(self, ctx:zaplangParser.DeclaracionEnumContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#listaEnumeradores.
|
||||
def visitListaEnumeradores(self, ctx:zaplangParser.ListaEnumeradoresContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#enumerador.
|
||||
def visitEnumerador(self, ctx:zaplangParser.EnumeradorContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#declaracionVariable.
|
||||
def visitDeclaracionVariable(self, ctx:zaplangParser.DeclaracionVariableContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#inicializadorVariable.
|
||||
def visitInicializadorVariable(self, ctx:zaplangParser.InicializadorVariableContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#inicializador.
|
||||
def visitInicializador(self, ctx:zaplangParser.InicializadorContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#inicializadorArreglo.
|
||||
def visitInicializadorArreglo(self, ctx:zaplangParser.InicializadorArregloContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#listaInitializers.
|
||||
def visitListaInitializers(self, ctx:zaplangParser.ListaInitializersContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentencia.
|
||||
def visitSentencia(self, ctx:zaplangParser.SentenciaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaCompuesta.
|
||||
def visitSentenciaCompuesta(self, ctx:zaplangParser.SentenciaCompuestaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaDeclaracion.
|
||||
def visitSentenciaDeclaracion(self, ctx:zaplangParser.SentenciaDeclaracionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaExpresion.
|
||||
def visitSentenciaExpresion(self, ctx:zaplangParser.SentenciaExpresionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaSeleccion.
|
||||
def visitSentenciaSeleccion(self, ctx:zaplangParser.SentenciaSeleccionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#casoEtiqueta.
|
||||
def visitCasoEtiqueta(self, ctx:zaplangParser.CasoEtiquetaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#etiquetaPorDef.
|
||||
def visitEtiquetaPorDef(self, ctx:zaplangParser.EtiquetaPorDefContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaIteracion.
|
||||
def visitSentenciaIteracion(self, ctx:zaplangParser.SentenciaIteracionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#sentenciaSalto.
|
||||
def visitSentenciaSalto(self, ctx:zaplangParser.SentenciaSaltoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#bloque.
|
||||
def visitBloque(self, ctx:zaplangParser.BloqueContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresion.
|
||||
def visitExpresion(self, ctx:zaplangParser.ExpresionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#asignacionExpresion.
|
||||
def visitAsignacionExpresion(self, ctx:zaplangParser.AsignacionExpresionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#operadorAsignacion.
|
||||
def visitOperadorAsignacion(self, ctx:zaplangParser.OperadorAsignacionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionCondicional.
|
||||
def visitExpresionCondicional(self, ctx:zaplangParser.ExpresionCondicionalContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionLogicaO.
|
||||
def visitExpresionLogicaO(self, ctx:zaplangParser.ExpresionLogicaOContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionLogicaY.
|
||||
def visitExpresionLogicaY(self, ctx:zaplangParser.ExpresionLogicaYContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionIgualacion.
|
||||
def visitExpresionIgualacion(self, ctx:zaplangParser.ExpresionIgualacionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionRelacional.
|
||||
def visitExpresionRelacional(self, ctx:zaplangParser.ExpresionRelacionalContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionDesplazamiento.
|
||||
def visitExpresionDesplazamiento(self, ctx:zaplangParser.ExpresionDesplazamientoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionAditiva.
|
||||
def visitExpresionAditiva(self, ctx:zaplangParser.ExpresionAditivaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionMultiplicativa.
|
||||
def visitExpresionMultiplicativa(self, ctx:zaplangParser.ExpresionMultiplicativaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionUnaria.
|
||||
def visitExpresionUnaria(self, ctx:zaplangParser.ExpresionUnariaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#operadorUnario.
|
||||
def visitOperadorUnario(self, ctx:zaplangParser.OperadorUnarioContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionPostfija.
|
||||
def visitExpresionPostfija(self, ctx:zaplangParser.ExpresionPostfijaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#expresionPrimaria.
|
||||
def visitExpresionPrimaria(self, ctx:zaplangParser.ExpresionPrimariaContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#constanteExpresion.
|
||||
def visitConstanteExpresion(self, ctx:zaplangParser.ConstanteExpresionContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#listaArgumentos.
|
||||
def visitListaArgumentos(self, ctx:zaplangParser.ListaArgumentosContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by zaplangParser#marcaPunto.
|
||||
def visitMarcaPunto(self, ctx:zaplangParser.MarcaPuntoContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
|
||||
del zaplangParser
|
||||
Reference in New Issue
Block a user