summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-06-10 23:53:20 +0200
committerLaurenz <laurmaedje@gmail.com>2022-06-10 23:54:16 +0200
commited6550fdb08eae92bffab6b6b137b1e0eebf62c6 (patch)
tree74152a38f7aa2ed2ac2fa190e81494422700ca36 /src/parse
parent6aff11057bc88257c9383137952bb41b5b85c3dc (diff)
Bump dependencies
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/mod.rs5
-rw-r--r--src/parse/parser.rs11
-rw-r--r--src/parse/tokens.rs17
3 files changed, 15 insertions, 18 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index be3af1f8..98f25cab 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -11,9 +11,8 @@ pub use tokens::*;
use std::collections::HashSet;
-use crate::diag::ErrorPos;
use crate::syntax::ast::{Associativity, BinOp, UnOp};
-use crate::syntax::{NodeKind, SyntaxNode};
+use crate::syntax::{NodeKind, SpanPos, SyntaxNode};
use crate::util::EcoString;
/// Parse a source file.
@@ -648,7 +647,7 @@ fn item(p: &mut Parser, keyed: bool) -> ParseResult<NodeKind> {
msg.push_str(", found ");
msg.push_str(kind.as_str());
}
- let error = NodeKind::Error(ErrorPos::Full, msg);
+ let error = NodeKind::Error(SpanPos::Full, msg);
marker.end(p, error);
p.eat();
marker.perform(p, NodeKind::Named, expr).ok();
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index 722e53ce..f4b02a9c 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -3,8 +3,7 @@ use std::mem;
use std::ops::Range;
use super::{TokenMode, Tokens};
-use crate::diag::ErrorPos;
-use crate::syntax::{InnerNode, NodeData, NodeKind, SyntaxNode};
+use crate::syntax::{InnerNode, NodeData, NodeKind, SpanPos, SyntaxNode};
use crate::util::EcoString;
/// A convenient token-based parser.
@@ -385,7 +384,7 @@ impl Parser<'_> {
pub fn unexpected(&mut self) {
if let Some(found) = self.peek() {
let msg = format_eco!("unexpected {}", found);
- let error = NodeKind::Error(ErrorPos::Full, msg);
+ let error = NodeKind::Error(SpanPos::Full, msg);
self.perform(error, Self::eat);
}
}
@@ -399,7 +398,7 @@ impl Parser<'_> {
/// Insert an error message that `what` was expected at the marker position.
pub fn expected_at(&mut self, marker: Marker, what: &str) {
let msg = format_eco!("expected {}", what);
- let error = NodeKind::Error(ErrorPos::Full, msg);
+ let error = NodeKind::Error(SpanPos::Full, msg);
self.children.insert(marker.0, NodeData::new(error, 0).into());
}
@@ -409,7 +408,7 @@ impl Parser<'_> {
match self.peek() {
Some(found) => {
let msg = format_eco!("expected {}, found {}", thing, found);
- let error = NodeKind::Error(ErrorPos::Full, msg);
+ let error = NodeKind::Error(SpanPos::Full, msg);
self.perform(error, Self::eat);
}
None => self.expected(thing),
@@ -481,7 +480,7 @@ impl Marker {
msg.push_str(", found ");
msg.push_str(child.kind().as_str());
}
- let error = NodeKind::Error(ErrorPos::Full, msg);
+ let error = NodeKind::Error(SpanPos::Full, msg);
let inner = mem::take(child);
*child = InnerNode::with_child(error, inner).into();
}
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index 92155909..ff36c6be 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -4,10 +4,9 @@ use unicode_xid::UnicodeXID;
use unscanny::Scanner;
use super::resolve::{resolve_hex, resolve_raw, resolve_string};
-use crate::diag::ErrorPos;
use crate::geom::{AngleUnit, LengthUnit};
use crate::syntax::ast::{MathNode, RawNode, Unit};
-use crate::syntax::NodeKind;
+use crate::syntax::{NodeKind, SpanPos};
use crate::util::EcoString;
/// An iterator over the tokens of a string of source code.
@@ -287,14 +286,14 @@ impl<'s> Tokens<'s> {
NodeKind::Escape(c)
} else {
NodeKind::Error(
- ErrorPos::Full,
+ SpanPos::Full,
"invalid unicode escape sequence".into(),
)
}
} else {
self.terminated = false;
NodeKind::Error(
- ErrorPos::End,
+ SpanPos::End,
"expected closing brace".into(),
)
}
@@ -394,7 +393,7 @@ impl<'s> Tokens<'s> {
self.terminated = false;
NodeKind::Error(
- ErrorPos::End,
+ SpanPos::End,
if found == 0 {
format_eco!("expected {} {}", remaining, noun)
} else {
@@ -442,7 +441,7 @@ impl<'s> Tokens<'s> {
} else {
self.terminated = false;
NodeKind::Error(
- ErrorPos::End,
+ SpanPos::End,
if !display || (!escaped && dollar) {
"expected closing dollar sign".into()
} else {
@@ -531,7 +530,7 @@ impl<'s> Tokens<'s> {
NodeKind::Str(string)
} else {
self.terminated = false;
- NodeKind::Error(ErrorPos::End, "expected quote".into())
+ NodeKind::Error(SpanPos::End, "expected quote".into())
}
}
@@ -677,12 +676,12 @@ mod tests {
use super::*;
use crate::parse::tests::check;
- use ErrorPos::*;
use NodeKind::*;
use Option::None;
+ use SpanPos::*;
use TokenMode::{Code, Markup};
- fn Error(pos: ErrorPos, message: &str) -> NodeKind {
+ fn Error(pos: SpanPos, message: &str) -> NodeKind {
NodeKind::Error(pos, message.into())
}