summaryrefslogtreecommitdiffstats
path: root/chall/ply-2.2/test/yacc_notfunc.py
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-03-30 15:37:05 +0100
committerLouis Burda <quent.burda@gmail.com>2024-03-30 15:37:05 +0100
commit32309e019f2ff7d9f69f3e0016f67439e81b8b30 (patch)
treeace9fccd48489648b0586a8f84da21839632d0b9 /chall/ply-2.2/test/yacc_notfunc.py
parent4007ea18f294aefb6128cbe82c5446cd8cb72c50 (diff)
downloadcscg24-lolpython-32309e019f2ff7d9f69f3e0016f67439e81b8b30.tar.gz
cscg24-lolpython-32309e019f2ff7d9f69f3e0016f67439e81b8b30.zip
Rename to solve
Diffstat (limited to 'chall/ply-2.2/test/yacc_notfunc.py')
-rw-r--r--chall/ply-2.2/test/yacc_notfunc.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/chall/ply-2.2/test/yacc_notfunc.py b/chall/ply-2.2/test/yacc_notfunc.py
deleted file mode 100644
index 8389355..0000000
--- a/chall/ply-2.2/test/yacc_notfunc.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -----------------------------------------------------------------------------
-# yacc_notfunc.py
-#
-# p_rule not defined as a function
-# -----------------------------------------------------------------------------
-import sys
-sys.tracebacklimit = 0
-
-sys.path.insert(0,"..")
-import ply.yacc as yacc
-
-from calclex import tokens
-
-# Parsing rules
-precedence = (
- ('left','PLUS','MINUS'),
- ('left','TIMES','DIVIDE'),
- ('right','UMINUS'),
- )
-
-# dictionary of names
-names = { }
-
-p_statement_assign = "Blah"
-
-def p_statement_expr(t):
- 'statement : expression'
- print t[1]
-
-def p_expression_binop(t):
- '''expression : expression PLUS expression
- | expression MINUS expression
- | expression TIMES expression
- | expression DIVIDE expression'''
- if t[2] == '+' : t[0] = t[1] + t[3]
- elif t[2] == '-': t[0] = t[1] - t[3]
- elif t[2] == '*': t[0] = t[1] * t[3]
- elif t[3] == '/': t[0] = t[1] / t[3]
-
-def p_expression_uminus(t):
- 'expression : MINUS expression %prec UMINUS'
- t[0] = -t[2]
-
-def p_expression_group(t):
- 'expression : LPAREN expression RPAREN'
- t[0] = t[2]
-
-def p_expression_number(t):
- 'expression : NUMBER'
- t[0] = t[1]
-
-def p_expression_name(t):
- 'expression : NAME'
- try:
- t[0] = names[t[1]]
- except LookupError:
- print "Undefined name '%s'" % t[1]
- t[0] = 0
-
-def p_error(t):
- print "Syntax error at '%s'" % t.value
-
-yacc.yacc()
-
-
-
-