Sublime Forum

Syntax Fun

#61

Here is an example of how I imagine this to work:

[code]- plain - plain ? plain : plain: plain

<- -string

^ -string

^ -string

^ -string

^ -string

^ -string

^ -string

^ -string

^ -string

  • plain - plain ? plain : plain: plain
    #.^^^^^…^^^^^…^^^^^…^^^^^…^^^^^ string.unquoted.plain

<- -string.unquoted.plain

[/code]

^ represents a supposed match, . represents a supposed “not match” and (space) represents “don’t care”
I would use -, but that is already used for negative selectors and thus ambiguous.

Edit: This example is actually wrong, but you get the idea.

0 Likes

#62

I hadn’t really considered rolling in a NOT character with it, but that’s a nice touch. It would make for much more expressive test blocks when we can express a larger logical idea with a single line. +1

0 Likes

#63

Another thing I ran into with block scalars in YAML: There are situations where you can not test a certain line because a comment is not allowed in the following line. A way to test against line " - " would be nice, where I could provide “” in the comment line somehow.

Other example would be multi-line strings with a newline escape (backslash before newline). Obviously the next line has to be a string as well and can’t be a comment matching against the escaped newline in the first line.

0 Likes

#64

@jps is there anything planned for improving syntax tests to be able to test multiple positions in one line, as I proposed earlier?

I have written a couple syntax test files for YAML (and intend to write more tests for future syntaxes) and this change would reduce the noise from comment lines greatly.
It would also promote writing more precise tests just because it gets easier. I resorted to only test against meaningful posititions in a line because of that.

0 Likes