From 8e1a000f201db5b343b05c32607634ca78cb8b7f Mon Sep 17 00:00:00 2001 From: Genta Kamitani Date: Mon, 28 Dec 2020 22:10:18 +0900 Subject: [PATCH] :books: doc: add notes and examples of Watson Representation --- doc/spec.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/spec.md b/doc/spec.md index 49c72e9..325b7d2 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -276,6 +276,8 @@ The correspondence between VM's instructions and its ASCII representation varies Each lexer has its own mode. The mode of a lexer is either `A` or `S`. The initial mode of a lexer is `A` unless otherwise specified. +Every time the lexer processes Snew, it flips its mode. + The complete conversion table between instructions and their Watson Representations are as follows: @@ -305,3 +307,33 @@ The complete conversion table between instructions and their Watson Representati |Gpop |# |e | |Gswp |% |: | +Any character that is not in this table is simply ignored. + +### Examples 1 + +``` +B +``` + +is converted into + +``` +Inew +``` + +since the initial state of the lexer is A and the corresponding instruction of a character `B` is `Inew`. + +### Example 2 + +``` +b?b +``` + +is converted into + +``` +Ishl Snew Fnan +``` + +since the lexer changes its mode to S after processing a character `?` and then converts the last character `b` using the `S` column of the conversion table. +