Skip to content

Commit 8ca5b92

Browse files
authored
Merge pull request #3 from whitequark/exceptions
Add support for syntax in the exception proposal
2 parents 468f2b2 + 5504835 commit 8ca5b92

File tree

1 file changed

+111
-2
lines changed

1 file changed

+111
-2
lines changed

wast.sublime-syntax

+111-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ variables:
1515
FLOATO: 'f32\.(?:reinterpret[/_]i32|demote[/_]f64)|f64\.(?:promote[/_]f32|reinterpret[/_]i64)'
1616
FLOATP: '[+-]?(?:inf|nan(?::0x{{HEXNUM}})?|{{HEXFLT}}|{{DECFLT}}){{IDTERM}}'
1717
FLOW_1: '(?:nop|return|unreachable){{IDTERM}}'
18-
FLOW_2: 'br(?:_if)?{{IDTERM}}'
18+
FLOW_2: '(?:br(?:_if)?|throw|rethrow){{IDTERM}}'
1919
FLOW_3: 'br_table{{IDTERM}}'
2020
HEXFLT: '0x{{HEXNUM}}(?=[Pp.])(\.{{HEXFRC}})?(?:[Pp][+-]?{{DECNUM}})?'
2121
HEXFRC: (?:{{HEXNUM}})?
@@ -272,6 +272,9 @@ contexts:
272272
- match: 'if{{IDTERM}}'
273273
scope: keyword.control.conditional.wast
274274
push: [ label, if_else_end, else, instructions, resulttype, label ]
275+
- match: 'try{{IDTERM}}'
276+
scope: keyword.control.flow.wast
277+
push: [ label, try_catch_delegate, instructions, resulttype, label ]
275278
- include: instructions_plain
276279
- include: instructions_folded
277280
instructions_folded:
@@ -341,6 +344,58 @@ contexts:
341344
- instructions_folded
342345
- resulttype
343346
- label
347+
- match: '(\(){{WHITES}}*(try){{IDTERM}}'
348+
captures:
349+
1: punctuation.definition.block.begin.wast
350+
2: keyword.control.flow.wast
351+
push:
352+
- - meta_scope: meta.s-expression.instruction.wast
353+
- match: '\)'
354+
scope: punctuation.definition.block.end.wast
355+
pop: true
356+
- match: '(\(){{WHITES}}*(do){{IDTERM}}'
357+
captures:
358+
1: punctuation.definition.block.begin.wast
359+
2: keyword.control.flow.wast
360+
push:
361+
- - meta_scope: meta.s-expression.instruction.wast
362+
- match: '\)'
363+
scope: punctuation.definition.block.end.wast
364+
pop: true
365+
- instructions
366+
- match: '(\(){{WHITES}}*(delegate){{IDTERM}}'
367+
captures:
368+
1: punctuation.definition.block.begin.wast
369+
2: keyword.control.flow.wast
370+
push:
371+
- - meta_scope: meta.s-expression.instruction.wast
372+
- match: '\)'
373+
scope: punctuation.definition.block.end.wast
374+
pop: true
375+
- reference
376+
- match: '(\(){{WHITES}}*(catch){{IDTERM}}'
377+
captures:
378+
1: punctuation.definition.block.begin.wast
379+
2: keyword.control.flow.wast
380+
push:
381+
- - meta_scope: meta.s-expression.instruction.wast
382+
- match: '\)'
383+
scope: punctuation.definition.block.end.wast
384+
pop: true
385+
- instructions
386+
- reference
387+
- match: '(\(){{WHITES}}*(catch_all){{IDTERM}}'
388+
captures:
389+
1: punctuation.definition.block.begin.wast
390+
2: keyword.control.flow.wast
391+
push:
392+
- - meta_scope: meta.s-expression.instruction.wast
393+
- match: '\)'
394+
scope: punctuation.definition.block.end.wast
395+
pop: true
396+
- instructions
397+
- resulttype
398+
- label
344399
# The lookahead here is a hack for if-then to avoid more copypasta contexts
345400
- match: '\((?!{{WHITES}}*then{{IDTERM}})'
346401
scope: punctuation.definition.instruction.begin.wast
@@ -545,7 +600,7 @@ contexts:
545600
pop: true
546601
- match: '.'
547602
scope: invalid.illegal.wast
548-
- - match: '(\(){{WHITES}}*(func|global|memory|table){{IDTERM}}'
603+
- - match: '(\(){{WHITES}}*(func|global|memory|table|tag){{IDTERM}}'
549604
captures:
550605
1: punctuation.definition.exportdesc.begin.wast
551606
2: storage.modifier.wast
@@ -632,12 +687,19 @@ contexts:
632687
captures:
633688
1: entity.name.type.wast
634689
pop: true
690+
modulefield_tag:
691+
- match: '(\(){{WHITES}}*(tag){{IDTERM}}'
692+
captures:
693+
1: punctuation.definition.tag.begin.wast
694+
2: storage.type.constant.wast storage.type.tag.wast
695+
push: [ tag_end, tag_type, tag_import, abbreviated_export, tag_name ]
635696
modulefields_IMPORT_START:
636697
- include: modulefield_data
637698
- include: modulefield_element
638699
- include: modulefield_export
639700
- include: modulefield_import
640701
- include: modulefield_type
702+
- include: modulefield_tag
641703
- match: '{{STARTS}}'
642704
captures:
643705
1: punctuation.definition.start.begin.wast
@@ -651,6 +713,7 @@ contexts:
651713
- include: modulefield_export
652714
- include: modulefield_import
653715
- include: modulefield_type
716+
- include: modulefield_tag
654717
- match: '(?=.)'
655718
set: modulefields_REST
656719
modulefields_REST:
@@ -662,6 +725,7 @@ contexts:
662725
- include: modulefield_memory
663726
- include: modulefield_table
664727
- include: modulefield_type
728+
- include: modulefield_tag
665729
- match: '(?=.)'
666730
pop: true
667731
modulefields_START:
@@ -831,6 +895,51 @@ contexts:
831895
captures:
832896
1: entity.name.table.wast
833897
pop: true
898+
tag_end:
899+
- meta_scope: meta.s-expression.tag.wast
900+
- match: '\)'
901+
scope: punctuation.definition.tag.end.wast
902+
pop: true
903+
- match: '.'
904+
scope: invalid.illegal.wast
905+
pop: true
906+
tag_import:
907+
- match: '(\(){{WHITES}}*(import){{IDTERM}}'
908+
captures:
909+
1: punctuation.definition.import.begin.wast
910+
2: keyword.other.import.wast
911+
set: [ import_end, import_names ]
912+
- match: '(?=.)'
913+
pop: true
914+
tag_name:
915+
- match: '({{IDNAME}})|'
916+
captures:
917+
1: entity.name.tag.wast
918+
pop: true
919+
tag_type:
920+
- include: param
921+
- match: '(?=.)'
922+
pop: true
923+
try_catch_delegate:
924+
- meta_scope: meta.block.wast
925+
- match: 'delegate{{IDTERM}}'
926+
scope: keyword.control.flow.wast
927+
set: [ reference ]
928+
- match: '(?=.)'
929+
set: [ try_catch ]
930+
try_catch:
931+
- meta_scope: meta.block.wast
932+
- match: 'catch{{IDTERM}}'
933+
scope: keyword.control.flow.wast
934+
push: [ instructions, reference ]
935+
- match: 'catch_all{{IDTERM}}'
936+
scope: keyword.control.flow.wast
937+
push: [ instructions ]
938+
- match: 'end{{IDTERM}}'
939+
scope: keyword.control.flow.wast
940+
pop: true
941+
- match: '.'
942+
scope: invalid.illegal.wast
834943
typeuse:
835944
- match: (?=.)
836945
set:

0 commit comments

Comments
 (0)