Extracts the next available uniline statement from the input stream, or `None` if none is available. The statement must be specifiable in a single line as part of a uniline `IF` statement, and we currently expect this to only be used while parsing an `IF`. On success, the stream is left in a position where the next statement can be extracted. On failure, the caller must advance the stream to the
(&mut self)
| 1842 | /// On success, the stream is left in a position where the next statement can be extracted. |
| 1843 | /// On failure, the caller must advance the stream to the next statement by calling `reset`. |
| 1844 | fn parse_uniline(&mut self) -> Result<Option<Statement>> { |
| 1845 | let token_span = self.lexer.read()?; |
| 1846 | match token_span.token { |
| 1847 | Token::Data => Ok(Some(self.parse_data()?)), |
| 1848 | Token::End => Ok(Some(self.parse_end(token_span.pos)?)), |
| 1849 | Token::Eof | Token::Eol => Ok(None), |
| 1850 | Token::Exit => Ok(Some(self.parse_exit(token_span.pos)?)), |
| 1851 | Token::Gosub => Ok(Some(self.parse_gosub()?)), |
| 1852 | Token::Goto => Ok(Some(self.parse_goto()?)), |
| 1853 | Token::On => Ok(Some(self.parse_on(token_span.pos)?)), |
| 1854 | Token::Return => Ok(Some(Statement::Return(ReturnSpan { pos: token_span.pos }))), |
| 1855 | Token::Symbol(vref) => { |
| 1856 | let peeked = self.lexer.peek()?; |
| 1857 | if peeked.token == Token::Equal { |
| 1858 | self.lexer.consume_peeked(); |
| 1859 | Ok(Some(self.parse_assignment(vref, token_span.pos)?)) |
| 1860 | } else { |
| 1861 | Ok(Some(self.parse_array_or_builtin_call(vref, token_span.pos)?)) |
| 1862 | } |
| 1863 | } |
| 1864 | Token::Bad(msg) => Err(Error::Bad(token_span.pos, msg)), |
| 1865 | t => Err(Error::Bad(token_span.pos, format!("Unexpected {} in uniline IF branch", t))), |
| 1866 | } |
| 1867 | } |
| 1868 | |
| 1869 | /// Extracts the next available statement from the input stream, or `None` if none is available. |
| 1870 | /// |
no test coverage detected