Skip to content

Commit 2cb9732

Browse files
committed
Remove "negative lookahead" misfeature.
1 parent c8eb9b3 commit 2cb9732

File tree

4 files changed

+3
-26
lines changed

4 files changed

+3
-26
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ doctest = false
3131
test = false
3232

3333
[patch.'crates-io']
34-
grammer = { git = "https://github.com/lykenware/grammer", rev = "e108acbe83271761538bf5b2ff2daeaaafa5919c" }
34+
grammer = { git = "https://github.com/lykenware/grammer", rev = "ed4fc4f9be9aa2c1a6c3245ba4e91684ddff5f2f" }
3535

3636
[workspace]
3737
members = [

src/generate/rust.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<Pat> RuleTypeMethods for Rule<Pat> {
116116

117117
fn field_type(&self, path: &[usize]) -> Src {
118118
match self {
119-
Rule::Empty | Rule::Eat(_) | Rule::NegativeLookahead(_) => {
119+
Rule::Empty | Rule::Eat(_) => {
120120
assert_eq!(path, []);
121121
quote!(())
122122
}
@@ -199,7 +199,6 @@ impl<Pat: Ord + Hash + RustInputPat> RuleRuleMapMethods<Pat> for Rule<Pat> {
199199
match self {
200200
Rule::Empty => "".to_string(),
201201
Rule::Eat(pat) => pat.rust_matcher().to_pretty_string(),
202-
Rule::NegativeLookahead(pat) => format!("!{}", pat.rust_matcher().to_pretty_string()),
203202
Rule::Call(r) => r.clone(),
204203
Rule::Concat([left, right]) => format!(
205204
"({} {})",
@@ -246,7 +245,7 @@ impl<Pat: Ord + Hash + RustInputPat> RuleRuleMapMethods<Pat> for Rule<Pat> {
246245
rules: &RuleMap<'_, Pat>,
247246
) -> ParseNodeShape<ParseNodeKind> {
248247
match &**rc_self {
249-
Rule::Empty | Rule::Eat(_) | Rule::NegativeLookahead(_) => ParseNodeShape::Opaque,
248+
Rule::Empty | Rule::Eat(_) => ParseNodeShape::Opaque,
250249
Rule::Call(_) => unreachable!(),
251250
Rule::Concat([left, right]) => {
252251
ParseNodeShape::Split(left.parse_node_kind(rules), right.parse_node_kind(rules))
@@ -802,10 +801,6 @@ impl<Pat: Ord + Hash + RustInputPat> RuleGenerateMethods<Pat> for Rule<Pat> {
802801
let pat = pat.rust_matcher();
803802
check(quote!(let Some(_range) = p.input_consume_left(_range, &(#pat)))).apply(cont)
804803
}
805-
(Rule::NegativeLookahead(pat), _) => {
806-
let pat = pat.rust_matcher();
807-
check(quote!(!p.input_lookahead_left(_range, &(#pat)))).apply(cont)
808-
}
809804
(Rule::Call(r), _) => call(Rc::new(CodeLabel::NamedRule(r.clone()))).apply(cont),
810805
(Rule::Concat([left, right]), None) => {
811806
(left.generate_parse(None) + right.generate_parse(None)).apply(cont)
@@ -902,7 +897,6 @@ impl<Pat: Ord + Hash + RustInputPat> RuleGenerateMethods<Pat> for Rule<Pat> {
902897
match self {
903898
Rule::Empty
904899
| Rule::Eat(_)
905-
| Rule::NegativeLookahead(_)
906900
| Rule::Call(_)
907901
| Rule::RepeatMany(..)
908902
| Rule::RepeatMore(..) => {

src/parse_grammar.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ impl Primary<'_, '_, TokenStream> {
6767
fn lower<Pat: From<SPat>>(self) -> grammer::RuleWithNamedFields<Pat> {
6868
match self {
6969
Primary::Eat(pat) => grammer::eat(pat.one().unwrap().lower()),
70-
Primary::NegativeLookahead { pat } => {
71-
grammer::negative_lookahead(pat.one().unwrap().lower())
72-
}
7370
Primary::Call(name) => {
7471
let name = match name.source() {
7572
[FlatToken::Ident(ident)] => ident.to_string(),

src/runtime.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,6 @@ impl<'i, C: CodeStep<I>, I: Input> Parser<'i, C, I> {
367367
}
368368
}
369369

370-
pub fn input_lookahead_left<Pat>(&mut self, range: Range<'i>, pat: &'static Pat) -> bool
371-
where
372-
I::Slice: InputMatch<Pat>,
373-
{
374-
self.forest.input(range).match_left(pat).is_some()
375-
}
376-
377370
pub fn input_consume_right<Pat>(&self, range: Range<'i>, pat: &'static Pat) -> Option<Range<'i>>
378371
where
379372
I::Slice: InputMatch<Pat>,
@@ -385,13 +378,6 @@ impl<'i, C: CodeStep<I>, I: Input> Parser<'i, C, I> {
385378
.map(|n| Range(range.split_at(range.len() - n).0))
386379
}
387380

388-
pub fn input_lookbehind_right<Pat>(&self, range: Range<'i>, pat: &'static Pat) -> bool
389-
where
390-
I::Slice: InputMatch<Pat>,
391-
{
392-
self.forest.input(range).match_right(pat).is_some()
393-
}
394-
395381
pub fn forest_add_choice(
396382
&mut self,
397383
kind: C::ParseNodeKind,

0 commit comments

Comments
 (0)