Giter VIP home page Giter VIP logo

Comments (2)

skx avatar skx commented on May 27, 2024 1

So I'd opened #58 for this, but it turns out that there were too many issues so that was closed.

The new approach is to convert our implementation to something more akin to a tree-walking interpreter:

  • The parser will not expand backticks, or file-inclusion.
  • Instead the parser will return an AST comprised of three distinct node-types:
    • File inclusion.
    • Variable assignments.
    • Actual rules.

This means that the evaluator will not solely be passed an array of "Rule" objects, instead it will receive the AST and walk that, switching on node-types:

  • Assignments will result in environment-updates.
  • Inclusions will result in recursion
  • Rules will be processed as they should be.

This will be a significant change in terms of the implementation, however the steps are simple and well-known and the functionality should be unchanged...

from marionette.

skx avatar skx commented on May 27, 2024

That's good feedback, thank-you!

In terms of the parser-changes the first suggestion - add an if/unless clause to the include statement - would be easiest to implement.

I'd be happy to add that once I've finished up the user module in #56.

EDIT: Now I think about it, this might be harder than expected. At parse-time the environment isn't really populated. Conditionals might refer to things that aren't setup yet. Consider:

let h = `hostname`
include "local" if equal( h, "frodo.local" );

To handle that in the parser means interpreting assignments, not just expanding text.

I guess a naive approach would be to include ALWAYS, but add a secret "conditional" statement to all rules contained within an included file. Then evaluate that if present.

That keeps execution and parsing as distinct steps. But it's a bit horrid.

I'll think on it for a day or two.

from marionette.

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.