Closed JordonPhillips closed 2 years ago
I added support for the = default
sugar proposed in https://github.com/awslabs/smithy/pull/920
Whoops, forgot mixins! While I was at it I fixed traits within shape definitions and a handful of bad captures.
This adds support for some of the new idl syntax for 2.0. Namely it adds support for:
!
)= default
)with
statementI do not think it is possible for a TextMate grammar to be able to distinguish between a key and a value in every case when there are no pair separators, though I would love to be proven wrong on this.
TM grammars are regex-based, but crucially regexes can never match across lines. A regex with a newline in the middle, like
foo\nbar
will NEVER match. This is to allow the highlighter to be able to re-start at any line if parsing failed on a previous line. To work around this somewhat, they allow you to change states withbegin
andend
regexes. Since these state changes are regexes and regexes can't span lines, you can't have a complex end state. So you can't simply say "end after parsing a json-like value". Since we have no other indication that a pair is ended, we can't end a pair state if we enter one.For some context, the way the JSON TM grammar works is by having an effective "value" state which is started by
:
and ended by,
or}
. This is what we used to do.Now what we CAN do if we don't care about being 100% accurate in all cases, is try to match the key if it shares a line with the colon. This is the approach I've gone with since I'm willing to bet this will be the case most of the time.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.