WebAssembly Text Syntax
wast (web assembly text format) sublime syntax definition
Details
Installs
- Total 2K
- Win 797
- Mac 562
- Linux 528
| Jun 27 | Jun 26 | Jun 25 | Jun 24 | Jun 23 | Jun 22 | Jun 21 | Jun 20 | Jun 19 | Jun 18 | Jun 17 | Jun 16 | Jun 15 | Jun 14 | Jun 13 | Jun 12 | Jun 11 | Jun 10 | Jun 9 | Jun 8 | Jun 7 | Jun 6 | Jun 5 | Jun 4 | Jun 3 | Jun 2 | Jun 1 | May 31 | May 30 | May 29 | May 28 | May 27 | May 26 | May 25 | May 24 | May 23 | May 22 | May 21 | May 20 | May 19 | May 18 | May 17 | May 16 | May 15 | May 14 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Mac | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| Linux | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
wast-sublime-syntax
WAST, the text format of WebAssembly, is a very low-level but human-readable and writable stack-based language. It is a tree of s-expressions, generally, though instructions can also be written linearly.
This is a Sublime Syntax definition for WAST. It requires Sublime Text version 3 or greater.
Highlighting examples
Using the themes Monokai, Propeller, Welded, and Excelsior (from ES Sublime) respectively:
I haven’t included any customized themes presently. I may add one later that highlights s-expressions by depth, since I think it would be an interesting experiment.
Symbols
Functions, globals and types will appear in the local symbol list if they have been given names, but not if they’re anonymous (that is, only referenced by index).
Exports will appear in both the local and global symbol lists.
Other meta-features
There is a definition for comments but, presently, no definition for indents. I still don’t know quite what that should look like — there seem to be some very different approaches to formatting s-expressions in the wild and I don’t have enough context yet to know which to choose. (Feedback or PRs welcome.)
Scopes
The following scopes are provided. Mostly this sticks to TextMate conventions
but with additional precision in some cases and, for certain stuff, minor abuse
of not-quite-applicable-but-common scopes in order to help improve compatibility
with existing color schemes. In particular, I used storage.type.constant in
order to force distinct coloring for some things that are semantically not all
“constant”.
comment.block.wastcomment.line.wastconstant.character.escape.byte.wastconstant.character.escape.char.wastconstant.numeric.float.wastconstant.numeric.integer.wastentity.name.export.wastentity.name.function.wastentity.name.memory.wastentity.name.module.import.wastentity.name.module.wastentity.name.statement.wastentity.name.table.wastentity.name.type.wastinvalid.illegal.wastkeyword.control.conditional.wastkeyword.control.flow.wastkeyword.declaration.offset.wastkeyword.operator.assignment.wastkeyword.operator.word.wastkeyword.other.export.wastkeyword.other.import.wastkeyword.other.module.wastkeyword.other.offset.wastkeyword.other.start.wastmeta.block.conditional.wastmeta.block.loop.wastmeta.block.wastmeta.function-call.wastmeta.group.limit.wastmeta.invocation.wastmeta.s-expression.data.wastmeta.s-expression.elem.wastmeta.s-expression.export-description.wastmeta.s-expression.export.wastmeta.s-expression.expression.wastmeta.s-expression.function.wastmeta.s-expression.functype.wastmeta.s-expression.global.wastmeta.s-expression.globaltype.wastmeta.s-expression.import.wastmeta.s-expression.instruction.wastmeta.s-expression.local.wastmeta.s-expression.memory.wastmeta.s-expression.module.wastmeta.s-expression.offset.wastmeta.s-expression.param.wastmeta.s-expression.result.wastmeta.s-expression.start.begin.wastmeta.s-expression.table.wastmeta.s-expression.type.wastmeta.s-expression.typeuse.wastpunctuation.definition.block.begin.wastpunctuation.definition.block.conditional.begin.wastpunctuation.definition.block.conditional.end.wastpunctuation.definition.block.end.wastpunctuation.definition.block.loop.begin.wastpunctuation.definition.block.loop.end.wastpunctuation.definition.comment.begin.wastpunctuation.definition.comment.end.wastpunctuation.definition.data.begin.wastpunctuation.definition.data.end.wastpunctuation.definition.elem.begin.wastpunctuation.definition.elem.end.wastpunctuation.definition.export.begin.wastpunctuation.definition.export.end.wastpunctuation.definition.exportdesc.begin.wastpunctuation.definition.exportdesc.end.wastpunctuation.definition.expression.begin.wastpunctuation.definition.expression.end.wastpunctuation.definition.function.begin.wastpunctuation.definition.function.end.wastpunctuation.definition.functype.begin.wastpunctuation.definition.functype.end.wastpunctuation.definition.global.begin.wastpunctuation.definition.global.end.wastpunctuation.definition.globaltype.begin.wastpunctuation.definition.globaltype.end.wastpunctuation.definition.import.begin.wastpunctuation.definition.import.end.wastpunctuation.definition.instruction.begin.wastpunctuation.definition.instruction.end.wastpunctuation.definition.local.begin.wastpunctuation.definition.local.end.wastpunctuation.definition.memory.begin.wastpunctuation.definition.memory.end.wastpunctuation.definition.module.begin.wastpunctuation.definition.module.end.wastpunctuation.definition.offset.begin.wastpunctuation.definition.offset.end.wastpunctuation.definition.param.begin.wastpunctuation.definition.param.end.wastpunctuation.definition.result.begin.wastpunctuation.definition.result.end.wastpunctuation.definition.start.begin.wastpunctuation.definition.start.end.wastpunctuation.definition.string.begin.wastpunctuation.definition.string.end.wastpunctuation.definition.table.begin.wastpunctuation.definition.table.end.wastpunctuation.definition.type.begin.wastpunctuation.definition.type.end.wastpunctuation.definition.typeuse.begin.wastpunctuation.definition.typeuse.end.wastsource.waststorage.modifier.mutable.waststorage.modifier.result.waststorage.modifier.type.waststorage.modifier.waststorage.type.constant.waststorage.type.data.waststorage.type.elem.waststorage.type.function.waststorage.type.global.waststorage.type.local.waststorage.type.memory.waststorage.type.param.waststorage.type.table.waststorage.type.type.waststring.quoted.double.wastsupport.function.memory.wastsupport.function.numeric.wastsupport.function.variable.wastsupport.type.wastvariable.other.index.wastvariable.other.readwrite.wastvariable.other.wastvariable.parameter.wast
Limitations
As with most languages, Sublime Syntax and Text Mate syntax definitions can model WAST correctly at the lexical level, but newline blindness prevents ideal scoping of some constructs.
In this case, however, there are not many issues that arise from this — really there’s just one. Whenever “(” is followed by a keyword, if there is a newline or a multiline comment between them, this syntax definition will not match that s-expression correctly. Since it would be unusual/unreadable if there really were newlines or comments in that position, I haven’t included any special recovery logic, only this caveat emptor.
Some higher level syntactic constraints are applied, like only allowing one start field, but plenty of other well-formedness constraints are not applied, even where they technically could be expressed in terms of Sublime Syntax.