Skip to main content
Any Framework

Deletes nodes in a parse tree. This program is part of the Trash toolkit.

NuGetCompare
Published
Sep 20, 2023
3y ago
Total Downloads
22.8K
22,828

Install

dotnet add package trdeltree --version 0.21.6

No framework information available.

README

trdeltree

Summary

Delete an entire subtree of a parse tree

Description

Reads a parse tree from stdin, and given an XPath expression for the nodes in the parse tree, delete the nodes and all children recursively. Writes the modified tree to stdout. The input and output are Parse Tree Data.

Usage

trdeltree 

Example

Before:

grammar Expression;
e : e ('*' | '/') e
  | e ('+' | '-') e
  | '(' e ')'
  | ('-' | '+')* a
  ;
a : INT ;
INT : ('0' .. '9')+ ;
MUL : '*' ;
DIV : '/' ;
ADD : '+' ;
SUB : '-' ;
LP : '(' ;
RP : ')' ;
WS : [ \r\n\t] + -> skip ;

Command:

trparse Expression.g4 | trdelete "//parserRuleSpec[RULE_REF/text() = 'a']" | trprint

After:

grammar Expression;
e : e ('*' | '/') e
  | e ('+' | '-') e
  | '(' e ')'
  | ('-' | '+')* a
  ;
a : INT ;
INT : ('0' .. '9')+ ;
MUL : '*' ;
DIV : '/' ;
ADD : '+' ;
SUB : '-' ;
LP : '(' ;
RP : ')' ;
WS : [ \r\n\t] + -> skip ;

Notes

If you are running MSYS2 on Windows, you may notice that XPaths are not being processed by this command correctly. To avoid the Bash shell from altering XPaths, type export MSYS2_ARG_CONV_EXCL="*", then execute your command.

Current version

0.21.6 Fix trquery.

Changes from Previous Version

No structural changes between v0.21.5 and v0.21.6.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.