Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def p_empty(p):
'empty : '
pass
yacc.yacc()
import sys
if len(sys.argv) < 2:
print "need kif file"
sys.exit(1)
file = open(sys.argv[1], 'r').read()
result = yacc.parse(file)
#import psyco
#psyco.full()
try:
collapse(ir.get_rules())
except KeyboardInterrupt:
pass
def main(text):
"""Usage:
$ cat << EOF | python tinypie2.py
> print x
> x = 7
> print 5
> EOF
7
5
"""
# Start the parser
lex.lex()
yacc.yacc()
visitor = NodeVisitor()
tree = yacc.parse(text)
visitor.visit(tree)
from ply import yacc, lex
import toyyacc
rules = '''
E + S <-> ES (1,2)
ES --> E + P (0.3)
'''
model = yacc.parse(rules)
print
print "rules:"
for r in model.rules:
print ' ', r
model.finalize()
print
print "equations:"
for s in model.species.values():
print ' d[%s]/dt = %s' % (s.name, ' + '.join(str(t) for t in s.mass_action_terms))
p[0] = names[p[1]]
except LookupError:
print("Undefined name '%s'" % p[1])
p[0] = 0
def p_error(p):
print("Syntax error at '%s'" % p.value)
yacc.yacc()
while True:
try:
s = input('calc > ') # use input() on Python 3
except EOFError:
break
yacc.parse(s)
def p_error(p):
if p:
print "Syntax error at '%s'" % p.value
else:
print "Syntax error at EOF"
import ply.yacc as yacc
yacc.yacc()
while 1:
try:
s = raw_input('calc > ')
except EOFError:
break
if not s: continue
yacc.parse(unicode(s))
def p_empty(p):
'empty :'
pass
def p_error(t):
print("Syntax error '%s' at line %d" % (t.value, t.lexer.lineno))
yacc.yacc()
def parse(content):
return yacc.parse(content)
if __name__ == '__main__':
import sys
if len(sys.argv) > 1:
print(yacc.parse(open(sys.argv[1]).read()))
else:
while 1:
try:
line = raw_input('parser_test> ')
print(yacc.parse(line))
except EOFError:
break
except LookupError:
print "Undefined name '%s'" % t[1]
t[0] = 0
def p_error(t):
print "Syntax error at '%s'" % t.value
import ply.yacc as yacc
yacc.yacc(optimize=1)
while 1:
try:
s = raw_input('calc > ')
except EOFError:
break
yacc.parse(s)
def p_error(t):
print "error: %s at line %d" % (t.value, t.lexer.lineno)
#print "Syntax error on line %d" % p.lineno(1)
def p_empty(p):
'empty : '
pass
yacc.yacc()
import sys
file = open(sys.argv[1], 'r').read()
result = yacc.parse(file)
if p:
print("Syntax error at '%s'" % p.value)
else:
print("Syntax error at EOF")
import ply.yacc as yacc
yacc.yacc()
while 1:
try:
s = raw_input('calc > ')
except EOFError:
break
if not s:
continue
yacc.parse(s)
def parse(filename=None, factory=None):
if filename is None or factory is None:
return
_, p = new_parser()
p.factory = factory
p.modelStack = []
p.modelStack2 = []
res = None
try:
filename = os.path.realpath(filename)
f = open(filename)
res = yacc.parse(f.read())
except:
log = Logger('JDraw Parser')
log.warning("Failed to parse %s" % filename)
log.debug("Details:", exc_info=1)
return res