Skip to content

Commit

Permalink
feat: support core schema (#13)
Browse files Browse the repository at this point in the history
Ref: https://yaml.org/spec/1.2/spec.html#schema/core/

- `null_scalar`
- `boolean_scalar`
- `integer_scalar`
- `float_scalar`
- `string_scalar`
  • Loading branch information
ikatyang authored Oct 4, 2020
1 parent 523a6d7 commit 6d74a6b
Show file tree
Hide file tree
Showing 14 changed files with 27,614 additions and 23,355 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ console.log(tree.rootNode.toString());
// (block_mapping
// (block_mapping_pair
// key: (flow_node
// (plain_scalar))
// (plain_scalar
// (string_scalar)))
// value: (block_node
// (anchor)
// (block_sequence
// (block_sequence_item
// (flow_node
// (plain_scalar))))))))))
// (plain_scalar
// (string_scalar)))))))))))
```

## License
Expand Down
354 changes: 354 additions & 0 deletions corpus/schema.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
================================================================================
Example 10.4. !!null Examples
================================================================================
!!null null: value for null key
key with null value: !!null null

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(tag)
(plain_scalar
(null_scalar)))
value: (flow_node
(plain_scalar
(string_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(null_scalar))))))))

================================================================================
Example 10.5. !!bool Examples
================================================================================
YAML is a superset of JSON: !!bool true
Pluto is a planet: !!bool false

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(boolean_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(boolean_scalar))))))))

================================================================================
Example 10.6. !!int Examples
================================================================================
negative: !!int -12
zero: !!int 0
positive: !!int 34

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(integer_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(integer_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(integer_scalar))))))))

================================================================================
Example 10.7. !!float Examples
================================================================================
negative: !!float -1
zero: !!float 0
positive: !!float 2.3e4
infinity: !!float .inf
not a number: !!float .nan

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(integer_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(integer_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(float_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(float_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(tag)
(plain_scalar
(float_scalar))))))))

================================================================================
Example 10.8. JSON Tag Resolution
================================================================================
A null: null
Booleans: [ true, false ]
Integers: [ 0, -0, 3, -19 ]
Floats: [ 0., -0.0, 12e03, -2E+05 ]
Invalid: [ True, Null, 0o7, 0x3A, +12.3 ]

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(plain_scalar
(null_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(boolean_scalar)))
(flow_node
(plain_scalar
(boolean_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(boolean_scalar)))
(flow_node
(plain_scalar
(null_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(float_scalar))))))))))

================================================================================
Example 10.9. Core Tag Resolution
================================================================================
A null: null
Also a null: # Empty
Not a null: ""
Booleans: [ true, True, false, FALSE ]
Integers: [ 0, 0o7, 0x3A, -19 ]
Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
Also floats: [ .inf, -.Inf, +.INF, .NAN ]

--------------------------------------------------------------------------------

(stream
(document
(block_node
(block_mapping
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(plain_scalar
(null_scalar))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar))))
(comment)
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(double_quote_scalar)))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(boolean_scalar)))
(flow_node
(plain_scalar
(boolean_scalar)))
(flow_node
(plain_scalar
(boolean_scalar)))
(flow_node
(plain_scalar
(boolean_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar)))
(flow_node
(plain_scalar
(integer_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar))))))
(block_mapping_pair
key: (flow_node
(plain_scalar
(string_scalar)))
value: (flow_node
(flow_sequence
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar)))
(flow_node
(plain_scalar
(float_scalar))))))))))
Loading

0 comments on commit 6d74a6b

Please sign in to comment.