def ReadWord(self, unused_lex_mode): # type: (lex_mode_t) -> word__String """Interface for bool_parse.py. TODO: This should probably be word_t """ if self.i == self.n: # Does it make sense to define Eof_Argv or something? # TODO: Add a way to show this location. Show 1 char past the right-most # spid of the last word? But we only have the left-most spid. w = word.String(Id.Eof_Real, '', runtime.NO_SPID) return w #log('ARGV %s i %d', self.argv, self.i) s = self.cmd_val.argv[self.i] left_spid = self.cmd_val.arg_spids[self.i] self.i += 1 # default is an operand word id_ = match.BracketUnary(s) if id_ == Id.Undefined_Tok: id_ = match.BracketBinary(s) if id_ == Id.Undefined_Tok: id_ = match.BracketOther(s) if id_ == Id.Undefined_Tok: id_ = Id.Word_Compound # NOTE: We only have the left spid now. It might be useful to add the # right one. w = word.String(id_, s, left_spid) return w
def ReadWord(self, unused_lex_mode): """Interface for bool_parse.py.""" if self.i == self.n: # Does it make sense to define Eof_Argv or something? w = word.String(Id.Eof_Real, '') # TODO: Add a way to show this. Show 1 char past the right-most spid of # the last word? But we only have the left-most spid. w.spids.append(runtime.NO_SPID) return w #log('ARGV %s i %d', self.argv, self.i) s = self.arg_vec.strs[self.i] left_spid = self.arg_vec.spids[self.i] self.i += 1 # default is an operand word id_int = ( TEST_UNARY_LOOKUP.get(s) or TEST_BINARY_LOOKUP.get(s) or TEST_OTHER_LOOKUP.get(s) ) id_ = Id.Word_Compound if id_int is None else id_int # NOTE: We only have the left spid now. It might be useful to add the # right one. w = word.String(id_, s) w.spids.append(left_spid) return w