Skip to content

Commit

Permalink
Use word_opt instead of tag_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
moratorium08 committed Oct 1, 2024
1 parent 03266ed commit a964c71
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ impl<'cxt, 's> Parser<'cxt, 's> {

if let Some(pos) = self.tag_opt_pos("(") {
self.ws_cmt();
if self.tag_opt(keywords::let_) {
if self.word_opt(keywords::let_) {
n += 1;
self.push_bind();
self.ws_cmt();
Expand Down Expand Up @@ -1751,21 +1751,10 @@ impl<'cxt, 's> Parser<'cxt, 's> {

/// Bool parser.
pub fn bool(&mut self) -> Option<bool> {
let start_pos = self.pos();
if self.tag_opt("true") {
if !self.legal_id_char() {
Some(true)
} else {
self.backtrack_to(start_pos);
None
}
} else if self.tag_opt("false") {
if !self.legal_id_char() {
Some(false)
} else {
self.backtrack_to(start_pos);
None
}
if self.word_opt("true") {
Some(true)
} else if self.word_opt("false") {
Some(false)
} else {
None
}
Expand Down Expand Up @@ -2411,7 +2400,7 @@ impl<'cxt, 's> Parser<'cxt, 's> {
op_pos,
bind_count,
)));
} else if self.tag_opt(keywords::op::as_) {
} else if self.word_opt(keywords::op::as_) {
return Ok(TermTokenRes::Push(TermFrame::new(
FrameOp::Cast,
op_pos,
Expand All @@ -2436,7 +2425,7 @@ impl<'cxt, 's> Parser<'cxt, 's> {
op_pos,
bind_count,
)));
} else if self.tag_opt(keywords::op::lambda_) {
} else if self.word_opt(keywords::op::lambda_) {
self.ws_cmt();
self.word(keywords::op::is_)?;
self.ws_cmt();
Expand Down Expand Up @@ -2981,16 +2970,16 @@ impl<'cxt, 's> Parser<'cxt, 's> {
let mut ptterm = if let Some(pos) = self.tag_opt_pos("(") {
self.ws_cmt();

if self.tag_opt("and") {
if self.word_opt("and") {
stack.push(Frame::And(vec![]));
continue 'go_down;
} else if self.tag_opt("or") {
} else if self.word_opt("or") {
stack.push(Frame::Or(vec![]));
continue 'go_down;
} else if self.tag_opt("not") {
} else if self.word_opt("not") {
stack.push(Frame::Not);
continue 'go_down;
} else if self.tag_opt("=>") {
} else if self.word_opt("=>") {
stack.push(Frame::Impl(vec![]));
continue 'go_down;
} else {
Expand Down Expand Up @@ -3403,9 +3392,9 @@ impl<'cxt, 's> Parser<'cxt, 's> {

let bind_count = self.let_bindings(&VarMap::new(), &BTreeMap::new(), instance)?;

let idx = if self.tag_opt("true") {
let idx = if self.word_opt("true") {
ClauseRes::Skipped
} else if self.tag_opt("false") {
} else if self.word_opt("false") {
ClauseRes::Skipped
} else {
self.ws_cmt();
Expand Down

0 comments on commit a964c71

Please sign in to comment.