Comments (19)
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.
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.
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.
An alternative is to try getting things to work with syntex.
from rust-peg.
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.
My pull request makes the generated code build with the nightly: #78
from rust-peg.
I've been meaning to look at syntex as well, but haven't had a chance to yet.
from rust-peg.
Are there plans to make this crate usable with Rust stable?
from rust-peg.
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.
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.
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.
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.
@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.
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.
That's a shame, i have no idea how those extensions work, but running on stable would have been very neat :(
from rust-peg.
FWIW, I've stopped working on this, don't have time for it :(
from rust-peg.
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.
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.
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)
- Using generics on grammar level HOT 2
- request: provide more helpful context in parse error messages HOT 1
- Stable sort for expected set entries in error messages HOT 2
- warn on missing .PHONY entry for common target names HOT 1
- feature request: a way to query the current line number during parsing HOT 5
- general question about thread safety HOT 1
- Use tracing rather than println?
- Binding captured strings? HOT 6
- help with misleading expected set HOT 2
- How do I escape the dot character in [^ pat]? HOT 1
- rustc warning about unused imports HOT 1
- Make the TokenStream wrappers used internally available
- How to escape the " HOT 3
- Mutual recursion with `#[cache_left_rec]` fails
- Case-insensitive literal matches throw off error position HOT 6
- `{? Err("x") }` should not be considered nullable for infinite loop check
- the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type HOT 2
- Automatic whitespace handling? HOT 1
- "rule" but not when HOT 2
- Error recovery when using `precedence!` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-peg.