mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 00:02:26 +00:00
feat: custom node (#138)
* feat: custom node * add zen template, expose $nodes and $root * add custom handler to go and nodejs * add support for python, improve bindings, add error to zen template * fix: correct binding exports for nodejs and python * fix benchmark * improve rust api, trim template in zen templates * update cargo action * update expression version * compile action * fix action format
This commit is contained in:
@@ -13,6 +13,7 @@ pub enum Node<'a> {
|
||||
Array(&'a [&'a Node<'a>]),
|
||||
Identifier(&'a str),
|
||||
Closure(&'a Node<'a>),
|
||||
Root,
|
||||
Member {
|
||||
node: &'a Node<'a>,
|
||||
property: &'a Node<'a>,
|
||||
|
||||
@@ -280,7 +280,11 @@ impl<'arena, 'token_ref, Flavor> Parser<'arena, 'token_ref, Flavor> {
|
||||
self.next()?;
|
||||
let current_token = self.current();
|
||||
if current_token.kind != TokenKind::Bracket(Bracket::LeftParenthesis) {
|
||||
let identifier_node = self.node(Node::Identifier(identifier_token.value));
|
||||
let identifier_node = match identifier_token.kind {
|
||||
TokenKind::Identifier(Identifier::RootReference) => self.node(Node::Root),
|
||||
_ => self.node(Node::Identifier(identifier_token.value)),
|
||||
};
|
||||
|
||||
return self
|
||||
.with_postfix(identifier_node, expression_parser)
|
||||
.map(Some);
|
||||
|
||||
@@ -214,6 +214,7 @@ impl From<&Node<'_>> for UnaryNodeBehaviour {
|
||||
|
||||
match value {
|
||||
Node::Null => CompareWithReference(Equal),
|
||||
Node::Root => CompareWithReference(Equal),
|
||||
Node::Bool(_) => CompareWithReference(Equal),
|
||||
Node::Number(_) => CompareWithReference(Equal),
|
||||
Node::String(_) => CompareWithReference(Equal),
|
||||
|
||||
Reference in New Issue
Block a user