fn close_delimiter(&mut self, delim: Delimiter, start: Span<Location>) -> bool {
        match self.open_braces.pop() {
            // We received a closing delimiter with an empty delimiter stack.
            // We don't want to emit the token, as this will certainly break
            // the parser.
            None => {
                let found = delim.to_string();

                self.errors.push(LexerError::UnexpectedCharacter {
                    start,
                    found: found.chars().next().unwrap(),
                });

                false
            }
            // We received a closing delimiter that closes the last delimiter.
            // Nothing to do, just emit the token.
            Some(open) if delim.closes(open) => true,
            // We received a closing delimiter that doesn't close the last delimiter.
            // Try to fix the delimiter stack.
            Some(open) => {
                // TODO(luisholanda): We should search the probably opening delimiter
                //  that match the closing one, as rustc does, instead of just telling
                //  what is expected.
                let expected = open.opposed().to_string();
                let found = delim.to_string();
                let error = LexerError::UnmatchedDelimiter {
                    start,
                    expected,
                    found,
                };
                self.errors.push(error);

                self.open_braces.push(open);

                self.try_fix_delimiter_stack(delim, start.start())
            }
        }
    }
/// Verifies if the close delimiters matches the open delimiter
/// on the top of the delimiters stack. Returns if the delimiter should be
/// emitted.
///
/// When the delimiters doesn't match and the close one matches one of the
/// others in the stack, tries to fix the last by emitting the opposed delimiter
/// of the part of the stack that didn't match. That is, when we have a stack like:
///
/// ```text
/// { { ( (
/// ```
///
/// And we receive a close delimiter `}`, we will emit two extra tokens,
/// that will close the `( (` part of the stack, thus, having a clean state
/// for the next tokens.
Verifies if the close delimiters matches the open delimiter
on the top of the delimiters stack. Returns if the delimiter should be
emitted.

When the delimiters doesn't match and the close one matches one of the
others in the stack, tries to fix the last by emitting the opposed delimiter
of the part of the stack that didn't match. That is, when we have a stack like.



And we receive a close delimiter `}`, we will emit two extra tokens,
that will close the `( (` part of the stack, thus, having a clean state
for the next tokens.
Verifies if the close delimiters matches the open delimiter on the top of the delimiters stack . Returns if the delimiter should be emitted . When the delimiters doesn ' t match and the close one matches one of the others in the stack tries to fix the last by emitting the opposed delimiter of the part of the stack that didn ' t match . That is when we have a stack like . And we receive a close delimiter ` } ` we will emit two extra tokens that will close the ` ( ( ` part of the stack thus having a clean state for the next tokens .
fn close_delimiter(&mut self, delim: Delimiter, start: Span<Location>) -> bool {
        match self.open_braces.pop() {
            // We received a closing delimiter with an empty delimiter stack.
            // We don't want to emit the token, as this will certainly break
            // the parser.
            None => {
                let found = delim.to_string();
                self.errors.push(LexerError::UnexpectedCharacter {
                    start,
                    found: found.chars().next().unwrap(),
                });
                false
            }
            // We received a closing delimiter that closes the last delimiter.
            // Nothing to do, just emit the token.
            Some(open) if delim.closes(open) => true,
            // We received a closing delimiter that doesn't close the last delimiter.
            // Try to fix the delimiter stack.
            Some(open) => {
                // TODO(luisholanda): We should search the probably opening delimiter
                //  that match the closing one, as rustc does, instead of just telling
                //  what is expected.
                let expected = open.opposed().to_string();
                let found = delim.to_string();
                let error = LexerError::UnmatchedDelimiter {
                    start,
                    expected,
                    found,
                };
                self.errors.push(error);
                self.open_braces.push(open);
                self.try_fix_delimiter_stack(delim, start.start())
            }
        }
    }
fn close_delimiter ( & mut self , delim : Delimiter , start : Span < Location > ) -> bool { match self . open_braces . pop ( ) { // We received a closing delimiter with an empty delimiter stack. // We don't want to emit the token, as this will certainly break // the parser. None => { let found = delim . to_string ( ) ; self . errors . push ( LexerError :: UnexpectedCharacter { start , found : found . chars ( ) . next ( ) . unwrap ( ) , } ) ; false } // We received a closing delimiter that closes the last delimiter. // Nothing to do, just emit the token. Some ( open ) if delim . closes ( open ) => true , // We received a closing delimiter that doesn't close the last delimiter. // Try to fix the delimiter stack. Some ( open ) => { // TODO(luisholanda): We should search the probably opening delimiter //  that match the closing one, as rustc does, instead of just telling //  what is expected. let expected = open . opposed ( ) . to_string ( ) ; let found = delim . to_string ( ) ; let error = LexerError :: UnmatchedDelimiter { start , expected , found , } ; self . errors . push ( error ) ; self . open_braces . push ( open ) ; self . try_fix_delimiter_stack ( delim , start . start ( ) ) } } }
Verifies if the close delimiters matches the open delimiter
on the top of the delimiters stack.
Verifies if the close delimiters matches the open delimiter on the top of the delimiters stack .
&mut self
delim
Delimiter
start
Span<Location>
&mut self
delim
Delimiter
start
Span<Location>