Factor out InputPosition to simplify the parsing code