tranalyze 0.23.14
See the version list below for details.
dotnet tool install --global tranalyze --version 0.23.14
dotnet new tool-manifest
dotnet tool install --local tranalyze --version 0.23.14
#tool dotnet:?package=tranalyze&version=0.23.14
nuke :add-package tranalyze --version 0.23.14
tranalyze
Summary
Analyze a grammar
Description
Reads an Antlr4 grammar in the form of parse tree data from stdin, searches for problems in the grammar, and outputs the results to stdout.
Usage
tranalyze
Details
tranalyze
performs a multi-pass search of a grammar in the
form of a parse result (from trparse
), looking for problems in the
grammar.
- Classify each node type and output a count for each type.
- Check for unused symbols.
- Check for Unicode literals of the type '\unnnn' with numbers that are over 32-bits.
- Check for common groupings in alts.
- Check for useless parentheses.
- Identify if a symbol derives the empty string, a non-empty string, or both.
- Check for unhalting nonterminals symbols in a single rule or group of rules.
Example
Consider the following combined grammar.
Input to command
grammar Test;
start : 'a' empty infinite0 infinite1 infinite2 ;
unused : 'b';
infinite0 : (infinite0 'c')* ; // Not legal in Antlr4 MLR, but okay
infinite1 : (infinite1 'c')+ ; // Not legal in Antlr4 MLR, infinite
infinite2 : ('c' infinite2)+ ; // Not flagged by Antlr4, infinite
empty : ;
Command
trparse Test.g4 | tranalyze
Output
6 occurrences of Antlr - nonterminal def
7 occurrences of Antlr - nonterminal ref
1 occurrences of Antlr - keyword
5 occurrences of Antlr - literal
Rule start is NonEmpty
Rule unused is NonEmpty
Rule infinite0 is NonEmpty
Rule infinite1 is NonEmpty
Rule infinite2 is NonEmpty
Rule empty is Empty
Rule infinite1 is malformed. It does not derive a string with referencing itself.
Rule infinite2 is malformed. It does not derive a string with referencing itself.
Current version
0.23.14 Updated trgen templates for Antlr-ng.
License
The MIT License
Copyright (c) 2024 Ken Domino
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
This package has no dependencies.
Version | Downloads | Last updated |
---|---|---|
0.23.17 | 210 | 3/7/2025 |
0.23.16 | 210 | 3/4/2025 |
0.23.15 | 91 | 2/25/2025 |
0.23.14 | 102 | 2/9/2025 |
0.23.13 | 98 | 1/19/2025 |
0.23.12 | 92 | 1/16/2025 |
0.23.11 | 122 | 12/18/2024 |
0.23.10 | 112 | 12/12/2024 |
0.23.9 | 108 | 11/29/2024 |
0.23.8 | 120 | 11/1/2024 |
0.23.7 | 143 | 10/9/2024 |
0.23.6 | 157 | 9/21/2024 |
0.23.5 | 126 | 9/15/2024 |
0.23.4 | 120 | 9/7/2024 |
0.23.3 | 126 | 8/15/2024 |
0.18.1 | 693 | 11/11/2022 |
0.18.0 | 528 | 11/7/2022 |
0.17.0 | 515 | 9/11/2022 |
0.16.5 | 595 | 7/29/2022 |
0.16.4 | 627 | 6/13/2022 |
0.16.3 | 583 | 5/7/2022 |
0.16.2 | 579 | 5/6/2022 |
0.16.1 | 544 | 5/5/2022 |
0.16.0 | 589 | 4/13/2022 |
0.15.1 | 583 | 4/4/2022 |
0.15.0 | 563 | 3/20/2022 |
0.14.3 | 583 | 2/27/2022 |
0.14.2 | 581 | 2/18/2022 |
0.14.1 | 634 | 1/26/2022 |
0.14.0 | 606 | 1/26/2022 |
0.13.8 | 577 | 1/14/2022 |
0.13.7 | 564 | 1/13/2022 |
0.13.6 | 585 | 1/13/2022 |
0.13.5 | 544 | 1/12/2022 |
0.13.4 | 598 | 1/11/2022 |
0.13.3 | 565 | 1/10/2022 |
0.13.2 | 443 | 12/24/2021 |
0.13.1 | 417 | 12/24/2021 |
0.13.0 | 430 | 12/23/2021 |
0.12.0 | 408 | 12/6/2021 |
0.11.5 | 452 | 10/17/2021 |
0.11.4 | 472 | 10/17/2021 |
0.11.3 | 438 | 9/28/2021 |
0.11.2 | 442 | 9/26/2021 |
0.11.1 | 460 | 9/25/2021 |
0.11.0 | 505 | 9/24/2021 |
0.10.0 | 421 | 9/9/2021 |
0.8.9 | 396 | 8/13/2021 |
0.8.8 | 431 | 8/5/2021 |
0.8.7 | 431 | 7/20/2021 |
0.8.6 | 426 | 7/13/2021 |
0.8.5 | 423 | 7/6/2021 |
0.8.4 | 456 | 6/24/2021 |
0.8.3 | 506 | 6/13/2021 |
0.8.2 | 477 | 6/8/2021 |
0.8.1 | 416 | 6/2/2021 |
0.8.0 | 441 | 5/27/2021 |
# tranalyze
## Summary
Analyze a grammar
## Description
Reads an Antlr4 grammar in the form of parse tree data from stdin,
searches for problems in the grammar, and outputs the results to stdout.
## Usage
tranalyze
## Details
`tranalyze` performs a multi-pass search of a grammar in the
form of a parse result (from `trparse`), looking for problems in the
grammar.
* Classify each node type and output a count for each type.
* Check for unused symbols.
* Check for Unicode literals of the type '\unnnn' with
numbers that are over 32-bits.
* Check for common groupings in alts.
* Check for useless parentheses.
* Identify if a symbol derives the empty string, a non-empty string, or both.
* Check for unhalting nonterminals symbols in a single rule or group of rules.
## Example
Consider the following combined grammar.
_Input to command_
grammar Test;
start : 'a' empty infinite0 infinite1 infinite2 ;
unused : 'b';
infinite0 : (infinite0 'c')* ; // Not legal in Antlr4 MLR, but okay
infinite1 : (infinite1 'c')+ ; // Not legal in Antlr4 MLR, infinite
infinite2 : ('c' infinite2)+ ; // Not flagged by Antlr4, infinite
empty : ;
_Command_
trparse Test.g4 | tranalyze
_Output_
6 occurrences of Antlr - nonterminal def
7 occurrences of Antlr - nonterminal ref
1 occurrences of Antlr - keyword
5 occurrences of Antlr - literal
Rule start is NonEmpty
Rule unused is NonEmpty
Rule infinite0 is NonEmpty
Rule infinite1 is NonEmpty
Rule infinite2 is NonEmpty
Rule empty is Empty
Rule infinite1 is malformed. It does not derive a string with referencing itself.
Rule infinite2 is malformed. It does not derive a string with referencing itself.
## Current version
0.23.14 Updated trgen templates for Antlr-ng.
## License
The MIT License
Copyright (c) 2024 Ken Domino
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.