WebAssembly Text Syntax
wast (web assembly text format) sublime syntax definition
Details
Installs
- Total 2K
- Win 734
- Mac 523
- Linux 474
Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 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 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
Linux | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 2 |
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.wast
comment.line.wast
constant.character.escape.byte.wast
constant.character.escape.char.wast
constant.numeric.float.wast
constant.numeric.integer.wast
entity.name.export.wast
entity.name.function.wast
entity.name.memory.wast
entity.name.module.import.wast
entity.name.module.wast
entity.name.statement.wast
entity.name.table.wast
entity.name.type.wast
invalid.illegal.wast
keyword.control.conditional.wast
keyword.control.flow.wast
keyword.declaration.offset.wast
keyword.operator.assignment.wast
keyword.operator.word.wast
keyword.other.export.wast
keyword.other.import.wast
keyword.other.module.wast
keyword.other.offset.wast
keyword.other.start.wast
meta.block.conditional.wast
meta.block.loop.wast
meta.block.wast
meta.function-call.wast
meta.group.limit.wast
meta.invocation.wast
meta.s-expression.data.wast
meta.s-expression.elem.wast
meta.s-expression.export-description.wast
meta.s-expression.export.wast
meta.s-expression.expression.wast
meta.s-expression.function.wast
meta.s-expression.functype.wast
meta.s-expression.global.wast
meta.s-expression.globaltype.wast
meta.s-expression.import.wast
meta.s-expression.instruction.wast
meta.s-expression.local.wast
meta.s-expression.memory.wast
meta.s-expression.module.wast
meta.s-expression.offset.wast
meta.s-expression.param.wast
meta.s-expression.result.wast
meta.s-expression.start.begin.wast
meta.s-expression.table.wast
meta.s-expression.type.wast
meta.s-expression.typeuse.wast
punctuation.definition.block.begin.wast
punctuation.definition.block.conditional.begin.wast
punctuation.definition.block.conditional.end.wast
punctuation.definition.block.end.wast
punctuation.definition.block.loop.begin.wast
punctuation.definition.block.loop.end.wast
punctuation.definition.comment.begin.wast
punctuation.definition.comment.end.wast
punctuation.definition.data.begin.wast
punctuation.definition.data.end.wast
punctuation.definition.elem.begin.wast
punctuation.definition.elem.end.wast
punctuation.definition.export.begin.wast
punctuation.definition.export.end.wast
punctuation.definition.exportdesc.begin.wast
punctuation.definition.exportdesc.end.wast
punctuation.definition.expression.begin.wast
punctuation.definition.expression.end.wast
punctuation.definition.function.begin.wast
punctuation.definition.function.end.wast
punctuation.definition.functype.begin.wast
punctuation.definition.functype.end.wast
punctuation.definition.global.begin.wast
punctuation.definition.global.end.wast
punctuation.definition.globaltype.begin.wast
punctuation.definition.globaltype.end.wast
punctuation.definition.import.begin.wast
punctuation.definition.import.end.wast
punctuation.definition.instruction.begin.wast
punctuation.definition.instruction.end.wast
punctuation.definition.local.begin.wast
punctuation.definition.local.end.wast
punctuation.definition.memory.begin.wast
punctuation.definition.memory.end.wast
punctuation.definition.module.begin.wast
punctuation.definition.module.end.wast
punctuation.definition.offset.begin.wast
punctuation.definition.offset.end.wast
punctuation.definition.param.begin.wast
punctuation.definition.param.end.wast
punctuation.definition.result.begin.wast
punctuation.definition.result.end.wast
punctuation.definition.start.begin.wast
punctuation.definition.start.end.wast
punctuation.definition.string.begin.wast
punctuation.definition.string.end.wast
punctuation.definition.table.begin.wast
punctuation.definition.table.end.wast
punctuation.definition.type.begin.wast
punctuation.definition.type.end.wast
punctuation.definition.typeuse.begin.wast
punctuation.definition.typeuse.end.wast
source.wast
storage.modifier.mutable.wast
storage.modifier.result.wast
storage.modifier.type.wast
storage.modifier.wast
storage.type.constant.wast
storage.type.data.wast
storage.type.elem.wast
storage.type.function.wast
storage.type.global.wast
storage.type.local.wast
storage.type.memory.wast
storage.type.param.wast
storage.type.table.wast
storage.type.type.wast
string.quoted.double.wast
support.function.memory.wast
support.function.numeric.wast
support.function.variable.wast
support.type.wast
variable.other.index.wast
variable.other.readwrite.wast
variable.other.wast
variable.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.