(self, typechar, allow_past_end)
return word, c
Read a number or string entry from KYBD: or COMn: for INPUT#.
Read a number or string entry from KYBD: or COMn: for INPUT#.
Read a number or string entry from KYBD : or COMn : for INPUT# .
def input_entry(self, typechar, allow_past_end):
        """Read a number or string entry from KYBD: or COMn: for INPUT#."""
        word, blanks = b'', b''
        c = self.read_one()
        # LF escapes quotes
        quoted = (c == b'"' and typechar == values.STR)
        if quoted:
            c = self.read_one()
        # LF escapes end of file, return empty string
        if not c and not allow_past_end:
            raise error.BASICError(error.INPUT_PAST_END)
        # on reading from a KYBD: file, control char replacement takes place
        # which means we need to use read_one() not read()
        parsing_trail = False
        while c and not (c in b',\r' and not quoted):
            if c == b'"' and quoted:
                parsing_trail = True
            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
            # there should be KYBD: control char replacement here even if quoted
            save_prev = self._previous
            c = self.read_one()
            if parsing_trail:
                if c not in INPUT_WHITESPACE:
                    # un-read the character if it's not a separator
                    if c not in (b',', b'\r'):
                        self._readahead.insert(0, c)
                        self._current, self._previous = self._previous, save_prev
                    break
            parsing_trail = parsing_trail or (typechar != values.STR and c == b' ')
        # file position is at one past the separator char
        return word, c
def input_entry ( self , typechar , allow_past_end ) : word , blanks = b'' , b'' c = self . read_one ( ) # LF escapes quotes quoted = ( c == b'"' and typechar == values . STR ) if quoted : c = self . read_one ( ) # LF escapes end of file, return empty string if not c and not allow_past_end : raise error . BASICError ( error . INPUT_PAST_END ) # on reading from a KYBD: file, control char replacement takes place # which means we need to use read_one() not read() parsing_trail = False while c and not ( c in b',\r' and not quoted ) : if c == b'"' and quoted : parsing_trail = True 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 # there should be KYBD: control char replacement here even if quoted save_prev = self . _previous c = self . read_one ( ) if parsing_trail : if c not in INPUT_WHITESPACE : # un-read the character if it's not a separator if c not in ( b',' , b'\r' ) : self . _readahead . insert ( 0 , c ) self . _current , self . _previous = self . _previous , save_prev break parsing_trail = parsing_trail or ( typechar != values . STR and c == b' ' ) # file position is at one past the separator char return word , c