Code Monkey home page Code Monkey logo

Comments (7)

nikomatsakis avatar nikomatsakis commented on May 22, 2024

This is already supported, in fact. You do it by adding the type parameters to the grammar declaration, like so:

grammar<F:Factory>;

from lalrpop.

nikomatsakis avatar nikomatsakis commented on May 22, 2024

Ah, actually, I think bounds have to be written as where clauses:

grammar<F> where F: Factory;

Anyway, let me know how that works for you. I don't know that I've tested this functionality very thoroughly, as I myself have not yet had a user for it.

from lalrpop.

ihrwein avatar ihrwein commented on May 22, 2024

I began to port my grammar from rust-peg to Lalrpop. So far I hit the following problems;

  1. The 'input lifetime comes after the F type parameter.
  pub fn parse_Term<
      F,
      'input,
  >(
      input: &'input str,
  ) -> Result<i32, __ParseError<usize,(usize, &'input str),()>> where
    F: ParserFactory,
  {...}

This is true not just for functions, but for impls:

impl<F, 'input, > __ToTriple<F, 'input, > for Result<(usize, (usize, &'input str), usize),()> {...}
  1. The generic type parameters are not propagated:

    __state0(...)
    

    instead of

    __state0::<F>(...)
    

from lalrpop.

nikomatsakis avatar nikomatsakis commented on May 22, 2024

OK, I think I fixed that problem, thanks for the report!

from lalrpop.

nikomatsakis avatar nikomatsakis commented on May 22, 2024

(You'll have to use the git version for now though.)

from lalrpop.

nikomatsakis avatar nikomatsakis commented on May 22, 2024

Note the new test case:

https://github.com/nikomatsakis/lalrpop/blob/ae027da57edd1b52ebd935e1af0011b5c683ecea/lalrpop-test/src/expr_generic.lalrpop

from lalrpop.

ihrwein avatar ihrwein commented on May 22, 2024

Thanks!

from lalrpop.

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.