Comments (2)
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.
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)
- Consider types - integers and booleans at least HOT 2
- directory module doesn't -p HOT 5
- Allow modules to setup output variables HOT 1
- Allow function-calls ..
- Package installation order HOT 1
- Update the module API
- Negative numbers aren't parsed
- broke lately HOT 7
- how do I install a specific version? HOT 2
- Circular dependency - strange result HOT 8
- Non-obvious variable assignment issues HOT 1
- It shouldn't be necessary to separate module from "{"
- prompt for user input? HOT 1
- Escape single quotes in commands? HOT 5
- contains doesn't work on cat'd file HOT 3
- Create file if not exists? HOT 3
- Add --version flag
- Allow search & replace inside existing files
- Add parameter to shell-module to force the use of a shell
- Add mysql module HOT 3
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 marionette.