-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Construct an AST programmatically in 0.20 #350
Comments
We haven't taken the time to update to latest comrak, but I think one of my teammate got things working by generating dummy positions (with zeros everywhere, probably). FWIW, in Nickel, the position in the AST is more or less isomorphic to an option |
I'd be happy to make it easier to supply zero |
For the record, we finally got back tho this and simply used this small helper (in tweag/nickel#1961): fn ast_node<'a>(val: NodeValue) -> AstNode<'a> {
// comrak allows for ast nodes to be tagged with source location. This location
// isn't need for rendering; it seems to be mainly for plugins to use. Since our
// markdown is generated anyway, we just stick in a dummy value.
let pos = comrak::nodes::LineColumn::from((0, 0));
AstNode::new(std::cell::RefCell::new(Ast::new(val, pos)))
} I guess a |
I've merged the old/new |
Hello,
We use comrak for the Nickel configuration language, in order to parse in-code markdown documentation and assemble it into one markdown file (think of generating the documentation associated to a module).
We are currently using v0.17, and were constructing nodes programmatically like:
However, as of the latest version,
AstNode::from<NodeValue>
doesn't exist anymore. We need to provideAstNode
with anAst
, which is itself a struct withNodeValue
and aSourcepos
. However it seemsAst
requires both, including theSourcepos
. Alas, I don't have anySourcepos
, because the node isn't parsed from source but constructed programmatically.What would be the idiomatic equivalent with comrak v0.20 ?
The text was updated successfully, but these errors were encountered: