summaryrefslogtreecommitdiff
path: root/src/parse/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-04 15:16:46 +0100
committerMartin Haug <mhaug@live.de>2021-11-05 13:46:41 +0100
commitf0c9635db5efd0c66e01bef1be0a8f140fdbdd84 (patch)
tree9dec85646e86592c6353f18aa9c6265cabb9c83e /src/parse/mod.rs
parent65fac0e57c9852eb2131aa06c0bac43b70bfbfbc (diff)
Notes
Diffstat (limited to 'src/parse/mod.rs')
-rw-r--r--src/parse/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index bfe93896..30e20c0d 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -53,6 +53,8 @@ where
p.start();
while !p.eof() && f(p) {
markup_node(p, &mut at_start);
+ // NOTE: Just do this at the end of markup_node. Maybe even gives a
+ // speed boost. Wasn't possible in old parser due to use of ?.
if let Some(node) = p.last_child() {
at_start &= matches!(node.kind(),
&NodeKind::Space(_) | &NodeKind::Parbreak |
@@ -115,6 +117,7 @@ fn markup_node(p: &mut Parser, at_start: &mut bool) {
let group = if stmt { Group::Stmt } else { Group::Expr };
p.start_group(group, TokenMode::Code);
+ // NOTE: Return success from expr_with?
expr_with(p, true, 0);
if stmt && p.success() && !p.eof() {
p.expected_at("semicolon or line break");
@@ -138,6 +141,7 @@ fn markup_node(p: &mut Parser, at_start: &mut bool) {
/// Parse a heading.
fn heading(p: &mut Parser) {
+ // NOTE: Remove HeadingLevel kind and simply count Eq children in AST.
p.start();
p.start();
p.eat_assert(&NodeKind::Eq);
@@ -198,6 +202,8 @@ fn expr_with(p: &mut Parser, atomic: bool, min_prec: usize) {
let prec = op.precedence();
expr_with(p, atomic, prec);
+ // NOTE: Lifting not needed if we don't start in the first place.
+ // Then we could simply do expr_with(p, atomic, prec)?;
if p.may_lift_abort() {
return;
}
@@ -264,6 +270,10 @@ fn expr_with(p: &mut Parser, atomic: bool, min_prec: usize) {
break;
}
+ // NOTE: All lifts up to here wouldn't be needed.
+ // Only here we then need to do
+ // marker.end(p, NodeKind::Binary);
+
offset = p.end_and_start_with(NodeKind::Binary).0;
}
}
@@ -456,6 +466,7 @@ fn item(p: &mut Parser) -> NodeKind {
if p.eat_if(&NodeKind::Dots) {
expr(p);
+ // NOTE: Should be called `Spread`.
p.end_or_abort(NodeKind::ParameterSink);
return NodeKind::ParameterSink;
}