identifier :: LParser String
identifier = ParseEither ok
  where
    ok ts@(Token t : _) | t `elem` map (:[]) forbidden_characters = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | t `elem` forbidden_identifier = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | head t == '\'' = Left ("invalid token: " ++ t, ts)
    ok (Token t : ts) = Right (t, ts)
    ok ts@(t:_) = Left $ ("expected token, got: " ++ show t, ts)
    ok [] = Left ("expected token, got EOF.", [])
identifier :: LParser String
identifier = ParseEither ok
  where
    ok ts@(Token t : _) | t `elem` map (:[]) forbidden_characters = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | t `elem` forbidden_identifier = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | head t == '\'' = Left ("invalid token: " ++ t, ts)
    ok (Token t : ts) = Right (t, ts)
    ok ts@(t:_) = Left $ ("expected token, got: " ++ show t, ts)
    ok [] = Left ("expected token, got EOF.", [])
identifier = ParseEither ok
  where
    ok ts@(Token t : _) | t `elem` map (:[]) forbidden_characters = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | t `elem` forbidden_identifier = Left ("invalid token: " ++ t, ts)
    ok ts@(Token t : _) | head t == '\'' = Left ("invalid token: " ++ t, ts)
    ok (Token t : ts) = Right (t, ts)
    ok ts@(t:_) = Left $ ("expected token, got: " ++ show t, ts)
    ok [] = Left ("expected token, got EOF.", [])