Gram.t Example Does Not Work

This may matter to very few people, but there is a file called “gram.t” to show some aspects of grammar production. If you try to compile that as is, you get:

If you correct that, it still doesn’t compile because you have to add:

Once you add that, it works. But now try this:

So the program doesn’t work regardless.

Why even bother with this? Well, this was basically done while trying to make sense of the material on this page:

tads.org/t3doc/doc/sysman/gramprod.htm

The example provided on that page is distributed and doesn’t make a lot of sense. So I was hoping gram.t would fill in the gaps. And it largely does, conceptually. But I was trying to build up gram.t on the fly, as it were, so I could better understand the structural aspects of TADS 3. I was getting the above error (about indexing) in my own code and couldn’t figure out what I was missing. So I finally just tried gram.t as provided and the above is the experience.

gram.t? Where did you got that file? I don’t have it in frobtads distribution. I’m not by any means an expert on TADS parser and don’t know what you want, but setting libGlobal.parserDebugMode = true; could help you to look under the hood of parser and here is a little map I made several years back: http://tads.cz/en/parser-enpdf/file

Ah, interesting. The Windows distribution comes with a samples directory that includes files like anonobj.j, bantest.t, calc.t, gram.t, and so on. So I was looking at those because they sync up with the System Manual documentation.

Here I’m just trying to make some of the System Manual material a little more actionable by providing (or refining existing) examples that prove out some of the behavior that is discussed. Also, since that gram.t file is included in the distribution – well, the Windows one at least – I want to make sure TADS is distributed with a version that actually works. With the error I’m seeing, I can’t tell if the issue is because the script is just bad or because something had changed with TADS but was not reflected in the scripts or documentation provided.

To be sure, none of this would in any way stop someone from starting up work with a game. But I’m introducing TADS as part of a wider context of introducing programming, so I’m micro-focusing on a few spots that might not have received as much attention.

I’ve downloaded TADS System Source Code (porting kit) and it seems this file is not part of samples, but rather part of test suite. And given there is also gram2.t which is little different (apart from other changes it has tok.h included) and has counterpart in log directory (gram.t does not), maybe gram.t is old deprecated version. Try the gram2.t.

Sweeeeeet!

I wasn’t even aware of all that stuff. Thanks for bringing that to my attention. I’ll play around with those files.

Initially, gram2.t is even worse. Just a basic compile leads to:

This might be due to some need to specify a particular command line switch. I see a comment in the file about “copied from _main.t, which we don’t include in this test.” So I thought maybe I needed to do -nodef as part of the command line switches but that doesn’t work either.

I haven’t tried playing around with all files in that test folder yet but so far I have found a few that don’t seem to work (sometimes compile errors, sometimes runtime errors) or don’t match the output in the associated .log files. Still investigating.

These files are not supposed to be compiled as-is. They are part of the test suite and built in “special” ways.

You can read their code though and copy relevant parts to a normal project for experimenting there.

Yeah, that’s what I’m finding with the test files as part of the porting kit; these seem to have been built with a test harness approach. Gram.t, which is included as a standalone with the official distribution, however, seems to be in a different category. It just seems to have a bug in it. Actually, perhaps a few. And its implementation doesn’t entirely match the System Manual page I referenced.

Again, I say all this totally realizing that 99% of people using TADS may never even see that file or care about it even if they do.