Compare commits

..

No commits in common. "master" and "v5.0.0" have entirely different histories.

7 changed files with 7 additions and 35 deletions

View File

@ -1,11 +1,3 @@
## v5.1.0
### New Features
- Add a `node_id()` accessor to the C++ and D tree node handle types, for node
identity comparison. This matches the existing `p_node_id()` macro (C) and
`node_id()` method (Rust).
## v5.0.0 ## v5.0.0
### New Features ### New Features

View File

@ -149,12 +149,6 @@ public struct <%= @grammar.tree_prefix %>Token<%= @grammar.tree_suffix %>
return __id != 0u; return __id != 0u;
} }
/** Return the node ID (for identity comparison). */
@property <%= @grammar.prefix %>node_id_t node_id()
{
return __id;
}
/** Access the underlying node record (token, pvalue, and user fields). */ /** Access the underlying node record (token, pvalue, and user fields). */
@property ref <%= @grammar.prefix %>node_data_t __node() @property ref <%= @grammar.prefix %>node_data_t __node()
{ {
@ -183,12 +177,6 @@ public struct <%= @grammar.tree_prefix %><%= rule_set.name %><%= @grammar.tree_s
return __id != 0u; return __id != 0u;
} }
/** Return the node ID (for identity comparison). */
@property <%= @grammar.prefix %>node_id_t node_id()
{
return __id;
}
/** Text position of the first code point spanned by this node. */ /** Text position of the first code point spanned by this node. */
@property <%= @grammar.prefix %>position_t position() @property <%= @grammar.prefix %>position_t position()
{ {

View File

@ -349,11 +349,10 @@ accessors on a node handle:
for token payload and user fields), and `p_node_id(node)` (for identity for token payload and user fields), and `p_node_id(node)` (for identity
comparison). comparison).
* C++: handle methods called with `()`, e.g. `node.field()`, `node.valid()`, * C++: handle methods called with `()`, e.g. `node.field()`, `node.valid()`,
`node.position()`, `node.token()`, `node.pvalue()`, `node.data()`, and `node.position()`, `node.token()`, `node.pvalue()`, and `node.data()`. The
`node.node_id()` (for identity comparison). The C-style functions and C-style functions and macros above are also available.
macros above are also available.
* D: `@property` accessors, e.g. `node.field`, `node.valid`, `node.position`, * D: `@property` accessors, e.g. `node.field`, `node.valid`, `node.position`,
`node.token`, `node.pvalue`, and `node.node_id` (for identity comparison). `node.token`, `node.pvalue`.
* Rust: handle methods called with `()`, e.g. `node.field()`, `node.valid()`, * Rust: handle methods called with `()`, e.g. `node.field()`, `node.valid()`,
`node.position()`, `node.end_position()`, `node.n_fields()`, `node.position()`, `node.end_position()`, `node.n_fields()`,
`node.token()`, `node.pvalue()`, `node.data()` (a reference to the node `node.token()`, `node.pvalue()`, `node.data()` (a reference to the node

View File

@ -696,10 +696,9 @@ class Propane
end end
# Generate the C++ tree node handle class declarations for the header. # Generate the C++ tree node handle class declarations for the header.
# Only valid() and node_id() are defined inline; every other method # Only valid() is defined inline; every other method dereferences the
# dereferences the context, which is still an incomplete type here, so # context, which is still an incomplete type here, so those are declared
# those are declared and defined out of line once the context is # and defined out of line once the context is complete.
# complete.
def cpp_tree_handle_types_header def cpp_tree_handle_types_header
p = @grammar.prefix p = @grammar.prefix
out = [] out = []
@ -712,7 +711,6 @@ class Propane
out << " #{p}context_t * __context;" out << " #{p}context_t * __context;"
out << " #{p}node_id_t __id;" out << " #{p}node_id_t __id;"
out << " bool valid() const { return __id != 0u; }" out << " bool valid() const { return __id != 0u; }"
out << " #{p}node_id_t node_id() const { return __id; }"
out << " #{p}node_data_t * data() const;" out << " #{p}node_data_t * data() const;"
out << " #{p}position_t position() const;" out << " #{p}position_t position() const;"
out << " #{p}position_t end_position() const;" out << " #{p}position_t end_position() const;"
@ -728,7 +726,6 @@ class Propane
out << " #{p}context_t * __context;" out << " #{p}context_t * __context;"
out << " #{p}node_id_t __id;" out << " #{p}node_id_t __id;"
out << " bool valid() const { return __id != 0u; }" out << " bool valid() const { return __id != 0u; }"
out << " #{p}node_id_t node_id() const { return __id; }"
out << " #{p}node_data_t * data() const;" out << " #{p}node_data_t * data() const;"
out << " #{p}position_t position() const;" out << " #{p}position_t position() const;"
out << " #{p}position_t end_position() const;" out << " #{p}position_t end_position() const;"

View File

@ -1,3 +1,3 @@
class Propane class Propane
VERSION = "5.1.0" VERSION = "5.0.0"
end end

View File

@ -31,7 +31,6 @@ unittest
assert(start.pR3.valid); assert(start.pR3.valid);
assert(start.pR.valid); assert(start.pR.valid);
assert(start.pR == start.pR3); assert(start.pR == start.pR3);
assert_eq(start.pR.node_id, start.pR3.node_id);
assert_eq(TOKEN_c, start.pR.pToken1.token); assert_eq(TOKEN_c, start.pR.pToken1.token);
p_context_delete(context); p_context_delete(context);

View File

@ -13,8 +13,6 @@ int main()
assert(start.pItems1().valid()); assert(start.pItems1().valid());
assert(start.pItems().valid()); assert(start.pItems().valid());
Items items = start.pItems(); Items items = start.pItems();
assert_ne(0u, items.node_id());
assert_eq(start.pItems().node_id(), items.node_id());
assert(items.pItem().valid()); assert(items.pItem().valid());
assert(items.pItem().pToken1().valid()); assert(items.pItem().pToken1().valid());
assert_eq(TOKEN_a, items.pItem().pToken1().token()); assert_eq(TOKEN_a, items.pItem().pToken1().token());
@ -42,7 +40,6 @@ int main()
assert_eq(P_SUCCESS, p_parse(context)); assert_eq(P_SUCCESS, p_parse(context));
start = p_result(context); start = p_result(context);
assert(!start.pItems().valid()); assert(!start.pItems().valid());
assert_eq(0u, start.pItems().node_id());
p_context_delete(context); p_context_delete(context);