pub struct PerlCode { /* private fields */ }Expand description
Per-language code type tag for Perl; carries no data.
Trait Implementations§
Source§impl Alterator for PerlCode
impl Alterator for PerlCode
Source§fn alterate(
node: &Node<'_>,
code: &[u8],
span: bool,
field_name: Option<&'static str>,
children: Vec<AstNode>,
) -> AstNode
fn alterate( node: &Node<'_>, code: &[u8], span: bool, field_name: Option<&'static str>, children: Vec<AstNode>, ) -> AstNode
AST node containing the code associated to the node,
its span, the grammar field name through which the parent reaches
it (if any), and its children. Read moreSource§fn get_text_span(
node: &Node<'_>,
code: &[u8],
span: bool,
text: bool,
) -> (String, Option<Span>)
fn get_text_span( node: &Node<'_>, code: &[u8], span: bool, text: bool, ) -> (String, Option<Span>)
Source§fn get_default(
node: &Node<'_>,
code: &[u8],
span: bool,
field_name: Option<&'static str>,
children: Vec<AstNode>,
) -> AstNode
fn get_default( node: &Node<'_>, code: &[u8], span: bool, field_name: Option<&'static str>, children: Vec<AstNode>, ) -> AstNode
AST node containing the code associated to the
node, its span, its grammar field name (if any), and its
children.Source§fn keeps_children<'a>(
_node: &Node<'a>,
_code: &[u8],
_ancestors: Ancestors<'a, '_>,
) -> bool
fn keeps_children<'a>( _node: &Node<'a>, _code: &[u8], _ancestors: Ancestors<'a, '_>, ) -> bool
node must keep its children even though
Self::alterate would flatten it into a verbatim leaf. Read moreSource§impl Getter for PerlCode
impl Getter for PerlCode
Source§fn get_operand_id<'a>(
node: &Node<'a>,
code: &'a [u8],
ancestors: Ancestors<'a, '_>,
) -> &'a [u8] ⓘ
fn get_operand_id<'a>( node: &Node<'a>, code: &'a [u8], ancestors: Ancestors<'a, '_>, ) -> &'a [u8] ⓘ
Spells a -bareword key whole (#1545). A key that is exactly a
file test ((-x => 1)) has swallowed the => and the value into
its node, so the key is the sign and the word after it; a
-and / -not key gets back the sign its - token stopped
billing, spelled the same however the two are spaced, since Perl
keys (- not => 1) as "-not" too. The sign is read off the tree
(perl_key_is_signed), not the byte before the key, which can
equally be an infix - or the end of a comment.
Any other -bareword key ((-name => 1), $h{-name}) bills its
word spelled from the sign (#1572). That is a source slice, so a
sign spaced off its word ((- name => 1), rare) keeps the space,
and a comment between the two ((- # c⏎ name => 1)) is carried
along in it: one operand, distinct from name, but not merged
with -name, and listed by bca ops as written.
Source§fn get_operator_id_as_str(id: u16) -> &'static str
fn get_operator_id_as_str(id: u16) -> &'static str
Folds paired delimiters to one glyph, and names the two pattern operations after their source spelling.
Hand-written rather than get_operator!(Perl) because
SubstitutionPatternS and TransliterationTrOrY are named
nodes rather than punctuation tokens (#1314): the macro’s
fallback renders a kind’s own name, so bca ops would list
substitution_pattern_s and transliteration_tr_or_y among
the operators, which reads as a bug rather than as s///.
tr/// covers y/// too — one kind, one glyph, because they
are synonyms. => is the named fat_comma node for the same
reason.
Source§fn get_space_kind(node: &Node<'_>) -> SpaceKind
fn get_space_kind(node: &Node<'_>) -> SpaceKind
node opens, or SpaceKind::Unknown when it
opens none.Source§fn get_op_type<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> TokenRole
fn get_op_type<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> TokenRole
node as a Halstead operator, operand, or neither. Read moreSource§fn get_func_name<'a, 'tree>(
node: &Node<'tree>,
code: &'a [u8],
ancestors: Ancestors<'tree, '_>,
) -> Option<&'a str>
fn get_func_name<'a, 'tree>( node: &Node<'tree>, code: &'a [u8], ancestors: Ancestors<'tree, '_>, ) -> Option<&'a str>
node declares. Defaults to
get_func_space_name.Source§fn get_func_space_name<'a, 'tree>(
node: &Node<'tree>,
code: &'a [u8],
ancestors: Ancestors<'tree, '_>,
) -> Option<&'a str>
fn get_func_space_name<'a, 'tree>( node: &Node<'tree>, code: &'a [u8], ancestors: Ancestors<'tree, '_>, ) -> Option<&'a str>
node opens. Read moreSource§fn get_space_kind_with_code<'a>(
node: &Node<'a>,
_code: &[u8],
_ancestors: Ancestors<'a, '_>,
) -> SpaceKind
fn get_space_kind_with_code<'a>( node: &Node<'a>, _code: &[u8], _ancestors: Ancestors<'a, '_>, ) -> SpaceKind
get_space_kind. The default
forwards to the byte-less classifier; languages whose space
kinds are encoded in macro identifier text (Elixir’s
defmodule / def / defp / defmacro / defmacrop Calls)
override this so the walker can attribute the correct
SpaceKind to each promoted func space (#275). Read moreSource§fn get_op_type_with_code<'a>(
node: &Node<'a>,
_code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> TokenRole
fn get_op_type_with_code<'a>( node: &Node<'a>, _code: &[u8], ancestors: Ancestors<'a, '_>, ) -> TokenRole
get_op_type. The default forwards
to the byte-less classifier; languages whose Halstead operand
classification depends on token text override this. Kotlin uses
it to recover the variable in a short-form string template
("Hi $name"), which the grammar emits as bare string_content
tokens with no structured interpolation node — the distinction
between an interpolated $name and a literal $5 is only
visible in the source bytes (#454).Source§fn get_operator_spelling<'a>(
_node: &Node<'a>,
_ancestors: Ancestors<'a, '_>,
) -> Option<&'static str>
fn get_operator_spelling<'a>( _node: &Node<'a>, _ancestors: Ancestors<'a, '_>, ) -> Option<&'static str>
node is keyed under in place of
its kind id, for a token whose kind the grammar shares with a
different operator; None keys it by kind. A generic list’s <
is the case (#1559): it has the comparison’s kind but is keyed as
the "<>" pair, as (), [] and {} are. Consulted only for a
node get_op_type_with_code calls
an operator.Source§fn string_operand_type(node: &Node<'_>, interp_kinds: &[u16]) -> TokenRole
fn string_operand_type(node: &Node<'_>, interp_kinds: &[u16]) -> TokenRole
node as a single Halstead
operand, unless it wraps an interpolation child drawn from
interp_kinds — in which case the wrapper yields
TokenRole::Unknown because the inner expressions are
walked and counted separately. Counting the wrapper too would
double-count their contribution to N2. Read moreSource§fn is_subsumed_braced_word<'a>(
node: &Node<'a>,
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_subsumed_braced_word<'a>( node: &Node<'a>, ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
node is a fragment of a Tcl-family braced word rather
than a token of its own, and so contributes no operand (#1354). Read moreSource§fn generic_argument_command<'tree, 'chain>(
word: &Node<'tree>,
ancestors: Ancestors<'tree, 'chain>,
kinds: &BracedWordKinds,
) -> Option<(Node<'tree>, Ancestors<'tree, 'chain>)>
fn generic_argument_command<'tree, 'chain>( word: &Node<'tree>, ancestors: Ancestors<'tree, 'chain>, kinds: &BracedWordKinds, ) -> Option<(Node<'tree>, Ancestors<'tree, 'chain>)>
command node word is an argument of, paired with
that command’s own ancestry — or None when word instead
fills a slot of a construct the grammar models, and so is a
script by construction. Read moreSource§fn is_value_braced_word<'a>(
word: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_value_braced_word<'a>( word: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
{a b} of lappend x {a b} rather than the block
of eval {…} (#1318). Read moreSource§fn is_braced_script_word<'a>(
node: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_braced_script_word<'a>( node: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
node is a Tcl-family braced script — a proc or if
body, an iRules when handler — rather than a braced literal
(#1381). Read moreSource§fn is_braced_literal_slot<'a>(
word: &Node<'a>,
code: &[u8],
ancestors: Ancestors<'a, '_>,
kinds: &BracedWordKinds,
) -> bool
fn is_braced_literal_slot<'a>( word: &Node<'a>, code: &[u8], ancestors: Ancestors<'a, '_>, kinds: &BracedWordKinds, ) -> bool
word, a braced word is_value_braced_word calls a
script, fills a slot whose documented syntax takes a value. Read moreSource§fn is_switch_arm_body(word: &Node<'_>, command: &Node<'_>) -> bool
fn is_switch_arm_body(word: &Node<'_>, command: &Node<'_>) -> bool
word, an argument of a switch arm command
(is_switch_arm), sits in a body position rather than a
pattern position. Read moreSource§fn command_leading_word<'c>(
command: &Node<'_>,
code: &'c [u8],
kinds: &BracedWordKinds,
) -> Option<&'c str>
fn command_leading_word<'c>( command: &Node<'_>, code: &'c [u8], kinds: &BracedWordKinds, ) -> Option<&'c str>
simple_word. Read more