diff --git a/YAML/YAML.sublime-syntax b/YAML/YAML.sublime-syntax index 198072df87..1cae918e96 100644 --- a/YAML/YAML.sublime-syntax +++ b/YAML/YAML.sublime-syntax @@ -265,20 +265,20 @@ contexts: flow-scalar-11: # http://yaml.org/spec/1.2/spec.html#style/flow/scalar - - include: flow-scalar-double-quoted - - include: flow-scalar-single-quoted + - include: flow-scalar-double-quoted-in + - include: flow-scalar-single-quoted-in - include: flow-scalar-plain-in-11 flow-scalar-12: # http://yaml.org/spec/1.2/spec.html#style/flow/scalar - - include: flow-scalar-double-quoted - - include: flow-scalar-single-quoted + - include: flow-scalar-double-quoted-in + - include: flow-scalar-single-quoted-in - include: flow-scalar-plain-in-12 flow-scalar-out-12: # for block keys - - include: flow-scalar-double-quoted - - include: flow-scalar-single-quoted + - include: flow-scalar-double-quoted-out + - include: flow-scalar-single-quoted-out - include: flow-scalar-plain-out-12 ###[ COMMENTS ]############################################################### @@ -466,12 +466,23 @@ contexts: 2: variable.other.alias.yaml 3: invalid.illegal.character.anchor.yaml - flow-scalar-double-quoted: + flow-scalar-double-quoted-in: # http://yaml.org/spec/1.2/spec.html#style/flow/double-quoted # c-double-quoted(n,c) - match: \" scope: punctuation.definition.string.begin.yaml - push: flow-scalar-double-quoted-body + push: + - flow-scalar-in-expect-end + - flow-scalar-double-quoted-body + + flow-scalar-double-quoted-out: + # http://yaml.org/spec/1.2/spec.html#style/flow/double-quoted + # c-double-quoted(n,c) + - match: \" + scope: punctuation.definition.string.begin.yaml + push: + - flow-scalar-out-expect-end + - flow-scalar-double-quoted-body flow-scalar-double-quoted-body: # TODO consider scoping meaningful trailing whitespace for color @@ -486,12 +497,23 @@ contexts: scope: punctuation.definition.string.end.yaml pop: 1 - flow-scalar-single-quoted: + flow-scalar-single-quoted-in: + # http://yaml.org/spec/1.2/spec.html#style/flow/single-quoted + # c-single-quoted(n,c) + - match: \' + scope: punctuation.definition.string.begin.yaml + push: + - flow-scalar-in-expect-end + - flow-scalar-single-quoted-body + + flow-scalar-single-quoted-out: # http://yaml.org/spec/1.2/spec.html#style/flow/single-quoted # c-single-quoted(n,c) - match: \' scope: punctuation.definition.string.begin.yaml - push: flow-scalar-single-quoted-body + push: + - flow-scalar-out-expect-end + - flow-scalar-single-quoted-body flow-scalar-single-quoted-body: - meta_include_prototype: false @@ -502,6 +524,18 @@ contexts: scope: punctuation.definition.string.end.yaml pop: 1 + flow-scalar-in-expect-end: + - meta_include_prototype: false + - match: (?:(?!{{_flow_scalar_end_plain_in}}).)* + scope: invalid.illegal.unexpected.yaml + pop: 1 + + flow-scalar-out-expect-end: + - meta_include_prototype: false + - match: (?:(?!{{_flow_scalar_end_plain_out}}).)* + scope: invalid.illegal.unexpected.yaml + pop: 1 + flow-scalar-plain-in-implicit-type-11: - match: '{{_type_bool_11}}{{_flow_scalar_end_plain_in}}' scope: constant.language.boolean.yaml diff --git a/YAML/tests/syntax_test_flow.yaml b/YAML/tests/syntax_test_flow.yaml index 07990cdeb2..ce3c05f464 100644 --- a/YAML/tests/syntax_test_flow.yaml +++ b/YAML/tests/syntax_test_flow.yaml @@ -23,13 +23,13 @@ # http://yaml.org/spec/1.2/spec.html#style/flow/double-quoted "flow string" -#^^^^^^^^^^^^ string.quoted.double +#^^^^^^^^^^^^ string.quoted.double - invalid # ^ punctuation.definition.string.end # <- string.quoted.double punctuation.definition.string.begin "flow string more string" -#^^^^^^^^^^^^ string.quoted.double +#^^^^^^^^^^^^ string.quoted.double - invalid # ^ punctuation.definition.string.end "\" \0 \\ \x1b \u12c4 \U1234F678" @@ -59,19 +59,27 @@ "string\ continuation" +"string"illegal +# <- meta.string.yaml string.quoted.double.yaml - invalid +#^^^^^^^ meta.string.yaml string.quoted.double.yaml - invalid +# ^^^^^^^ invalid.illegal.unexpected.yaml + +unquoted"string" +# <- meta.string.yaml string.unquoted.plain.out.yaml +#^^^^^^^^^^^^^^^ meta.string.yaml string.unquoted.plain.out.yaml - invalid ############################################################################## ## Single-quoted # http://yaml.org/spec/1.2/spec.html#style/flow/single-quoted 'flow string' -#^^^^^^^^^^^^ string.quoted.single +#^^^^^^^^^^^^ string.quoted.single - invalid # ^ punctuation.definition.string.end # <- string.quoted.single punctuation.definition.string.begin 'flow string more string' -#^^^^^^^^^^^^ string.quoted.single +#^^^^^^^^^^^^ string.quoted.single - invalid # ^ punctuation.definition.string.end # <- string.quoted.single @@ -80,6 +88,14 @@ continuation" # ^^ constant.character.escape # ^ -constant +'string'illegal +# <- meta.string.yaml string.quoted.single.yaml - invalid +#^^^^^^^ meta.string.yaml string.quoted.single.yaml - invalid +# ^^^^^^^ invalid.illegal.unexpected.yaml + +unquoted'string' +# <- meta.string.yaml string.unquoted.plain.out.yaml +#^^^^^^^^^^^^^^^ meta.string.yaml string.unquoted.plain.out.yaml - invalid ############################################################################## ## Flow-sequence @@ -107,6 +123,36 @@ continuation" # ^ punctuation.separator.sequence # ^^^ string.unquoted.plain.in - entity.name.tag +[ "str"err, 'str'err, "str"err ] +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow.yaml +# ^^^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml +# ^ punctuation.separator.sequence.yaml +# ^^^^^ meta.string.yaml string.quoted.single.yaml +# ^^^ invalid.illegal.unexpected.yaml +# ^ punctuation.separator.sequence.yaml +# ^^^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml +# ^ punctuation.definition.sequence.end.yaml + +# mapping keys are not matched +[ "k"err: "v"err, "k"err : "v"err ] +# <- meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow.yaml +# ^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml +# ^ meta.mapping.yaml punctuation.separator.key-value.mapping.yaml +# ^^^ meta.mapping.value.yaml meta.string.yaml string.quoted.double.yaml +# ^^^ meta.mapping.value.yaml invalid.illegal.unexpected.yaml +# ^ punctuation.separator.sequence.yaml +# ^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml +# ^ - invalid +# ^ meta.mapping.yaml punctuation.separator.key-value.mapping.yaml +# ^^^ meta.mapping.value.yaml meta.string.yaml string.quoted.double.yaml +# ^^^ meta.mapping.value.yaml invalid.illegal.unexpected.yaml +# ^ meta.mapping.value.yaml - invalid +# ^ punctuation.definition.sequence.end.yaml ############################################################################## ## Flow-mapping @@ -155,6 +201,26 @@ continuation" # ^ meta.number.integer.decimal.yaml constant.numeric.value.yaml # ^ meta.mapping.yaml punctuation.definition.mapping.end.yaml +{ "k"err: "v"err, 'k'err: 'v'err } +# <- meta.mapping.yaml punctuation.definition.mapping.begin.yaml +#^^^^^^^^ meta.mapping.yaml +# ^^^^^^^ meta.mapping.value.yaml +# ^^^^^^^^^ meta.mapping.yaml +# ^^^^^^^^ meta.mapping.value.yaml +# ^ meta.mapping.yaml +# ^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml - string +# ^ punctuation.separator.key-value.mapping.yaml +# ^^^ meta.string.yaml string.quoted.double.yaml +# ^^^ invalid.illegal.unexpected.yaml - string +# ^ punctuation.separator.sequence.yaml +# ^^^ meta.string.yaml string.quoted.single.yaml +# ^^^ invalid.illegal.unexpected.yaml - string +# ^ punctuation.separator.key-value.mapping.yaml +# ^^^ meta.string.yaml string.quoted.single.yaml +# ^^^ invalid.illegal.unexpected.yaml - string +# ^ punctuation.definition.mapping.end.yaml + {? !!str 'key' : !!str value, # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping - meta.mapping meta.mapping # ^^^^^^^^^^^^ meta.mapping.value