DanSimon / peruse

A parser-combinator library for Rust
MIT License
45 stars 5 forks source link

error: `OrParser` does not name a structure #2

Open bjadamson opened 9 years ago

bjadamson commented 9 years ago

Hey, I'm getting this error when trying to combine my own parser using any of the macros, do you have any ideas on maybe I'm doing incorrectly?

#[phase(plugin)] 
extern crate peruse;
extern crate peruse;
use self::peruse::parsers::literal;

fn mm() {
    let dddd = or!(literal(A), literal(B));
}

The full error I get from trying to compile this:

badamson@406c8f2a3866 ~/D/r/myproject-rs> cargo build --verbose
       Fresh peruse v0.1.0 (https://github.com/DanSimon/peruse.git#5915d6fa)
   Compiling myproject-rs v0.0.1 (file:///Users/badamson/Documents/rust/myproject-rs)
     Running `rustc /Users/badamson/Documents/rust/myproject-rs/src/main.rs --crate-name myproject-rs --crate-type bin -g --out-dir /Users/badamson/Documents/rust/myproject-rs/target --dep-info /Users/badamson/Documents/rust/myproject-rs/target/.fingerprint/myproject-rs-030fbdb89d7c4fb3/dep-bin-myproject-rs -L /Users/badamson/Documents/rust/myproject-rs/target -L /Users/badamson/Documents/rust/myproject-rs/target/deps --extern peruse=/Users/badamson/Documents/rust/myproject-rs/target/deps/libperuse-1cb3ff65831a86b2.rlib`
<peruse macros>:3:5: 3:13 error: `OrParser` does not name a structure
<peruse macros>:3     OrParser{
                      ^~~~~~~~
<peruse macros>:1:1: 18:2 note: in expansion of or!
/Users/badamson/Documents/rust/myproject-rs/src/lexer/lexer.rs:43:13: 43:41 note: expansion site
error: aborting due to previous error
Could not compile `myproject-rs`.

Caused by:
  Process didn't exit successfully: `rustc /Users/badamson/Documents/rust/myproject-rs/src/main.rs --crate-name myproject-rs --crate-type bin -g --out-dir /Users/badamson/Documents/rust/myproject-rs/target --dep-info /Users/badamson/Documents/rust/myproject-rs/target/.fingerprint/myproject-rs-030fbdb89d7c4fb3/dep-bin-myproject-rs -L /Users/badamson/Documents/rust/myproject-rs/target -L /Users/badamson/Documents/rust/myproject-rs/target/deps --extern peruse=/Users/badamson/Documents/rust/myproject-rs/target/deps/libperuse-1cb3ff65831a86b2.rlib` (status=101)
bjadamson commented 9 years ago
badamson@406c8f2a3866 ~/D/r/myproject-rs> rustc -v
rustc 0.13.0-nightly (d91a015ab 2014-11-14 23:37:27 +0000)
DanSimon commented 9 years ago

Yeah that's a bug with the macros not properly namespacing the parsers. I'll have that fixed shortly.

bjadamson commented 9 years ago

Oh, okay. Thanks, is there any way to work around it in the meantime?

DanSimon commented 9 years ago

I just pushed a fix to master that should resolve the issue.

bjadamson commented 9 years ago

Ok I pulled in your patch (thanks btw!) and got this:

let p = or!(literal(A), literal(B));
<peruse macros>:3:5: 3:11 error: failed to resolve. Did you mean `self::peruse::parsers`?
<peruse macros>:3     ::peruse::parsers::OrParser{
                      ^~~~~~
<peruse macros>:1:1: 18:2 note: in expansion of or!
/Users/badamson/Documents/rust/myproject-rs/src/lexer/lexer.rs:38:11: 38:39 note: expansion site
<peruse macros>:3:5: 3:32 error: `peruse::parsers::OrParser` does not name a structure
<peruse macros>:3     ::peruse::parsers::OrParser{
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<peruse macros>:1:1: 18:2 note: in expansion of or!
/Users/badamson/Documents/rust/myproject-rs/src/lexer/lexer.rs:38:11: 38:39 note: expansion site
error: aborting due to 2 previous errors
Could not compile `myproject-rs`.
DanSimon commented 9 years ago

Very odd, I'm not able to reproduce this error. Try doing cargo clean and then cargo build. I've run into issues before when updating without doing a clean.

bjadamson commented 9 years ago

Tried it, no dice! I have this though, could you try it on your box? http://is.gd/ILt8I1

DanSimon commented 9 years ago

Weird, that works fine for me. The only changes I had to make to your code were add #![feature(plugin)] at the top and a main fn. Also my Cargo.toml looks like:

[package]

name = "test"
version = "0.0.1"
authors = [ "Your name <you@example.com>" ]

[[bin]]

name = "test"
path = "src/test.rs"

[dependencies.peruse]

git = "https://github.com/DanSimon/peruse.git"

Also just a heads up, the latest Rust nightly just broke peruse because of the new enum namespacing, I'll have that fixed soon fixed.