Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ In additional to parsing YAML to AST, it has following features:

* restoration after the errors and reporting errors as a part of AST nodes.
* built-in support for `!include` tag used in RAML
* built-in support fot `!reference` tag used in Gitlab CI.

## Usage
The type information below is relevant when using TypeScript, if using from JavaScript only the field/method information is relevant.
Expand All @@ -17,7 +18,7 @@ The type information below is relevant when using TypeScript, if using from Java
### YAMLNode
`YAMLNode` class is an ancestor for all node kinds.
It's `kind` field determine node kind, one of `Kind` enum:
* `SCALAR`, `MAPPING`, `MAP`, `SEQ`, `ANCHOR_REF` or `INCLUDE_REF`.
* `SCALAR`, `MAPPING`, `MAP`, `SEQ`, `ANCHOR_REF`, `INCLUDE_REF` or `REFERENCE_REF`.

After node kind is determined, it can be cast to one of the `YAMLNode` descendants types:
* `YAMLScalar`, `YAMLMapping`, `YamlMap`, `YAMLSequence` or `YAMLAnchorReference`.
Expand Down
4 changes: 4 additions & 0 deletions src/dumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ function writeScalar(state, object, level) {
state.dump=""+object;//FIXME
return;
}
if (object.indexOf("!reference")==0){
state.dump=""+object;//FIXME
return;
}
if (object.indexOf("!$$$novalue")==0){
state.dump="";//FIXME
return;
Expand Down
10 changes: 9 additions & 1 deletion src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,15 @@ function composeNode(state:State, parentIndent, nodeContext, allowToSeek, allowC
}

if (null !== state.tag && '!' !== state.tag) {
if (state.tag=="!include"){
if (state.tag == "!reference") {
if (!state.result) {
state.result = ast.newScalar();
state.result.startPosition = state.position;
state.result.endPosition = state.position;
throwError(state, "!reference without value");
}
state.result.kind = ast.Kind.REFERENCE_REF;
} else if (state.tag=="!include"){
if (!state.result){
state.result=ast.newScalar();
state.result.startPosition=state.position;
Expand Down
3 changes: 2 additions & 1 deletion src/yamlAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export enum Kind{
MAP,
SEQ,
ANCHOR_REF,
INCLUDE_REF
INCLUDE_REF,
REFERENCE_REF
}

export interface YAMLDocument {
Expand Down