Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spec] Text format #471

Merged
merged 35 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fa6ee73
Start on text format
rossberg Apr 27, 2017
cefc934
Core syntax done
rossberg May 2, 2017
fed5963
Lexical
rossberg May 3, 2017
748ccac
Disallow control characters in strings
rossberg May 3, 2017
006f359
Lexical; index context
rossberg May 4, 2017
26b9df9
Unicode
rossberg May 5, 2017
6cfc342
Finish
rossberg May 8, 2017
e2f42d3
Merge branch 'master' into spec.textual
rossberg May 8, 2017
5cac42d
Locals, params
rossberg May 8, 2017
de44c0c
Reject malformed UTF-8 sources
rossberg May 9, 2017
ac11a6c
Inline types
rossberg May 9, 2017
818b4cc
Free module ordering
rossberg May 10, 2017
5658fab
Free module ordering
rossberg May 10, 2017
dfaa467
More abbreviations
rossberg May 10, 2017
7907caa
Complete
rossberg May 11, 2017
3cae95a
Merge branch 'spec.exec.1' into spec.textual
rossberg May 11, 2017
bb30331
Fix various xref and TeX bugs
rossberg May 11, 2017
998078c
Merge branch 'spec.exec.1' into spec.textual
rossberg May 11, 2017
b184b66
C&P typo
rossberg May 11, 2017
ef40721
Typos
rossberg May 11, 2017
a902130
binji's comments
rossberg May 12, 2017
27da124
Update paper
rossberg May 15, 2017
1a7cbed
Merge branch 'spec.exec.1' into spec.textual
rossberg May 15, 2017
27b2ad5
[spec] Execution: conventions, runtime, instructions (#467)
rossberg May 16, 2017
a768935
Merge branch 'master' into spec.textual
rossberg May 16, 2017
7fc3ba7
Stricter lexical rules for token separation
rossberg May 16, 2017
302d843
Parens are tokens too
rossberg May 16, 2017
d1469fa
Update interpreter to match text format spec
rossberg May 16, 2017
678dade
Support .wat files
rossberg May 17, 2017
6bfd70e
Forgot added test file
rossberg May 17, 2017
bcec37f
Fix tokenisation
rossberg May 17, 2017
2e52a8a
More Unicode-related fixes in the interpreter
rossberg May 29, 2017
997a258
Comments
rossberg May 29, 2017
47b7405
Fix Latex
rossberg May 29, 2017
f1f24e4
Rename text to string token
rossberg Jun 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions document/appendix-textual/index.rst

This file was deleted.

4 changes: 2 additions & 2 deletions document/binary/conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ In order to distinguish symbols of the binary syntax from symbols of the abstrac
* :math:`B^n` is a sequence of :math:`n\geq 0` iterations of :math:`B`.

* :math:`B^\ast` is a possibly empty sequence of iterations of :math:`B`.
(This is a shorthand for :math:`A^n` used where :math:`n` is not relevant.)
(This is a shorthand for :math:`B^n` used where :math:`n` is not relevant.)

* :math:`B^?` is an optional occurrence of :math:`B`.
(This is a shorthand for :math:`A^n` where :math:`n \leq 1`.)
(This is a shorthand for :math:`B^n` where :math:`n \leq 1`.)

* :math:`x{:}B` denotes the same language as the nonterminal :math:`B`, but also binds the variable :math:`x` to the attribute synthesized for :math:`B`.

Expand Down
34 changes: 14 additions & 20 deletions document/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ The only exception are :ref:`structured control instructions <binary-instr-contr
.. _binary-instr-control:
.. index:: control instructions, structured control, label, block, branch, result type, label index, function index, type index, vector, polymorphism
pair: binary format; instruction
single: abstract syntax; instruction

Control Instructions
~~~~~~~~~~~~~~~~~~~~

:ref:`Control instructions <syntax-instr-control>` have varying encodings. For structured instructions, the nested instruction sequences are terminated with explicit opcodes for |END| and |ELSE|.

.. _valid-nop:
.. _valid-unreachable:
.. _valid-block:
.. _valid-loop:
.. _valid-if:
.. _valid-br:
.. _valid-br_if:
.. _valid-br_table:
.. _valid-return:
.. _valid-call:
.. _valid-call_indirect:
.. _binary-nop:
.. _binary-unreachable:
.. _binary-block:
.. _binary-loop:
.. _binary-if:
.. _binary-br:
.. _binary-br_if:
.. _binary-br_table:
.. _binary-return:
.. _binary-call:
.. _binary-call_indirect:

.. math::
\begin{array}{llclll}
Expand All @@ -51,8 +50,8 @@ Control Instructions
&\Rightarrow& \IF~\X{rt}~\X{in}_1^\ast~\ELSE~\X{in}_2^\ast~\END \\ &&|&
\hex{0C}~~l{:}\Blabelidx &\Rightarrow& \BR~l \\ &&|&
\hex{0D}~~l{:}\Blabelidx &\Rightarrow& \BRIF~l \\ &&|&
\hex{0E}~~l^\ast{:}\Bvec(\Blabelidx)~~l_N{:}\Blabelidx &\Rightarrow&
\BRTABLE~l^\ast~l_N \\ &&|&
\hex{0E}~~l^\ast{:}\Bvec(\Blabelidx)~~l_N{:}\Blabelidx
&\Rightarrow& \BRTABLE~l^\ast~l_N \\ &&|&
\hex{0F} &\Rightarrow& \RETURN \\ &&|&
\hex{10}~~x{:}\Bfuncidx &\Rightarrow& \CALL~x \\ &&|&
\hex{11}~~x{:}\Btypeidx &\Rightarrow& \CALLINDIRECT~x \\
Expand All @@ -65,7 +64,6 @@ Control Instructions
.. _binary-instr-parametric:
.. index:: value type, polymorphism
pair: binary format; instruction
single: abstract syntax; instruction

Parametric Instructions
~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -86,7 +84,6 @@ Parametric Instructions
.. _binary-instr-variable:
.. index:: variable instructions, local index, global index
pair: binary format; instruction
single: abstract syntax; instruction

Variable Instructions
~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -113,8 +110,7 @@ Variable Instructions
.. _binary-instr-memory:
.. _binary-memarg:
.. index:: memory instruction, memory index
pair: validation; instruction
single: abstract syntax; instruction
pair: binary format; instruction

Memory Instructions
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -168,7 +164,6 @@ Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with
.. _binary-instr-numeric:
.. index:: numeric instruction
pair: binary format; instruction
single: abstract syntax; instruction

Numeric Instructions
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -370,7 +365,6 @@ All other numeric instructions are plain opcodes without any immediates.
.. _binary-expr:
.. index:: expression
pair: binary format; expression
single: abstract syntax; expression
single: expression; constant

Expressions
Expand Down
28 changes: 5 additions & 23 deletions document/binary/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ except that :ref:`function definitions <syntax-func>` are split into two section
.. _binary-globalidx:
.. _binary-localidx:
.. _binary-labelidx:
.. index:: index, index space, type index, function index, table index, memory index, global index, local index, label index
.. index:: index, type index, function index, table index, memory index, global index, local index, label index
pair: binary format; type index
pair: binary format; function index
pair: binary format; table index
pair: binary format; memory index
pair: binary format; global index
pair: binary format; local index
pair: binary format; label index
single: abstract syntax; type index
single: abstract syntax; function index
single: abstract syntax; table index
single: abstract syntax; memory index
single: abstract syntax; global index
single: abstract syntax; local index
single: abstract syntax; label index

Indices
~~~~~~~
Expand Down Expand Up @@ -112,7 +105,6 @@ Their contents consist of a :ref:`name <syntax-name>` further identifying the cu
.. _binary-type:
.. index:: ! type section, type definition
pair: binary format; type section
single: abstract syntax; type definition
pair: section; type

Type Section
Expand All @@ -132,7 +124,6 @@ It decodes into a vector of :ref:`function types <syntax-functype>` that represe
.. _binary-import:
.. index:: ! import section, import, name, function type, table type, memory type, global type
pair: binary format; import
single: abstract syntax; import
pair: section; import

Import Section
Expand Down Expand Up @@ -160,7 +151,6 @@ It decodes into a vector of :ref:`imports <syntax-import>` that represent the |I
.. _binary-func:
.. index:: ! function section, function, type index, function type
pair: binary format; function
single: abstract syntax; function
pair: section; function

Function Section
Expand All @@ -181,7 +171,6 @@ The |LOCALS| and |BODY| fields of the respective functions are encoded separatel
.. _binary-table:
.. index:: ! table section, table, table type
pair: binary format; table
single: abstract syntax; table
pair: section; table

Table Section
Expand All @@ -203,7 +192,6 @@ It decodes into a vector of :ref:`tables <syntax-table>` that represent the |TAB
.. _binary-mem:
.. index:: ! memory section, memory, memory type
pair: binary format; memory
single: abstract syntax; memory
pair: section; memory

Memory Section
Expand All @@ -225,7 +213,6 @@ It decodes into a vector of :ref:`memories <syntax-mem>` that represent the |MEM
.. _binary-global:
.. index:: ! global section, global, global type, expression
pair: binary format; global
single: abstract syntax; global
pair: section; global

Global Section
Expand All @@ -248,7 +235,6 @@ It decodes into a vector of :ref:`globals <syntax-global>` that represent the |G
.. _binary-export:
.. index:: ! export section, export, name, index, function index, table index, memory index, global index
pair: binary format; export
single: abstract syntax; export
pair: section; export

Export Section
Expand Down Expand Up @@ -276,7 +262,6 @@ It decodes into a vector of :ref:`exports <syntax-export>` that represent the |E
.. _binary-start:
.. index:: ! start section, start function, function index
pair: binary format; start function
single: abstract syntax; start function
single: section; start
single: start function; section

Expand All @@ -299,7 +284,6 @@ It decodes into an optional :ref:`start function <syntax-start>` that represents
.. _binary-elem:
.. index:: ! element section, element, table index, expression, function index
pair: binary format; element
single: abstract syntax; element
pair: section; element
single: table; element
single: element; segment
Expand All @@ -324,7 +308,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
.. _binary-local:
.. index:: ! code section, function, local, type index, function type
pair: binary format; function
single: abstract syntax; function
pair: binary format; local
pair: section; code

Code Section
Expand Down Expand Up @@ -360,14 +344,14 @@ denoting *count* locals of the same value type.
&\Rightarrow& \X{code} & (\X{size} = ||\Bfunc||) \\
\production{function} & \Bfunc &::=&
(t^\ast)^\ast{:}\Bvec(\Blocals)~~e{:}\Bexpr
&\Rightarrow& \F{concat}((t^\ast)^\ast), e^\ast
& (|\F{concat}((t^\ast)^\ast)| < 2^{32}) \\
&\Rightarrow& \concat((t^\ast)^\ast), e^\ast
& (|\concat((t^\ast)^\ast)| < 2^{32}) \\
\production{locals} & \Blocals &::=&
n{:}\Bu32~~t{:}\Bvaltype &\Rightarrow& t^n \\
\end{array}

Here, :math:`\X{code}` ranges over pairs :math:`(\valtype^\ast, \expr)`.
The meta function :math:`\F{concat}((t^\ast)^\ast)` denotes the sequence of types formed by concatenating all sequences :math:`t_i^\ast` in :math:`(t^\ast)^\ast`.
The meta function :math:`\F{concat}((t^\ast)^\ast)` concatenates all sequences :math:`t_i^\ast` in :math:`(t^\ast)^\ast`.
Any code for which the length of the resulting sequence is out of bounds of the maximum size of a :ref:`vector <syntax-vec>` is malformed.

.. note::
Expand All @@ -379,7 +363,6 @@ Any code for which the length of the resulting sequence is out of bounds of the
.. _binary-data:
.. index:: ! data section, data, memory, memory index, expression, byte
pair: binary format; data
single: abstract syntax; data
pair: section; data
single: memory; data
single: data; segment
Expand All @@ -405,7 +388,6 @@ It decodes into a vector of :ref:`data segments <syntax-data>` that represent th
.. _binary-version:
.. index:: module, section, type definition, function type, function, table, memory, global, element, data, start function, import, export, context, version
pair: binary format; module
single: abstract syntax; module

Modules
~~~~~~~
Expand Down
16 changes: 3 additions & 13 deletions document/binary/types.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
.. _binary-type:
.. index:: type
pair: binary format; type
single: abstract syntax; type

Types
-----

.. _binary-valtype:
.. index:: value type
pair: binary format; value type
single: abstract syntax; value type

Value Types
~~~~~~~~~~~
Expand All @@ -34,7 +32,6 @@ Value Types
.. _binary-blocktype:
.. index:: result type, value type
pair: binary format; result type
single: abstract syntax; result type

Result Types
~~~~~~~~~~~~
Expand All @@ -55,7 +52,6 @@ The only :ref:`result types <syntax-resulttype>` occurring in the binary format
.. _binary-functype:
.. index:: function type, value type, result type
pair: binary format; function type
single: abstract syntax; function type

Function Types
~~~~~~~~~~~~~~
Expand All @@ -73,7 +69,6 @@ Function Types
.. _binary-limits:
.. index:: limits
pair: binary format; limits
single: abstract syntax; limits

Limits
~~~~~~
Expand All @@ -90,8 +85,7 @@ Limits

.. _binary-memtype:
.. index:: memory type, limits, page size
single: binary format; memory type
pair: abstract syntax; memory type
pair: binary format; memory type

Memory Types
~~~~~~~~~~~~
Expand All @@ -105,13 +99,11 @@ Memory Types
\end{array}


.. _syntax-tabletype:
.. _syntax-elemtype:
.. _binary-tabletype:
.. _binary-elemtype:
.. index:: table type, element type, limits
pair: binary format; table type
pair: binary format; element type
single: abstract syntax; table type
single: abstract syntax; element type

Table Types
~~~~~~~~~~~
Expand All @@ -131,8 +123,6 @@ Table Types
.. index:: global type, mutability, value type
pair: binary format; global type
pair: binary format; mutability
single: abstract syntax; global type
single: abstract syntax; mutability

Global Types
~~~~~~~~~~~~
Expand Down
Loading