def nexusSkipPastBlockEnd(flob):
    """Read up to and including a block 'end' or 'endblock'."""
    # This should only ever be issued after a semi-colon

    complaintHead = '\nNexus: nexusSkipPastBlockEnd()'
    if hasattr(flob, 'name'):
        complaintHead += " file: %s" % flob.name
    while 1:
        tok = nextTok(flob)
        if tok:
            lowTok = string.lower(tok)
            if lowTok == 'end' or lowTok == 'endblock':
                tok2 = nextTok(flob)
                if not tok2 or tok2 != ';':
                    gm = [complaintHead]
                    gm.append("    Expecting a semicolon after %s" % tok)
                    if not tok2:
                        gm.append("Got nothing.")
                    else:
                        gm.append("Got '%s'" % tok2)
                    raise Glitch, gm
                return
            elif lowTok == ';':  # for pathological cases where the last command is a ';' by itself.
                continue
            else:
                pf.nexusSkipPastNextSemiColon(nt.nexusToken, flob)
        else:
            break
    gm = [complaintHead]
    gm.append("Failed to find either 'end' or 'endblock'")
    gm.append("Premature end of file?")
    raise Glitch, gm
Example #2
0
def nexusSkipPastBlockEnd(flob):
    """Read up to and including a block 'end' or 'endblock'."""
    # This should only ever be issued after a semi-colon

    complaintHead = '\nNexus: nexusSkipPastBlockEnd()'
    if hasattr(flob, 'name'):
        complaintHead += " file: %s" % flob.name
    while 1:
        tok = nextTok(flob)
        if tok:
            lowTok = string.lower(tok)
            if lowTok == 'end' or lowTok == 'endblock':
                tok2 = nextTok(flob)
                if not tok2 or tok2 != ';':
                    gm = [complaintHead]
                    gm.append("    Expecting a semicolon after %s" % tok)
                    if not tok2:
                        gm.append("Got nothing.")
                    else:
                        gm.append("Got '%s'" % tok2)
                    raise Glitch(gm)
                return
            elif lowTok == ';':  # for pathological cases where the last command is a ';' by itself.
                continue
            else:
                pf.nexusSkipPastNextSemiColon(nt.nexusToken, flob)
        else:
            break
    gm = [complaintHead]
    gm.append("Failed to find either 'end' or 'endblock'")
    gm.append("Premature end of file?")
    raise Glitch(gm)
def nexusSkipPastNextSemiColon(flob):
    pf.nexusSkipPastNextSemiColon(nt.nexusToken, flob)
Example #4
0
def nexusSkipPastNextSemiColon(flob):
    pf.nexusSkipPastNextSemiColon(nt.nexusToken, flob)