Are there any analogs in the Standard Library for Roger Firth’s example tokenDict()
, tokenLength()
and tokenPos()
routines for getting information about parsed tokens from the parse array, as seen in his Inform 6 FAQ at http://www.firthworks.com/roger/informfaq/ii.html ? I’ve looked but haven’t spotted any.
I’m thinking that maybe he published those routines because there’s nothing like them in the library?
In parser.h: WordAddress(), WordLength(), WordValue(), NumberWords() etc.
@fredrik, yes – the site hasn’t been maintained for years, however, and it doesn’t reflect recent changes. I noticed that some of the other things that he published in the FAQ were folded into Standard Library 6/11 (e.g. removal of “wall” from the description
and name
of compass
objects, expansion of invent
property functionality to room descriptions). Perhaps these were just missed?
If they don’t exist in Standard Library 6.12.4, Firth’s routines seem like they would be valuable additions. Decoding the parse
array format is a point of confusion to I6 newcomers – especially in light of the misprint in the table on DM4 page 45 [section 2.5, online at DM4 §2: The state of play (with online version not correcting the misprint)], which misinforms. The functions are very short, and they’re even already defined in Z-machine/Glulx compatible format.
[ tokenDict w; ! dictionary value of token 1,2,3...
#Ifdef TARGET_ZCODE;
return parse-->(2*w - 1);
#Ifnot; ! TARGET_GLULX
return parse-->(3*w - 2);
#Endif; ! TARGET_
];
[ tokenLen w; ! length in chars of token 1,2,3...
#Ifdef TARGET_ZCODE;
return parse->(4*w);
#Ifnot; ! TARGET_GLULX
return parse-->(3*w - 1);
#Endif; ! TARGET_
];
[ tokenPos w; ! position in buffer of token 1,2,3...
#Ifdef TARGET_ZCODE;
return parse->(4*w + 1);
#Ifnot; ! TARGET_GLULX
return parse-->(3*w);
#Endif; ! TARGET_
];
@aureas, thank you! I missed those because I was looking for string “parse-
” (to find references to the parse
array).
So, in 6.12.4:
-
WordValue()
does the job oftokenDict()
-
WordLength()
does the job oftokenLen()
-
WordAddress()
does a similar job totokenPos()
I don’t think that WordValue()
is mentioned in the release notes anywhere, but it seems to be new to one of the 6.12 releases. (FYI, @DavidG)
I’ve created an issue at https://gitlab.com/DavidGriffith/inform6lib/-/issues/115 to remind myself to investigate this.
Now that I’ve cleared out a bunch of nasty bugs, I’m revisiting this issue. WordValue()
first appeared in https://gitlab.com/DavidGriffith/inform6lib/-/commit/281c9e7cd4c7db71a0390f0d969d572575b823bf implementing Suggestion 130 (see Inform - Support - Suggestions). I suppose what I could do is mention this in a “Caveats” section of the upcoming release of 6.12.5.