Home | History | Annotate | Download | only in parsing
      1 # -----------------------------------------------------------------------------
      2 # yacc_simple.py
      3 #
      4 # A simple, properly specifier grammar
      5 # -----------------------------------------------------------------------------
      6 
      7 from .calclex import tokens
      8 from ply import yacc
      9 
     10 # Parsing rules
     11 precedence = (
     12     ('left','PLUS','MINUS'),
     13     ('left','TIMES','DIVIDE'),
     14     ('right','UMINUS'),
     15     )
     16 
     17 # dictionary of names
     18 names = { }
     19 
     20 from .statement import *
     21 
     22 from .expression import *
     23 
     24 def p_error(t):
     25     print("Syntax error at '%s'" % t.value)
     26 
     27 import os.path
     28 parser = yacc.yacc(outputdir=os.path.dirname(__file__))
     29 
     30 
     31 
     32 
     33 
     34