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

Ch 17. Grammar: Various Problems #66

Open
8 tasks
tajmone opened this issue Mar 1, 2020 · 2 comments
Open
8 tasks

Ch 17. Grammar: Various Problems #66

tajmone opened this issue Mar 1, 2020 · 2 comments
Assignees
Labels
📋 Roody Notes From @roodyyogurt annotated PDF of Hugo Book 🕑 pending approval Issue requires approval by Ken Tessman 🕑 pending decision Issue requires decisions by maintainers 💀 bug Something isn't working 💀 code problems Problems with code examples or syntax definitions. 💀 text problems Text problems, typos or obsolete contents. ⚠️ important Priority: High
Milestone

Comments

@tajmone
Copy link
Owner

tajmone commented Mar 1, 2020

  • Get @tessman approval for these changes.
  • Fix document source.
  • Document the changes in CHANGES.md.
  • Document in ChangeLog.
  • Add commented annotation in source file.

In his annotated PDF, @roodyyogurt suggests that the following passage from Ch 17. Grammar is incorrect:

becomes:

000040: 2C 02 x2 x1 y2 y1
000046: 08 66 48 r2 r1
00004B: FF

where $r1r2 is the indexed routine address of DoGet.

The $FF byte marks the end of the current verb definition. Immediately following this is either another verb or xverb token, or a second $FF to indicate the end of the verb table.

and that the line:

000046: 08 66 48 r2 r1

… should be fixed to:

000046: 08 05 66 48 r2 r1
  • Check above amend proposal and fix text accordingly.

Furthermore, @roodyyogurt commented on the sentence "The $FF byte marks the end of the current verb definition.":

Actually there are no $FF bytes at the end of verb definitions. All definitions are run after one another. In each grammar line the asterisk ($08) is followed by a byte that indicates the length of the grammar line excluding the length byte itself.

and regarding the sentence "or a second $FF to indicate the end of the verb table", Roody adds:

The grammar table ends in a single $FF byte. (Also, "verb table" should be "grammar table".)

  • Fix "verb table" into "grammar table".
  • We need to understand how these last comments might impact the text in terms of required adjustments.
@tajmone tajmone added 💀 bug Something isn't working 📋 Roody Notes From @roodyyogurt annotated PDF of Hugo Book labels Mar 1, 2020
@tajmone tajmone added this to the text fixes milestone Mar 1, 2020
@tajmone tajmone changed the title Ch 17: Fix Binary Hugo Example Ch 17: Fix Binary Grammars Example Mar 1, 2020
@tajmone tajmone added 🕑 pending decision Issue requires decisions by maintainers 🕑 pending approval Issue requires approval by Ken Tessman labels Mar 1, 2020
@tajmone tajmone changed the title Ch 17: Fix Binary Grammars Example Ch 17. Grammar: Various Problems Mar 1, 2020
@tajmone tajmone added the ⚠️ important Priority: High label Mar 1, 2020
@tajmone
Copy link
Owner Author

tajmone commented Mar 8, 2020

Related Sections

The above considerations seem to be related to the definitions of the object and xobject grammar tokens ($66 and $67) in App. H, which contain the following admonition notes:

Removed as a token after grammar table is compiled so that object can refer to the object global variable.

and

Removed as a token after grammar table is compiled so that xobject can refer to the xobject global variable.

Some clarifications on what is meant exactly by "Removed as a token after grammar table is compiled" would make the text less cryptic, and any references of which Hugo versions were affected by these changes would be of great help for coders trying to implement alternative interpreters (which need to be backward compatible for games created with older Hugo versions).

@tajmone tajmone added 💀 code problems Problems with code examples or syntax definitions. 💀 text problems Text problems, typos or obsolete contents. labels Mar 8, 2020
@tajmone tajmone pinned this issue Mar 10, 2020
@tajmone
Copy link
Owner Author

tajmone commented Mar 10, 2020

Extra Byte Might Affects Last Example-Line Too

Note that by adding the suggested fix to the original example:

000040: 2C 02 x2 x1 y2 y1
000046: 08 66 48 r2 r1
00004B: FF

it should then become:

000040: 2C 02 x2 x1 y2 y1
000046: 08 05 66 48 r2 r1
00004C: FF

i.e. affecting also the last line address, which should be bumped up one byte (00004B00004C).

Except that if we take into account the other fix proposal:

@roodyyogurt: Actually there are no $FF bytes at the end of verb definitions.

Then the third line should be removed altogether, leaving the example as:

000040: 2C 02 x2 x1 y2 y1
000046: 08 05 66 48 r2 r1

unless that was the (single) $FF indicating the grammar table end (which probably is, since it's in an independent line).

This whole ordeal it's a bit confusing, because we have to take into account also disposing of the "$FF bytes at the end of verb definitions" rule.

Probably the best thing is to compile a Hugo example and look at it's real binary output.

Length Byte Clarification

@roodyyogurt:

In each grammar line the asterisk ($08) is followed by a byte that indicates the length of the grammar line excluding the length byte itself.

In the fixed example this would be the 05 value:

000046: 08 05 66 48 r2 r1
           ^^

so, if I've understood correctly, this length-byte also includes the * token in its count, and all the rest of the line except itself. And in the above example it's 5 because the FF on the following line is not part of the grammar line, but the indicator of the grammar table end.

Are these fixes related to changes in how Hugo handled grammar encodings? i.e. the documentation wasn't update accordingly and still refers to previous Hugo versions?

Adding Comments to Hex Blocks?

I also think that adding comment next to those Hex previews could greatly improve the learning experience. E.g. something like:

000040: 2C 02 x2 x1 y2 y1   ;
000046: 08 05 66 48 r2 r1   ; '*' [line len] object routine# $r1r2
00004C: FF                  ; grammar table end

although finding a consistent convention might not be that easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📋 Roody Notes From @roodyyogurt annotated PDF of Hugo Book 🕑 pending approval Issue requires approval by Ken Tessman 🕑 pending decision Issue requires decisions by maintainers 💀 bug Something isn't working 💀 code problems Problems with code examples or syntax definitions. 💀 text problems Text problems, typos or obsolete contents. ⚠️ important Priority: High
Projects
None yet
Development

No branches or pull requests

2 participants