1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
// -*- coding: utf-8 -*-
// ------------------------------------------------------------------------------------------------
// Copyright © 2021, tree-sitter authors.
// Licensed under either of Apache License, Version 2.0, or MIT license, at your option.
// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details.
// ------------------------------------------------------------------------------------------------
//! This section defines the standard library of functions available to graph DSL files.
//!
//! Note that the process that is executing the graph DSL file has control over which function it
//! provides. Most of the time, you will have (at least) the functions defined here available.
//! There might be additional functions available, and in rare cases, there might be a completely
//! different set of functions available!
//!
//! # General functions
//!
//! ## `eq`
//!
//! Check if values are equal.
//!
//! - Input parameters: two values
//! - Output value: a boolean indicating whether the values are equal or not
//!
//! The compared values must be of the same type. Null values are equal to each
//! other and can be compared to values of any type.
//!
//! ## `is-null`
//!
//! Check if an optional value is missing.
//!
//! - Input parameters: one value
//! - Output value: a boolean indicating whether the value is null or not
//!
//! # Graph manipulation functions
//!
//! ## `node`
//!
//! Creates a new graph node.
//!
//! - Input parameters: none
//! - Output value: a reference to the new graph node
//!
//! # Logical functions
//!
//! ## `not`
//!
//! Negates a boolean value.
//!
//! - Input parameters: one boolean
//! - Output value: the negation of the input value
//!
//! ## `and`
//!
//! Computes the conjunction of boolean values:
//! true if none of the inputs are false, otherwise false.
//!
//! - Input parameters: zero or more booleans
//! - Output value: the conjunction of all the input booleans
//!
//! ## `or`
//!
//! Computes the disjunction of boolean values:
//! true if any of the inputs are true, otherwise false.
//!
//! - Input parameters: zero or more booleans
//! - Output value: the disjunction of all the input booleans
//!
//! # Mathematical functions
//!
//! ## `plus`
//!
//! Adds integers together.
//!
//! - Input parameters: zero or more integers
//! - Output value: the sum of all of the input integers
//!
//! # String functions
//!
//! ## `format`
//!
//! Formats a string according to the given format string and arguments.
//!
//! - Input parameters:
//! - `format`: a format string containing placeholders
//! - as many additional parameters as there are placeholders in the format string
//!
//! - Output value: a formatted string with the placeholders replaced by formatted values
//!
//! Placeholders are written as `{}`. To produce literal braces, use `{{` and `}}` instead.
//!
//! ## `replace`
//!
//! Applies a regular expression to a string, replacing any text that matches.
//!
//! - Input parameters:
//! - `text`: a string to look for matches in
//! - `pattern`: a string defining the regular expression to search for
//! - `replacement`: the text to replace any matches with
//!
//! Note that the regular expression syntax that we support is exactly that used by Rust's
//! [`regex`][] crate. In particular, the `pattern` is passed in to [`Regex::new`][], and the
//! `replacement` text passed in to [`Regex::replace_all`][].
//!
//! [`regex`]: https://docs.rs/regex/
//! [`Regex::new`]: https://docs.rs/regex/*/regex/struct.Regex.html#method.new
//! [`Regex::replace_all`]: https://docs.rs/regex/*/regex/struct.Regex.html#method.replace_all
//!
//! # List functions
//!
//! ## `concat`
//!
//! Concatenate list arguments.
//!
//! - Input parameters: list values
//! - Output value: the concatenation of the input lists
//!
//! ## `is-empty`
//!
//! Test whether a list is empty or not.
//!
//! - Input parameters: a list value
//! - Output value: a boolean indicating whether the list is empty or not
//!
//! ## `join`
//!
//! Join a list of values using the given separator
//!
//! - Input parameters:
//! - `list`: A list of values
//! - `sep`: An optional separator string
//! - Output value:
//! - A string consisting of the formatted values from the list separated by
//! the separator string
//!
//! ## `length`
//!
//! Determine the length of a list.
//!
//! - Input parameters: a list value
//! - Output value: an integer indicating the length of the list
//!
//! # Syntax manipulation functions
//!
//! ## `named-child-index`
//!
//! Returns the index of a "named child" within its parent.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The index of `node` within its parent's list of _named_ children (i.e., the index that
//! would cause `ts_node_named_child` to return `node`)
//!
//! ## `named-child-count`
//!
//! Returns the number of "named children" of a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The number of _named_ children in `node`
//!
//! ## `source-text`
//!
//! Returns the source text represented by a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - A string containing the source text represented by `node`
//!
//! ## `node-type`
//!
//! Returns a syntax node's type as a string. (The type is the name of the node's grammar rule in
//! the underlying tree-sitter grammar.)
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - A string containing the type of `node`
//!
//! ## `start-column`
//!
//! Returns the zero-based start column of a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The zero-based start column of `node`
//!
//! ## `start-row`
//!
//! Returns the zero-based start row of a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The zero-based start row of `node`
//!
//! ## `end-column`
//!
//! Returns the zero-based end column of a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The zero-based end column of `node`
//!
//! ## `end-row`
//!
//! Returns the zero-based end row of a syntax node.
//!
//! - Input parameters:
//! - `node`: A syntax node
//! - Output value:
//! - The zero-based end row of `node`