# Path: pydsl/exceptions.py
# class ParseError(Exception):
# 
#     def __init__(self, msg, offset):
#         self.msg = msg
#         self.offset = offset
# 
#     def __repr__(self):
#         return "ParseError(%r, %r)" % (self.msg, self.offset)
# 
#     def __str__(self):
#         return "%s at position %s" % (self.msg, self.offset + 1)


from pydsl.exceptions import ParseError
    )

# Tokens

t_PLUS    = r'\+'
t_MINUS   = r'-'
t_TIMES   = r'\*'
t_DIVIDE  = r'/'
t_EQUALS  = r'='
t_LPAREN  = r'\('
t_RPAREN  = r'\)'
t_NAME    = r'[a-zA-Z_][a-zA-Z0-9_]*'

def t_NUMBER(t):
    r'\d+'
    try:
        t.value = int(t.value)
    except ValueError:
        print("Integer value too large %d", t.value)
        t.value = 0
    return t

# Ignored characters
t_ignore = " \t"

def t_newline(t):
    r'\n+'
    t.lexer.lineno += t.value.count("\n")

def t_error(t):

# Path: pydsl/exceptions.py
# class ParseError(Exception):
# 
#     def __init__(self, msg, offset):
#         self.msg = msg
#         self.offset = offset
# 
#     def __repr__(self):
#         return "ParseError(%r, %r)" % (self.msg, self.offset)
# 
#     def __str__(self):
#         return "%s at position %s" % (self.msg, self.offset + 1)


# Path: pydsl/contrib/grammar/calc_ply.py
from pydsl.exceptions import ParseError

    )

# Tokens

t_PLUS    = r'\+'
t_MINUS   = r'-'
t_TIMES   = r'\*'
t_DIVIDE  = r'/'
t_EQUALS  = r'='
t_LPAREN  = r'\('
t_RPAREN  = r'\)'
t_NAME    = r'[a-zA-Z_][a-zA-Z0-9_]*'

def t_NUMBER(t):
    r'\d+'
    try:
        t.value = int(t.value)
    except ValueError:
        print("Integer value too large %d", t.value)
        t.value = 0
    return t

# Ignored characters
t_ignore = " \t"

def t_newline(t):
    r'\n+'
    t.lexer.lineno += t.value.count("\n")

def t_error(t):

    raise ParseError("unknown character", t.lexpos)