def t_indent_sp(t):
    r'\n\ *'
    global Last_colonindent, Sent_newline
    indent = len(t.value) - 1
    if indent == Last_colonindent:
        t.lexer.lineno += 1
        t.lexer.begin('INITIAL')
        t.type = 'NEWLINE_TOK'
        return t
    if indent > Last_colonindent:
        t.lexer.lineno += 1
        t.lexer.begin('INITIAL')
        return
    if indent % 4:
        raise SyntaxError("invalid indent level, must be multiple of 4 spaces",
                          scanner_init.syntaxerror_params())
    if not Sent_newline:
        t.lexer.lineno += 1
        t.lexer.skip(-len(t.value))     # come back here after NEWLINE_TOK
        t.type = 'NEWLINE_TOK'
        Sent_newline = True
        return t
    t.type = 'DEINDENT_TOK'
    Last_colonindent -= 4
    if indent == Last_colonindent:
        t.lexer.begin('INITIAL')
    else:
        t.lexer.skip(-len(t.value))     # come back here after DEINDENT_TOK
    return t
def t_colonindent_INDENT_TOK(t):
    r'\n\ *'
    global Last_colonindent
    indent = len(t.value) - 1
    if indent != Last_colonindent + 4:
        raise SyntaxError("improper indent level after :",
                          scanner_init.syntaxerror_params())
    Last_colonindent = indent
    t.lexer.begin('INITIAL')
    return t
def t_ANY_error(t):
    raise SyntaxError("Scanner error: possible illegal character %r" %
                        t.value[0],
                      scanner_init.syntaxerror_params())
def p_error(t):
    if t is None:
        raise SyntaxError("invalid syntax", scanner_init.syntaxerror_params())
    else:
        raise SyntaxError("invalid syntax", scanner_init.syntaxerror_params(t))