lisp_parser->tag = tag;
lisp_parser->last_set_ranges = Qnil;
lisp_parser->embed_level = Qnil;
- lisp_parser->parent_node = Qnil;
lisp_parser->buffer = buffer;
lisp_parser->parser = parser;
lisp_parser->tree = tree;
return level;
}
-DEFUN ("treesit-parser-parent-node",
- Ftreesit_parser_parent_node, Streesit_parser_parent_node,
- 1, 1, 0,
- doc: /* Return PARSER's parent node, if one exists.
-
-Only embeded local parsers can have parent node. When Emacs uses a node
-in the host parser to create this local parser, that node is considered
-the parent node of the local parser. */)
- (Lisp_Object parser)
-{
- treesit_check_parser (parser);
- return XTS_PARSER (parser)->parent_node;
-}
-
-DEFUN ("treesit-parser-set-parent-node",
- Ftreesit_parser_set_parent_node, Streesit_parser_set_parent_node,
- 2, 2, 0,
- doc: /* Make NODE be the parent node of PARSER. */)
- (Lisp_Object parser, Lisp_Object node)
-{
- treesit_check_parser (parser);
- if (!NILP (node))
- CHECK_TS_NODE (node);
-
- XTS_PARSER (parser)->parent_node = node;
- return node;
-}
-
-
/* Return true if PARSER is not deleted and its buffer is live. */
static bool
treesit_parser_live_p (Lisp_Object parser)
defsubr (&Streesit_parser_tag);
defsubr (&Streesit_parser_embed_level);
defsubr (&Streesit_parser_set_embed_level);
- defsubr (&Streesit_parser_parent_node);
- defsubr (&Streesit_parser_set_parent_node);
defsubr (&Streesit_parser_root_node);
defsubr (&Streesit_parse_string);
friends) haven't touched this parser yet, and this parser isn't
part of the embed parser tree. */
Lisp_Object embed_level;
- /* Some comments: Technically you could calculate embed_level by
- following parent_node, but parent_node might be outdated so it's a
- good idea to record embed_level separately. Embed_level and
- parent_node could have been implemented as "parser properties" with
- an obarray, but ultimately I think two explicit fields helps
- documentation better and it's not clear to me that a property list
- for a parser will be useful beyond this. And we can always convert
- these to properties later, but not vice versa. */
- /* When an embedded parser is created, it's usually based on a node in
- the host parser. This field saves that node so it's possible to
- climb up and out of the embedded parser into the host parser. Note
- that the range of the embedded parser doesn't have to match that of
- the parent node. */
- Lisp_Object parent_node;
/* The buffer associated with this parser. */
Lisp_Object buffer;
/* The pointer to the tree-sitter parser. Never NULL. */