Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support core schema #13

Merged
merged 1 commit into from
Oct 4, 2020
Merged
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
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