Giter VIP home page Giter VIP logo

Comments (6)

kevinmehall avatar kevinmehall commented on June 3, 2024

The easier way to use rust-peg with Cargo is to use it as a syntax extension. It makes rustc compile the grammar when it compiles the crate. I should probably update the readme with those instructions, since it's the primary way to use rust-peg at this point...

Use

#[phase(plugin)] extern crate peg_syntax_ext;
peg_file! grammar("yourfile.rustpeg")
grammar::rule(source)

example

However, syntax extensions won't be enabled in Rust 1.0. They've promised giving Cargo the ability to preprocess source like this, but I haven't seen documentation on that yet.

from rust-peg.

benjreinhart avatar benjreinhart commented on June 3, 2024

The closest thing I saw was that cargo supports having a build script but this doesn't do me any good in this case if I can't access executables from crates.

Even if they weren't removing that in 1.0, I'd prefer to have a separate file for my grammar.

Anyways, thanks for the response. I'll figure something out.

from rust-peg.

kevinmehall avatar kevinmehall commented on June 3, 2024

The closest thing I saw was that cargo supports having a build script but this doesn't do me any good in this case if I can't access executables from crates.

If the build script can access libraries from crates, we could add a library to rust-peg that would be convenient to call from the build script.

Even if they weren't removing that in 1.0, I'd prefer to have a separate file for my grammar.

With the syntax extension, you can have the grammar either an inline string with peg or an external file with peg_file.

from rust-peg.

benjreinhart avatar benjreinhart commented on June 3, 2024

Ohhh wow, I missed the peg_file!.

I still would have to say that I personally like having that taken care of and generated outside of my other source code files, but this is a step in the right direction for me. However, it sounds like syntax extensions are going away.

Thanks!

from rust-peg.

kevinmehall avatar kevinmehall commented on June 3, 2024

They're not going away in the nightly builds; they're just being disabled in 1.0 release builds because the APIs they need won't be considered stable with the 1.0 release.

from rust-peg.

kevinmehall avatar kevinmehall commented on June 3, 2024

Closing in favor of #121

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.