# -*- coding: utf-8 -*-
tokens = [
    'LPAREN',
    'RPAREN',
    'LBRACE',
    'RBRACE',
    'EQUAL',
    'DOUBLE_EQUAL',
    'NUMBER',
    'COMMA',
    'VAR_DEFINITION',
    'IF',
    'ELSE',
    'END',
    'ID',
    'PRINT'
]

t_RBRACE = r"\}"
t_EQUAL = r"\="
t_DOUBLE_EQUAL = r"\=\="

def t_NUMBER(token):
    r"[0-9]+"
    token.value = int(token.value)
    return token

t_COMMA = r","
def t_VAR_DEFINITION(token):
    r",\sFirst\sof\s(his|her)\sName"
    return token

def t_IF(token):
    r"I\spromise"
    return token

def t_ELSE(token):
    r"Mayhaps"
    return token

def t_PRINT(token):
    r"Hodor"
    return token

def t_END(token):
    r"And\snow\shis\swatch\sis\sended"
    return token

def t_ID(token):
    r"[a-zA-Z][_a-zA-Z0-9]*"
    return token

t_ignore = " \t"

def t_NEWLINE(token):
    r"\n+"
    token.lexer.lineno += len(token.value)

def t_IGNORE_COMMENTS(token):
    r"//(.*)\n"
    token.lexer.lineno += 1

def t_error(token):
    raise Exception("Sintax error: Unknown token on line {0}. \"{1}\"".format(token.lineno, token.value.partition("\n")[0]))
t_LPAREN = r"\("
t_RPAREN = r"\)"
t_LBRACE = r"\{"