Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: roskoff/gSL
base: b4ac913802
...
head fork: roskoff/gSL
compare: 063c6c22f7
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 40 additions and 8 deletions.
  1. +1 −1  gSLLexer.py
  2. +39 −7 gSLParser.py
2  gSLLexer.py
View
@@ -106,7 +106,7 @@ def t_IDENTIFICADOR(t):
return t
def t_CADENA(t):
- r'(\".*\")|(\'.*\')'
+ r'(\".*?\")|(\'.*?\')'
return t
# Definimos esta regla para poder controlar los numeros de lineas
46 gSLParser.py
View
@@ -92,15 +92,34 @@ def p_body_statements(p):
"""
p[0] = p[2]
- def p_statement_list(p):
- """ statement_list : statement_list statement
- | statement
+ def p_statement_list_compund(p):
+ """ statement_list : statement_list multiple_statement
"""
- if len(p) == 3:
+ #""" statement_list : statement_list statement
+ # | statement
+ # p_statement_list se separa en 2 (compound y simple) para
+ # simplificar la funcion
+
+ # Si multiple_statement resulta una lista, concatenar listas,
+ # si es un nodo, agregarlo como elemento.
+ if isinstance(p[2], list):
+ p[0] = p[1] + p[2]
+ else:
p[0] = p[1] + [p[2]]
- if len(p) == 2:
- if p[1] == None or p[1] == []:
- p[0] = []
+
+ def p_statement_list_simple(p):
+ """ statement_list : multiple_statement
+ """
+ # p_statement_list se separa en 2 (compound y simple) para
+ # simplificar la funcion
+
+ # Si multiple_statement resulta una lista, concatenar listas,
+ # si es un nodo, agregarlo como elemento.
+ if p[1] == None or p[1] == []:
+ p[0] = []
+ else:
+ if isinstance(p[1], list):
+ p[0] = p[1]
else:
p[0] = [p[1]]
@@ -109,6 +128,15 @@ def p_empty_statement(p):
"""
#p[0] = p[1] #"asf"
+ def p_multiple_statement(p):
+ """ multiple_statement : multiple_statement PUNTO_Y_COMA statement
+ | statement
+ """
+ if len(p) == 4:
+ p[0] = p[1] + [p[3]]
+ elif len(p) == 2:
+ p[0] = [p[1]]
+
def p_subrutine_list(p):
""" subrutine_list : subrutine_list subrutine
| subrutine
@@ -263,6 +291,7 @@ def p_statement_assign(p):
def p_statement_if(p):
'statement : SI PAREN_I bool_expression PAREN_D LLAVE_I statement_list LLAVE_D'
p[0] = If(test = p[3], body = p[6], orelse = [])
+ print_debug("SI: (" + str(p[3]) +")")
def p_statement_if_else(p):
'statement : SI PAREN_I bool_expression PAREN_D LLAVE_I statement_list SINO statement_list LLAVE_D'
@@ -303,6 +332,7 @@ def p_expression_bool(p):
| and_expression'''
if len(p) == 2:
p[0] = p[1]
+ print_debug("bool_expression: (" + str(p[0]) +")")
elif len(p) == 4:
p[0] = BoolOp(op = Or(), values = [p[1], p[3]])
@@ -316,6 +346,7 @@ def p_expression_and(p):
p[0] = UnaryOp(op = Not(), operand = p[2])
elif len(p) == 2:
p[0] = p[1]
+ print_debug("and_expression: (" + str(p[1]) +")")
def p_expression_comp(p):
'''test_expression : expression S_MENOR_QUE expression
@@ -376,6 +407,7 @@ def p_expression_cadena(p):
# Tomamos desde el segundo caracter hasta el penúltimo
# para sacar las comillas
p[0] = Str(s = p[1][1:-1])
+ print_debug("Cadena: '%s'" % p[1])
def p_expression_subrutine_call(p):
"expression : subrutine_call"

No commit comments for this range

Something went wrong with that request. Please try again.