-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/internal/parser: implement automatic reformatting (#2036)
* tools/internal/parser: remove Blank from the parsed output This node is format-specific, and so should not exist in the abstract syntax tree. The _lexer token_ for a blank is important to disambiguate during parsing of the PSL format, but it's not necessary after the tree has been assembled. * tools/internal/domain: factor out parsing and comparing of domain names The new domain subpackage enforces all IDNA2008 validation rules, which covers a superset of the PSL style rules. One exception is that it corrects unambiguous fixable errors like a browser would, instead of rejecting non canonical input. This is to support automated reformatting and authoring help in a followup change. * tools/internal/parser: implement AST cleaning The Clean method fixes lint issues that can be fixed by a machine, such as the sorting of domain names and suffix blocks. These fixes should not alter any of the meaning of a parsed PSL, only cosmetic things. * tools/internal/parser: silently fix some whitespace/encoding mistakes Now that there is a reformatter, leading/trailing whitespace, unnecessary UTF-8 BOMs, explicitly declared UTF-16 encoding and DOS style line endings can all be fixed automatically by the formatter, no need to bother the user about it. * tools/internal/parser: support outputting a parsed PSL back to text govalidate now has extra flags to control formatting. By default, if there are no parse errors (only validation/lint), it automatically overwrites the input file with a reformatted copy. * tools/internal/parser: support outputting a parsed PSL to debug form This just pulls the ad-hoc debug printer from govalidate into the parser library.
- Loading branch information
Showing
20 changed files
with
8,578 additions
and
638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.