trpiggy 0.18.1
dotnet tool install --global trpiggy --version 0.18.1
dotnet new tool-manifest
dotnet tool install --local trpiggy --version 0.18.1
#tool dotnet:?package=trpiggy&version=0.18.1
nuke :add-package trpiggy --version 0.18.1
Modify trees from template.
This program is part of the Trash toolkit.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
# trpiggy
## Summary
Perform a parse tree rewrite
## Description
Read from stdin a parsing result set, modify the trees using a template engine, then
output the modified parsing result set. The command also reads a template to follow
as the first argument to the command. The template extends the well-known visitor
pattern used by Antlr with a template that contains strings and xpath expressions
that defines children.
## Usage
trpiggy template-spec
## Examples
Assume "lua.g4" grammar.
Doc input "input.txt":
```
local tbl = {
SomeObject = {
Key = "Value",
AnotherKey = {
Key1 = "Value 1",
Key2 = "Value 2",
Key3 = "Value 3",
}
},
AnotherObject = {
Key = "Value",
AnotherKey = {
Key1 = "Value 1",
Key2 = "Value 2",
Key3 = "Value 3",
}
}
}
```
Template input "templates.txt":
```
//chunk -> {{<block>}} ;
//block -> {{<stat>}} ;
//stat[attnamelist and explist] -> {{<explist>}} ;
//explist -> {{ {<exp>} }} ;
//exp[position()=1 and tableconstructor] -> {{<tableconstructor>}} ;
//exp[position()>1 and tableconstructor] -> {{, <tableconstructor>}} ;
//fieldlist -> {{<field>}} ;
//field[position()>1] -> {{, "<NAME>" : <exp> }} ;
//field[position()=1] -> {{ "<NAME>" : <exp> }} ;
```
trparse input.txt | trpiggy templates.txt | trprint
Output:
```
{{ "SomeObject " : { "Key " : "Value" , "AnotherKey " : { "Key1 " : "Value 1" , "Key2 " : "Value 2" , "Key3 " : "Value 3" } } , "AnotherObject " : { "Key " : "Value" , "AnotherKey " : { "Key1 " : "Value 1" , "Key2 " : "Value 2" , "Key3 " : "Value 3" } } }}
```
## Current version
0.18.1 Fix trperf, trfirst. Adding Xalan code. Fix #180. Fix crash in trgen https://github.com/antlr/grammars-v4/issues/2818. Fix #134. Add -e option to trrename. Update Antlr4BuildTasks version. Fix #197, #198. Fix trparse exit code. Add --quiet option to trparse to just get exit code. Change trgen templates to remove -file option, make file name parsing the default.