def lineno2tokenno(dat,lineno):
    """
    This routine takes a line number and returns the token number of the 
    token corresponding to the first token on that line.
    """
    nlines = len(dat.line2token)
    if lineno == 0:
        tokenno = 0
    elif lineno > nlines:
        tokenno = len(dat.token)
        tokenno = tokenno + 1
    else:
        tokenno = dat.line2token[lineno]
    return tokenno