|
| 1 | +/** |
| 2 | + * Provides classes for working with YAML data. |
| 3 | + * |
| 4 | + * YAML documents are represented as abstract syntax trees whose nodes |
| 5 | + * are either YAML values or alias nodes referring to another YAML value. |
| 6 | + */ |
| 7 | + |
| 8 | +private import codeql.yaml.Yaml as LibYaml |
| 9 | + |
| 10 | +private module YamlSig implements LibYaml::InputSig { |
| 11 | + import semmle.python.Files |
| 12 | + |
| 13 | + class LocatableBase extends @yaml_locatable { |
| 14 | + Location getLocation() { yaml_locations(this, result) } |
| 15 | + |
| 16 | + string toString() { none() } |
| 17 | + } |
| 18 | + |
| 19 | + class NodeBase extends LocatableBase, @yaml_node { |
| 20 | + NodeBase getChildNode(int i) { yaml(result, _, this, i, _, _) } |
| 21 | + |
| 22 | + string getTag() { yaml(this, _, _, _, result, _) } |
| 23 | + |
| 24 | + string getAnchor() { yaml_anchors(this, result) } |
| 25 | + |
| 26 | + override string toString() { yaml(this, _, _, _, _, result) } |
| 27 | + } |
| 28 | + |
| 29 | + class ScalarNodeBase extends NodeBase, @yaml_scalar_node { |
| 30 | + int getStyle() { yaml_scalars(this, result, _) } |
| 31 | + |
| 32 | + string getValue() { yaml_scalars(this, _, result) } |
| 33 | + } |
| 34 | + |
| 35 | + class CollectionNodeBase extends NodeBase, @yaml_collection_node { } |
| 36 | + |
| 37 | + class MappingNodeBase extends CollectionNodeBase, @yaml_mapping_node { } |
| 38 | + |
| 39 | + class SequenceNodeBase extends CollectionNodeBase, @yaml_sequence_node { } |
| 40 | + |
| 41 | + class AliasNodeBase extends NodeBase, @yaml_alias_node { |
| 42 | + string getTarget() { yaml_aliases(this, result) } |
| 43 | + } |
| 44 | + |
| 45 | + class ParseErrorBase extends LocatableBase, @yaml_error { |
| 46 | + string getMessage() { yaml_errors(this, result) } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +import LibYaml::Make<YamlSig> |
0 commit comments