view ply-3.8/test/pkg_test6/parsing/calcparse.py @ 12467:a4835ba01fb1 draft

<int-e> learn The password of the month was delayed by snow and ice and Elon Musk.
author HackEso <hackeso@esolangs.org>
date Sun, 20 Nov 2022 20:26:27 +0000
parents 343ff337a19b
children
line wrap: on
line source

# -----------------------------------------------------------------------------
# yacc_simple.py
#
# A simple, properly specifier grammar
# -----------------------------------------------------------------------------

from .calclex import tokens
from ply import yacc

# Parsing rules
precedence = (
    ('left','PLUS','MINUS'),
    ('left','TIMES','DIVIDE'),
    ('right','UMINUS'),
    )

# dictionary of names
names = { }

from .statement import *

from .expression import *

def p_error(t):
    print("Syntax error at '%s'" % t.value)

import os.path
parser = yacc.yacc(outputdir=os.path.dirname(__file__))