def read_keyword(form):
    """Read a keyword."""
    if len(form) == 0:
        raise SyntaxError('unexpected EOF while reading keyword')
    if form[0] != ':':
        raise SyntaxError('expected : as first char of keyword')
    form = form[1:]
    s = ""
    while len(form) > 0:
        ch = form[0]
        if not (ch.isalpha() or ch.isdigit() or ch == '-' or ch == '.'):
            return (Keyword(":" + s), form)
        else:
            s = s + ch
            form = form[1:]

    if len(s) > 1:
        return (Keyword(":" + s), form)
    else:
        raise SyntaxError('EOF while reading keyword')
dataset/ETHPy150Open ensime/ensime-sublime/sexp.py/read_keyword/original