(self, typechar, allow_past_end)
return word, c
Read a number or string entry for INPUT
Read a number or string entry for INPUT
Read a number or string entry for INPUT
def input_entry(self, typechar, allow_past_end):
        """Read a number or string entry for INPUT """
        word, blanks = b'', b''
        # fix readahead buffer (self.next_char)
        last = self._skip_whitespace(INPUT_WHITESPACE)
        # read first non-whitespace char
        c = self.read_one()
        # LF escapes quotes
        # may be true if last == '', hence "in ('\n', '\0')" not "in '\n0'"
        quoted = (c == b'"' and typechar == values.STR and last not in (b'\n', b'\0'))
        if quoted:
            c = self.read_one()
        # LF escapes end of file, return empty string
        if not c and not allow_past_end and last not in (b'\n', b'\0'):
            raise error.BASICError(error.INPUT_PAST_END)
        # we read the ending char before breaking the loop
        # this may raise FIELD OVERFLOW
        while c and not (
                (typechar != values.STR and c in self.soft_sep) or
                (c in b',\r' and not quoted)
            ):
            if c == b'"' and quoted:
                # whitespace after quote will be skipped below
                break
            elif c == b'\n' and not quoted:
                # LF, LFCR are dropped entirely
                c = self.read_one()
                if c == b'\r':
                    c = self.read_one()
                continue
            elif c == b'\0':
                # NUL is dropped even within quotes
                pass
            elif c in INPUT_WHITESPACE and not quoted:
                # ignore whitespace in numbers, except soft separators
                # include internal whitespace in strings
                if typechar == values.STR:
                    blanks += c
            else:
                word += blanks + c
                blanks = b''
            if len(word) + len(blanks) >= 255:
                break
            if not quoted:
                c = self.read_one()
            else:
                # no CRLF replacement inside quotes.
                c = self.read(1)
        # if separator was a whitespace char or closing quote
        # skip trailing whitespace before any comma or hard separator
        if c and c in INPUT_WHITESPACE or (quoted and c == b'"'):
            self._skip_whitespace(b' ')
            if self.peek(1) in b',\r':
                c = self.read_one()
        # file position is at one past the separator char
        return word, c
def input_entry ( self , typechar , allow_past_end ) : word , blanks = b'' , b'' # fix readahead buffer (self.next_char) last = self . _skip_whitespace ( INPUT_WHITESPACE ) # read first non-whitespace char c = self . read_one ( ) # LF escapes quotes # may be true if last == '', hence "in ('\n', '\0')" not "in '\n0'" quoted = ( c == b'"' and typechar == values . STR and last not in ( b'\n' , b'\0' ) ) if quoted : c = self . read_one ( ) # LF escapes end of file, return empty string if not c and not allow_past_end and last not in ( b'\n' , b'\0' ) : raise error . BASICError ( error . INPUT_PAST_END ) # we read the ending char before breaking the loop # this may raise FIELD OVERFLOW while c and not ( ( typechar != values . STR and c in self . soft_sep ) or ( c in b',\r' and not quoted ) ) : if c == b'"' and quoted : # whitespace after quote will be skipped below break elif c == b'\n' and not quoted : # LF, LFCR are dropped entirely c = self . read_one ( ) if c == b'\r' : c = self . read_one ( ) continue elif c == b'\0' : # NUL is dropped even within quotes pass elif c in INPUT_WHITESPACE and not quoted : # ignore whitespace in numbers, except soft separators # include internal whitespace in strings if typechar == values . STR : blanks += c else : word += blanks + c blanks = b'' if len ( word ) + len ( blanks ) >= 255 : break if not quoted : c = self . read_one ( ) else : # no CRLF replacement inside quotes. c = self . read ( 1 ) # if separator was a whitespace char or closing quote # skip trailing whitespace before any comma or hard separator if c and c in INPUT_WHITESPACE or ( quoted and c == b'"' ) : self . _skip_whitespace ( b' ' ) if self . peek ( 1 ) in b',\r' : c = self . read_one ( ) # file position is at one past the separator char return word , c