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

[YAML] Add entirely new YAML syntax #90

Merged
merged 12 commits into from
Mar 15, 2016
583 changes: 514 additions & 69 deletions YAML/YAML.sublime-syntax

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions YAML/preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%YAML 1.2
%TAG !e! tag:example.com,2000:app/ # comment
%RESERVED name parameter #comment
---
- [~, null, Null, NULL, nUll,
yes, no, true, false,
0b0, +0b1_0_1, -0b1, ~, 0b, 0b2,
01, +0_761, -07, ~, 09,
0, +1, -12_345,
0x0, +0x12_34_56, -0xabcdef, ~, 0xyz, 0x,
1:20, +1:9, -1_234:59:00, ~, 1:60, :60,
0.1, +.293, -1_123.e-3, 2.234.567,
.inf, +.INF, -.Inf, .nan, ~, .inF,
.NaN, ~, .Nan,
2015-08-15, 2015-08-15 1:20:30.123, 2015-08-15T12:20:30.123-9:00,
plain scalar, 'single-quoted ('''') scalar', "double-quoted (\"\") scalar"
]

- &anchor !!omap
- 1: a
- 2: b
- foo: bar

- !!pairs
- 0: {<<: *anchor, 2: c}
- 1: a2 [also part of the plain scalar]
- 2: :another scalar {}
- !e!float 3: !<tag:example.com,2000:app/int> 1 - 3

- {? !!int '12' : value,
? !!str foo : :bar}

- - key: {more key: baz}
asdf: ~

? |-
block scalar as key
# comment here
: !!str >5
block scalar as value
...
80 changes: 0 additions & 80 deletions YAML/syntax_test_yaml.yaml

This file was deleted.

124 changes: 124 additions & 0 deletions YAML/tests/syntax_test_block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# SYNTAX TEST "Packages/YAML/YAML.sublime-syntax"
# <- source.yaml comment

# http://yaml.org/spec/1.2/spec.html#style/block/


##############################################################################
## Scalars
# http://yaml.org/spec/1.2/spec.html#style/block/scalar

# Headers ############################
# (note that block scalars may be empty)
- |
# ^ punctuation.definition.block.scalar.literal

- >
# ^ punctuation.definition.block.scalar.folded

- >1
# ^ punctuation.definition.block.scalar
# ^ constant.numeric.indentation-indicator

- |1-
# ^ punctuation.definition.block.scalar
# ^ constant.numeric.indentation-indicator
# ^ support.other

# Headers and content ################
- |
literal
#^^^^^^^ string.unquoted.block

- >1
folded
#^^^^^^^ string.unquoted.block

- |+
keep
#^^^^ string.unquoted.block

- >1-
strip
#^^^^^^ string.unquoted.block

- >
content
# still content
#^^^^^^^^^^^^^^^^^ string.unquoted.block

- >
# content
# still content
# not content
#^^^^^^^^^^^^^ comment

# Empty blocks #######################
- > asdf
# ^^^^^ invalid.illegal.expected-comment-or-newline
- ># not comment
# ^^^^^^^^^^^^^ invalid.illegal.expected-comment-or-newline
- |
plain
# <- -string.unquoted.block


##############################################################################
## Sequence
# http://yaml.org/spec/1.2/spec.html#style/block/sequence

-
# <- punctuation.definition.block.sequence.item
- -
# <- punctuation.definition.block.sequence.item
# ^ punctuation.definition.block.sequence.item
- !!omap -
# <- punctuation.definition.block.sequence.item
# ^ punctuation.definition.block.sequence.item
-


##############################################################################
## Mapping
# http://yaml.org/spec/1.2/spec.html#style/block/mapping

key: value
#^^ string.unquoted.plain.out entity.name.tag
# ^ punctuation.separator.mapping.key-value, -entity
# ^^^^^ string.unquoted.plain.out
key# : value
#^^^ string.unquoted.plain.out entity.name.tag
# ^ -string
# ^ punctuation.separator.mapping.key-value
# ^^^^^ string.unquoted.plain.out
:
# <- punctuation.separator.mapping.key-value

_type_null: (?:null|Null|NULL|~) # http://yaml.org/type/null.html
#^^^^^^^^^ entity.name.tag
# ^^^^^^^^^^^^^^^^^^^^ -entity.name.tag
# ^ comment

? explicit key # Empty value
#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block-mapping
# ^^^^^^^^^^^^ string.unquoted.plain.out
# ^^^^^^^^^^^^^ comment
# <- meta.block-mapping punctuation.definition.key-value.begin

? |
block key
# ^^^^^^^^^ meta.block-mapping string.unquoted.block
# ^^^^^^^^^ -meta.block-mapping meta.block-mapping
: - one # Explicit compact
# <- meta.block-mapping punctuation.separator.mapping.key-value
- two: :three # block value
# ^ punctuation.definition.block.sequence
# ^^^ string.unquoted.plain.out entity.name.tag
# ^ punctuation.separator.mapping.key-value
# ^^^^^^ string.unquoted.plain.out

? a key : not a value
# ^ meta.block-mapping invalid.illegal.expected-newline

scalar
# <- -meta.block-mapping
94 changes: 94 additions & 0 deletions YAML/tests/syntax_test_directives.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# SYNTAX TEST "Packages/YAML/YAML.sublime-syntax"
# <- source.yaml comment

# http://yaml.org/spec/1.2/spec.html#directive//


##############################################################################
## YAML DIRECTIVE
# http://yaml.org/spec/1.2/spec.html#directive/YAML/

%YAML 1.2
#^^^^ keyword.other.directive.yaml
# ^^^ constant.numeric.yaml-version
# <- meta.directive punctuation.definition.directive.begin
%YAML 9821.2213213 # comment
# ^^^^^^^^^^^^ constant.numeric.yaml-version
# ^ comment
%YAML 9821.2213213 more
# ^^^^ invalid.illegal


##############################################################################
## TAG DIRECTIVE
# http://yaml.org/spec/1.2/spec.html#directive/TAG/

%TAG
#^^^ meta.directive keyword.other.directive.tag
# <- meta.directive
%TAG !
#^^^ keyword.other.directive.tag
# ^ storage.type.tag-handle
%TAG ! tag:example.com,2000:app/
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.directive
#^^^ keyword.other.directive.tag
# ^ storage.type.tag-handle
# ^^^^^^^^^^^^^^^^^^^^^^^^^ support.type.tag-prefix
%TAG !! tag:example.com,2000:app/
# ^^ storage.type.tag-handle
# ^ support.type.tag-prefix
%TAG !e! tag:example.com,2000:app/ # comment
# ^^^ storage.type.tag-handle
# ^ support.type.tag-prefix
# ^ comment
%TAG !e! !empty-
# ^^^ storage.type.tag-handle
# ^^^^^^^ support.type.tag-prefix

%TAG !tag some text
# ^^^ invalid.illegal
# ^^^^ invalid.illegal
# ^^^^ invalid.illegal
%TAG !yea-! [
# ^^^^^^ storage.type.tag-handle
# ^ invalid.illegal
%TAG !y_ea! [
# ^^^^^ invalid.illegal
%TAG !yea! tag more
# ^^^^ invalid.illegal
%TAG !yea!%%YAML
# ^^^^^^ invalid.illegal


##############################################################################
## RESERVED DIRECTIVE
# http://yaml.org/spec/1.2/spec.html#directive/reserved/

%RESERVED
#^^^^^^^^ meta.directive support.other.directive.reserved
# <- meta.directive punctuation.definition.directive.begin
%1
#^ support.other.directive.reserved
%RESERVED name
#^^^^^^^^ support.other.directive.reserved
# ^ string.unquoted.directive-name
%RESERVED name parameter #comment
#^^^^^^^^ support.other.directive.reserved
# ^^^^ string.unquoted.directive-name
# ^^^^^^^^^ string.unquoted.directive-parameter
# ^ comment
%RESERVED name parameter#no-comment
# ^^^^^^^^^^^ invalid.illegal
%RESERVED name parameter more
# ^^^^ invalid.illegal


##############################################################################
## MISC

%
# <- meta.directive punctuation.definition.directive.begin
% TAG
# ^^^ invalid.illegal
%%
#^ invalid.illegal
Loading