fn error_context(&self) -> String {
        let length = 10;
        let mut string = String::from("");
        let context_length = if self.position >= length {
            string.push_str("...");
            length
        } else {
            self.position
        };

        for i in (self.position - context_length)
            ..min(self.position + context_length, self.tokens.len() - 1)
        {
            let token_str = format!("{}", &self.tokens[i]);
            if i == self.position {
                string.push_str(format_color(Color::BoldRed, token_str.as_str()).as_str());
            } else {
                string.push_str(&token_str);
            }

            if i != self.position - 1
                && self.tokens[i + 1].requires_space()
                && self.tokens[i].requires_space()
            {
                string.push_str(" ");
            }
        }

        if self.position != self.tokens.len() {
            string.push_str("...");
        }

        string
    }
Returns a string representing a context in the input.
weld/src/syntax/parser.rs