New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEEK[start..end] #334

Merged
merged 27 commits into from Nov 19, 2018

Conversation

Projects
None yet
3 participants
@flying-sheep
Contributor

flying-sheep commented Nov 6, 2018

fixes #329

Rule::quote,
Rule::single_quote
],
positives: vec![Rule::term],

This comment has been minimized.

@flying-sheep

flying-sheep Nov 6, 2018

Contributor

no idea why I had to change this. is this a bug on master or did my added rule really change something?

This comment has been minimized.

@dragostis

dragostis Nov 8, 2018

Collaborator

This may be a bug. I can take a closer look at it. It's weird that this particular example shouldn't be influenced by the changes you've made.

This comment has been minimized.

@dragostis

dragostis Nov 17, 2018

Collaborator

I'll take a jab at this right now to see exactly what's going on.

This comment has been minimized.

@dragostis

dragostis Nov 17, 2018

Collaborator

I've fixed it in #343.

Show resolved Hide resolved pest/src/parser_state.rs Outdated
Show resolved Hide resolved pest/src/parser_state.rs Outdated
@dragostis

Very good progress! 👍

Show resolved Hide resolved derive/src/lib.rs
Show resolved Hide resolved meta/src/grammar.pest Outdated
Rule::quote,
Rule::single_quote
],
positives: vec![Rule::term],

This comment has been minimized.

@dragostis

dragostis Nov 8, 2018

Collaborator

This may be a bug. I can take a closer look at it. It's weird that this particular example shouldn't be influenced by the changes you've made.

Show resolved Hide resolved pest/src/stack.rs Outdated
Show resolved Hide resolved pest/src/stack.rs
Show resolved Hide resolved meta/src/grammar.pest
Show resolved Hide resolved meta/src/parser.rs Outdated
Show resolved Hide resolved pest/src/parser_state.rs Outdated
Show resolved Hide resolved pest/src/stack.rs

@flying-sheep flying-sheep force-pushed the flying-sheep:peek-slice branch from f123d3a to 2d5e03b Nov 9, 2018

@flying-sheep

This comment has been minimized.

Contributor

flying-sheep commented Nov 9, 2018

OK, one problem:

   Compiling pest_grammars v2.0.0 (/home/phil/Dev/Rust/pest/grammars)
error[E0433]: failed to resolve. Use of undeclared type or module `state`
  --> derive/tests/grammar.rs:15:10
   |
15 | #[derive(Parser)]
   |          ^^^^^^ Use of undeclared type or module `state`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: Could not compile `pest_derive`.

I don’t know what I did differently than the other generator code. What did I miss?

Show resolved Hide resolved generator/src/generator.rs Outdated
Show resolved Hide resolved generator/src/generator.rs Outdated
@flying-sheep

This comment has been minimized.

Contributor

flying-sheep commented Nov 9, 2018

oh, whoops! thank you! I also fixed the next problem:

   Compiling pest_derive v2.0.1 (/home/phil/Dev/Rust/pest/derive)
error[E0308]: mismatched types
  --> derive/tests/grammar.rs:15:10
   |
15 | #[derive(Parser)]
   |          ^^^^^^
   |          |
   |          expected enum `std::option::Option`, found i32
   |          help: try using a variant of the expected type: `Some(-2i32)`
   |
   = note: expected type `std::option::Option<i32>`
              found type `i32`

the problem was that (Option as ToToken)::to_token only emits something if not empty!

I fixed it as described in dtolnay/quote#20

Show resolved Hide resolved vm/tests/grammar.rs Outdated

@flying-sheep flying-sheep changed the title PEEK[start..end] (work in progress) PEEK[start..end] Nov 9, 2018

@dragostis

This is pretty close. I'll take a look at the error reporting issue right now and let you know as soon as I figure it out.

Show resolved Hide resolved derive/src/lib.rs Outdated
Show resolved Hide resolved meta/src/ast.rs Outdated
Show resolved Hide resolved meta/src/grammar.pest Outdated
Rule::quote,
Rule::single_quote
],
positives: vec![Rule::term],

This comment has been minimized.

@dragostis

dragostis Nov 17, 2018

Collaborator

I'll take a jab at this right now to see exactly what's going on.

pub fn stack_match_peek_slice(mut self: Box<Self>, start: i32, end: Option<i32>, match_dir: MatchDir) -> ParseResult<Box<Self>> {
let range = match constrain_idxs(start, end, self.stack.len()) {
Some(r) => r,
None => return Err(self),

This comment has been minimized.

@dragostis

dragostis Nov 17, 2018

Collaborator

Should being out-of-range be considered a hard error or a match fail? Currently, POP-ing on an empty stack causes a panic, but I feel like this approach is probably more expressive, if more error-prone.

Show resolved Hide resolved pest/src/parser_state.rs Outdated
Show resolved Hide resolved pest/src/stack.rs Outdated
Show resolved Hide resolved pest/src/stack.rs Outdated
@dragostis

This comment has been minimized.

Collaborator

dragostis commented Nov 17, 2018

Also, brackets should be added in pest_meta error renaming.

@flying-sheep flying-sheep force-pushed the flying-sheep:peek-slice branch 2 times, most recently from 4307654 to ec331e9 Nov 17, 2018

@flying-sheep

This comment has been minimized.

Contributor

flying-sheep commented Nov 17, 2018

i added the brackets, all done!

@flying-sheep flying-sheep force-pushed the flying-sheep:peek-slice branch from d28442b to 74be17d Nov 17, 2018

@dragostis

LGTM apart from small fix!

Show resolved Hide resolved vm/tests/grammar.rs
@dragostis

This comment has been minimized.

Collaborator

dragostis commented Nov 19, 2018

bors r+

@bors

This comment has been minimized.

Contributor

bors bot commented Nov 19, 2018

👎 Rejected by code reviews

@dragostis

This comment has been minimized.

Collaborator

dragostis commented Nov 19, 2018

bors r+

@bors

This comment has been minimized.

Contributor

bors bot commented Nov 19, 2018

Merge conflict

@flying-sheep flying-sheep force-pushed the flying-sheep:peek-slice branch from a5c6f6e to 9a63e1b Nov 19, 2018

@dragostis

This comment has been minimized.

Collaborator

dragostis commented Nov 19, 2018

bors r+

bors bot added a commit that referenced this pull request Nov 19, 2018

Merge #334
334: PEEK[start..end] r=dragostis a=flying-sheep

fixes #329

Co-authored-by: Philipp A <flying-sheep@web.de>
Co-authored-by: Dragoș Tiselice <dragostiselice@gmail.com>
@bors

This comment has been minimized.

Contributor

bors bot commented Nov 19, 2018

@bors bors bot merged commit 7bf4ed6 into pest-parser:master Nov 19, 2018

2 checks passed

bors Build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@flying-sheep flying-sheep deleted the flying-sheep:peek-slice branch Nov 19, 2018

@flying-sheep

This comment has been minimized.

Contributor

flying-sheep commented Nov 19, 2018

Yay 🥳

Too bad it wasn't a squash merge, that's some messy series of commits 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment