Giter Club home page Giter Club logo

Comments (9)

Hywan avatar Hywan commented on May 17, 2024

Hello :-),

During my PhD thesis, I mentionned this feature and addressing it is a very challenging task. You don't only import rules here, you are extending them or even worse: You are also overriding them. This is difficult. Hardly difficult. Extending would be difficult, refining would be much more difficult, but overriding… damn. This is too error-prone because: What if you are depending on a grammar that radically changes? Your grammar will be broken. We have to detect this, and this is very difficult.

from compiler.

Hywan avatar Hywan commented on May 17, 2024

So, it would be 👎 for me regarding the amount of work, but, let's the community decides. If this is something the community asks, I could work on it. Don't expect this feature to be availble in a week. Just the formalization could take months.

from compiler.

jubianchi avatar jubianchi commented on May 17, 2024

@Hywan fine ;) I already reverted my code in tml.

TBH I'm not aware of the problems but if you can explain them or give me a link to something giving more clue, I would be glad to work on this.

from compiler.

CircleCode avatar CircleCode commented on May 17, 2024

I really love the idea, but I understand how hard this could be.
Maybe some mitigation could be some kind of
%import: path/to/file.pp:%token|#rule
that would just work like computer-assisted copy paste (are you thinking about traits?)

This way, no overriding, no extending, and no huge copy paste, only a big list of imports, and some custom rules.

What do you think about this?

Note: I understand this would lead to pp files with a lot of imports and only some custom rules, making files much much bigger than a full gramma import, but the idea here is not to reduce grammar length, only to avoid huge parts to be duplicated.

On the parsing side, I think (but I do not know the compiler internals) that this does not change radically the way compiler works

from compiler.

jubianchi avatar jubianchi commented on May 17, 2024

@CircleCode I was also thinking of %importing only tokens or only rules but would propose it in a second time, but I was probably wrong.

A first step could be to support on token imports but we still have to take care of some things: if the imported grammar changes one of its token regex, the importing grammar could break.

from compiler.

CircleCode avatar CircleCode commented on May 17, 2024

@jubianchi right, but the break would be easy to detect since once the replacement (aka import) has been done, the grammar should be good on its own

from compiler.

stephpy avatar stephpy commented on May 17, 2024

It's really interesting, but I understand @Hywan, it seems hard ...

  • We could assume than %import% does like an include in PHP, if you override tokens, rules, ... the 2nd occurence override the 1st.
  • We could use %import% to load in background, then use xx_token; use yy_token; etc..., It would be more flexible but harder to implement for client.

from compiler.

1e1 avatar 1e1 commented on May 17, 2024

Sorry for my dummy question.
Before building the AST, a file is like a key-value of "lines"?
Can we rebuild a cached .pp which is a merge of both files.

(I'm always curious about the context leading to write a new grammar).

from compiler.

Hywan avatar Hywan commented on May 17, 2024

@1e1 I don't understand your comment. A grammar is a set of lexemes and a set of rules. This is not simply “merging” them. A grammar describes a syntax. Merging syntax and still be coherent or detect conflict is not simple. Actually, I don't know if this is even automatically done.

from compiler.

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.