-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Make the project generalized #57
Comments
@Naddiseo That's a great point. I've been thinking there would be a lot of value in allowing users of the library to instantiate their own copy of the type system, so that when (for example) Recast adds the custom Something like this? var types = require("ast-types").fork(/* pass true to start fresh? */);
types.registerDefs("ast-types/def/core.js");
types.registerDefs("./custom/defs");
types.registerDefs("./more/defs"); |
That would work. If the files under var types = require('ast-types');
/*
languages.ECMA is defined as an array containing what is currently in `def`
*/
var langs = types.languages;
types.registerDefs(langs.ECMA) This would allow ast-types to possible build up defs of other language to aid other parser builders (or a separate repository for language defs). Some other things that need to be thought about
|
Another thing that I've found using the builders is that I want to be able to pass in the current location. I think one of the arguments in the builder function is a |
Actually, that I may have a look tomorrow to see if there's an easy way to accomplish this. Do you have any ideas where to start? |
The latest recast is using a different parser version which seems to have lost support for the `File` AST node.
I still think this is a great idea, by the way. Hope to work on it for the next minor version (0.8.0). |
This is a temporary workaround for benjamn/recast#206 until something along the lines of #57 is implemented.
bump! Personally, I think the core components should be split out into another library ( I like the syntax, but I think you should pass actual modules (or a custom function) instead of strings. The problem with strings would be accurately resolving them (especially if you do split into a separate module): var types = require('ast-types-base')(
require('ast-types/def/core'),
require('./myCustomDefs'),
function(types) {
types.def('MyType')
//...
}
); I do like the This would be the equivalent, less verbose version of above: require('ast-types').fork(
'core',
require('./myCustomDefs'),
function(types) {
types.def('MyType')
//...
}
); One problem with the |
@benjamn - anything I can do to move this forward? |
Should probably be closed since #145 was merged nearly 2.5 years (!!!) ago. |
Agreed, though I should mention the move to TypeScript (#300) has complicated this story, since the generated TypeScript declarations are fundamentally less modular/dynamic than the forking system. |
This is a temporary workaround for benjamn/recast#206 until something along the lines of benjamn/ast-types#57 is implemented.
This is a temporary workaround for benjamn/recast#206 until something along the lines of benjamn/ast-types#57 is implemented.
This is a temporary workaround for benjamn/recast#206 until something along the lines of benjamn/ast-types#57 is implemented.
Currently, this project is geared towards ES, but since the interface is so nice for building asts, I'd like to use it in other parsing projects.
Would it be possible to make the project more generalized so that it doesn't load all the types in
def/*
unless requested?The text was updated successfully, but these errors were encountered: