Code Monkey home page Code Monkey logo

Comments (19)

nejucomo avatar nejucomo commented on May 22, 2024

It's not clear to me which features are unstable from the rustc output, so I'm going to file a bug with rustc.

from rust-peg.

kevinmehall avatar kevinmehall commented on May 22, 2024

rust-peg generates code with the libsyntax AST API (even when not using the syntax extension), so it will not work on builds which feature-gate that. However, I would like to see if it would be possible for the generated output code to use only 1.0 stable features.

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

If you could generate stable code, would you then add some way to save the generated code to a file?

Have you looked at this issue recently? 1.0 will be out soon, and I would like my project that uses rust-peg to be able to build with it.

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

An alternative is to try getting things to work with syntex.

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

I also just saw you can use peg as a standalone code generator, so scratch one of my previous comments. I'll take a look in the near future to see what needs to be done to use only stable features in the generated code.

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

My pull request makes the generated code build with the nightly: #78

from rust-peg.

kevinmehall avatar kevinmehall commented on May 22, 2024

I've been meaning to look at syntex as well, but haven't had a chance to yet.

from rust-peg.

buster avatar buster commented on May 22, 2024

Are there plans to make this crate usable with Rust stable?

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

You can use the standalone peg tool, which generates stable code.

On Sun, May 17, 2015, 3:19 PM buster [email protected] wrote:

Are there plans to make this crate usable with Rust stable?


Reply to this email directly or view it on GitHub
#72 (comment)
.

from rust-peg.

buster avatar buster commented on May 22, 2024

Yes, but rust-peg offers the ability to use macros (which i do) and having rust stable and rust nightly both installed and keeping in sync is not very comfortable... Atleast with a rust-peg on "stable" i know this project will still work in a year or two, not so much with "nightly" :(

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

The only way to make this work with stable Rust is to port it to the syntex library. I've heard that this drastically increases build times, and I've never used this library so I don't know how complete it is.

There really is no benefit of the macros over the standalone tools other than Cargo automatically building the files on a change. You can get this same behavior by using a build script, a makefile, or some other script.

from rust-peg.

untitaker avatar untitaker commented on May 22, 2024

Syntex is a fork of libsyntax. I'm taking a stab at a port: The API is very similar but I'm kinda stumped ATM anyway.

from rust-peg.

gsingh93 avatar gsingh93 commented on May 22, 2024

@untitaker I'm not sure if it actually was a proper "fork", as I had to ask the maintainer to add some missing methods. In any case, feel free to try it out, if you need help figuring out how syntax extensions work, I have a nice post here.

from rust-peg.

untitaker avatar untitaker commented on May 22, 2024

I've run against a brick wall with the port: The registration of quote_*! macros is commented out syntex, and there doesn't seem to be an obvious way to use e.g. function calls instead.

Uncommenting those macro definitions breaks more things.

from rust-peg.

buster avatar buster commented on May 22, 2024

That's a shame, i have no idea how those extensions work, but running on stable would have been very neat :(

from rust-peg.

untitaker avatar untitaker commented on May 22, 2024

FWIW, I've stopped working on this, don't have time for it :(

from rust-peg.

nejucomo avatar nejucomo commented on May 22, 2024

I see that the README now explains how to use the standalone peg tool. How do I build and install the tool with rust 1.0?

I tried simply crate build --verbose in revision 76cfa35, but that fails as follows:

$ cargo build --verbose
   Compiling peg v0.3.0 (file:///home/n/3p/github.com/kevinmehall/rust-peg)
     Running `rustc src/peg_syntax_ext.rs --crate-name peg_syntax_ext --crate-type dylib -C prefer-dynamic -g --out-dir /home/n/3p/github.com/kevinmehall/rust-peg/target/debug --emit=dep-info,link -L dependency=/home/n/3p/github.com/kevinmehall/rust-peg/target/debug -L dependency=/home/n/3p/github.com/kevinmehall/rust-peg/target/debug/deps`
src/translate.rs:288:74: 288:84 error: type `&collections::string::String` does not implement any method in scope named `to_tokens`
src/translate.rs:288                    println!("[PEG_TRACE] Attempting to match rule {} at {}:{} (pos {})", $rule_name, line, col, pos);
                                                                                                              ^~~~~~~~~~
note: in expansion of quote_expr!
src/translate.rs:286:3: 298:5 note: expansion site
src/translate.rs:294:80: 294:90 error: type `&collections::string::String` does not implement any method in scope named `to_tokens`
src/translate.rs:294                            Matched(_, _) => println!("[PEG_TRACE] Matched rule {} at {}:{} (pos {})", $rule_name, line, col, pos),
                                                                                                                           ^~~~~~~~~~
note: in expansion of quote_expr!
src/translate.rs:286:3: 298:5 note: expansion site
src/translate.rs:295:81: 295:91 error: type `&collections::string::String` does not implement any method in scope named `to_tokens`
src/translate.rs:295                            Failed => println!("[PEG_TRACE] Failed to match rule {} at {}:{} (pos {})", $rule_name, line, col, pos)
                                                                                                                            ^~~~~~~~~~
note: in expansion of quote_expr!
src/translate.rs:286:3: 298:5 note: expansion site
src/translate.rs:451:92: 451:102 error: type `&collections::string::String` does not implement any method in scope named `to_tokens`
src/translate.rs:451                                                                    &Matched(..) => println!("[PEG_TRACE] Cached match of rule {} at {}:{} (pos {})", $rule_name, line, col, pos),
                                                                                                                                                                          ^~~~~~~~~~
note: in expansion of quote_expr!
src/translate.rs:447:7: 457:9 note: expansion site
src/translate.rs:452:86: 452:96 error: type `&collections::string::String` does not implement any method in scope named `to_tokens`
src/translate.rs:452                                                                    &Failed => println!("[PEG_TRACE] Cached fail of rule {} at {}:{} (pos {})", $rule_name, line, col, pos),
                                                                                                                                                                    ^~~~~~~~~~
note: in expansion of quote_expr!
src/translate.rs:447:7: 457:9 note: expansion site
error: aborting due to 5 previous errors
Could not compile `peg`.

Caused by:
  Process didn't exit successfully: `rustc src/peg_syntax_ext.rs --crate-name peg_syntax_ext --crate-type dylib -C prefer-dynamic -g --out-dir /home/n/3p/github.com/kevinmehall/rust-peg/target/debug --emit=dep-info,link -L dependency=/home/n/3p/github.com/kevinmehall/rust-peg/target/debug -L dependency=/home/n/3p/github.com/kevinmehall/rust-peg/target/debug/deps` (exit code: 101)
$ rustc --version
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)

from rust-peg.

kevinmehall avatar kevinmehall commented on May 22, 2024

You still have to build the peg program with a nightly, but you can use the code it generates with 1.0.

from rust-peg.

kevinmehall avatar kevinmehall commented on May 22, 2024

Closing in favor of using a build script (#121), which I'm starting on the next branch (to become 0.4)

from rust-peg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.