}
#[derive(Debug, Default)]
-pub struct LayoutInfo {
- pub inserted: bool,
- pub more: bool,
+struct LayoutInfo {
+ inserted: bool,
+ more: bool,
}
#[derive(Debug, PartialEq)]
}
}
- pub fn consume_layout(
+ fn consume_layout(
&mut self,
c: Option<char>,
layout_info: &mut LayoutInfo,
Ok(())
}
- fn scan_for_layout(&mut self) -> Result<bool, ParserError> {
- let mut layout_info = LayoutInfo { inserted: false, more: true };
+ pub fn scan_for_layout(&mut self) -> Result<bool, ParserError> {
+ match self.lookahead_char() {
+ Err(e) => {
+ Err(e)
+ }
+ Ok(c) => {
+ let mut layout_info = LayoutInfo { inserted: false, more: true };
+ let mut cr = Some(c);
- loop {
- let cr = self.lookahead_char();
- self.consume_layout(cr.ok(), &mut layout_info)?;
+ loop {
+ self.consume_layout(cr, &mut layout_info)?;
- if !layout_info.more {
- break;
+ if !layout_info.more {
+ break;
+ }
+
+ cr = self.lookahead_char().ok();
+ }
+
+ Ok(layout_info.inserted)
}
}
-
- Ok(layout_info.inserted)
}
pub fn next_token(&mut self) -> Result<Token, ParserError> {
false
}
- pub fn devour_whitespace(&mut self) -> Result<(), ParserError> {
- match self.lexer.lookahead_char() {
- Err(e) => { // if e.is_unexpected_eof() => {
- return Err(e);
- }
- Ok(c) => {
- let mut layout_info = LayoutInfo { inserted: false, more: true };
- let mut cr = Some(c);
-
- loop {
- self.lexer.consume_layout(cr, &mut layout_info)?;
-
- if !layout_info.more {
- break;
- }
-
- cr = self.lexer.lookahead_char().ok();
- }
- }
- }
-
- Ok(())
- }
-
pub fn reset(&mut self) {
self.stack.clear()
}
type SubtermDeque = VecDeque<(usize, usize)>;
pub(crate) fn devour_whitespace<'a, R: CharRead>(parser: &mut Parser<'a, R>) -> Result<bool, ParserError> {
- match parser.devour_whitespace() {
+ match parser.lexer.scan_for_layout() {
Err(e) if e.is_unexpected_eof() => {
Ok(true)
}
Err(e) => Err(e),
- Ok(()) => {
+ Ok(_) => {
Ok(false)
}
}
read_and_match :-
+ '$debug_hook',
'$read_query_term'(_, Term, _, _, VarList),
instruction_match(Term, VarList).