Python: Add support for YAML comments.

This commit is contained in:
Mathias Vorreiter Pedersen
2026-06-04 11:37:54 +01:00
parent b6521e7c0e
commit 0aa1abe432
3 changed files with 34 additions and 1 deletions

View File

@@ -45,6 +45,12 @@ private module YamlSig implements LibYaml::InputSig {
class ParseErrorBase extends LocatableBase, @yaml_error {
string getMessage() { yaml_errors(this, result) }
}
class CommentBase extends LocatableBase, @yaml_comment {
string getText() { yaml_comments(this, result, _) }
override string toString() { yaml_comments(this, _, result) }
}
}
import LibYaml::Make<YamlSig>

View File

@@ -280,13 +280,17 @@ yaml_scalars (unique int scalar: @yaml_scalar_node ref,
int style: int ref,
string value: string ref);
yaml_comments (unique int id: @yaml_comment,
string text: string ref,
string tostring: string ref);
yaml_errors (unique int id: @yaml_error,
string message: string ref);
yaml_locations(unique int locatable: @yaml_locatable ref,
int location: @location_default ref);
@yaml_locatable = @yaml_node | @yaml_error;
@yaml_locatable = @yaml_node | @yaml_error | @yaml_comment;
/*- Python dbscheme -*/

View File

@@ -641,6 +641,10 @@
<k>@yaml_error</k>
<v>1</v>
</e>
<e>
<k>@yaml_comment</k>
<v>1000</v>
</e>
</typesizes>
<stats><relation>
<name>externalDefects</name>
@@ -18657,5 +18661,24 @@
</dep>
</dependencies>
</relation>
<relation>
<name>yaml_comments</name>
<cardinality>1000</cardinality>
<columnsizes>
<e>
<k>id</k>
<v>1000</v>
</e>
<e>
<k>text</k>
<v>1000</v>
</e>
<e>
<k>tostring</k>
<v>1000</v>
</e>
</columnsizes>
<dependencies/>
</relation>
</stats>
</dbstats>