Overriding Preform grammar in a language extension in Inform 10

I’m trying to figure out how to include some Preform tries in a language extension in Inform 10, which is proving to be a hard task.

The Inform documentation (which I have been informed reflects the current development version of Inform, not the currently released 10.1.2) What This Module Does for the inflections-module says the following:

§12. Naming conventions. Tries are highly language specific, and would need rewriting for every language. The tries for English are supplied in English Inflections, but that’s just for convenience; other languages should supply them in the Inform source text of the relevant language extension, or in Syntax.preform files.

It is not clear to me where I should put my own Syntax.preform file. It seems like Inform’s internal mkscript file, which creates the English language’s Syntax.preform file out of a web of stuff including the inflections-module, puts it in English Language’s Materials/Languages/English/, so I’ve tried to put it in the corresponding place (as well as the directory corresponding to Languages/English (because I think an extension having a Materials/ subdirectory is a development feature, but I’m not even sure) to no avail - it never seems to be compiled, evidenced by the fact that I put lots of non-Preform gibberish there and Inform didn’t complain.

Anyway, the Guide to Language Bundles documentation seems to imply that Syntax.preform is mostly used for language bundles where the Language of Syntax is changed, not just the Language of Play (although of course it might just be required in that case, but still allowed):

If the user tries to build a project “scritto in italiano”, then Inbuild will read a file of Preform declarations called Syntax.preform inside the bundle: in this example, at Italian/Syntax.preform. Should such a file not exist (or not declare any nonterminals) then Inform will produce a problem like so:

Problem. The project says that its syntax is written in a language other than
English (specifically, Italian), but the language bundle for that language does not provide a file of Preform definitions.

So I tried to include the Preform trie inside of my language extension instead, the way other language extensions did in Inform 7. This works insofar that the Preform is compiled, but it seems it doesn’t properly override the English Preform. For example, if I try to change the plural ending, it still uses the English ones. As a more obvious example, this:

Include (-
language Danish

<indefinite-article> ::=
	[Danish indefinite articles here]
-) in the Preform grammar. 

Gives the following error:

Problem. There’s a problem in Inform’s linguistic grammar, which is probably set by a translation extension. The problem occurs in the definition of : nonterminal internal in one definition and regular in another.

The nonterminal <indefinite-article> is indeed marked as internal in English Language’s Syntax.preform file, but I would think I was overriding that one instead of trying to redefine it, or at least that’s what the naming conventions lead me to believe:

Except at the very top level, translators are free to created new tries and name them as they please, but the top-level tries must have the same names that they have here. For example, the Spanish implementation of

    <singular-noun-to-its-indefinite-article>

may look entirely unlike its English version, but at the top level it still has to have that name.

So I’m thinking I might need to use Syntax.preform after all, so it’s read in the correct order? I’m not sure. I’m a bit at a loss here.

I’m apparently not the only person frustrated with the state of translation:

(@otistdog, you apparently got it to work never said how…)

If anyone can help, I’d be very grateful!

2 Likes

The only dabbling I’ve done in Preform is the kind of stuff I’ve posted – only ever in 6M62, not anything more recent. All of it is composed of a whole lot of guesswork (and some of it possibly only working due to the unwitting exploitation of bugs). Also, I’ve only tried to add to the Preform definitions, never to replace existing ones.

I wish I could say that I understood Preform in any real way. @Zed has a better handle on it than I do, I think.

1 Like

Hello Tobias!

I’ve worked extensively with this version of Inform while developing a full Greek language extension as part of my thesis, so I’ve had to experiment quite a bit with Preform, tries, and the internals of the language modules.

Much like what you’re encountering, I found that many of the mechanisms surrounding the Language of Play and the Language of Syntax are undocumented or behave differently from what the official documentation implies. Almost everything I achieved required systematic trial-and-error, because the compiler’s treatment of Preform files and linguistic overrides is far from transparent in the current public releases of Inform 10.

You may find some useful hints or inspiration by looking through my implementation, even if Greek isn’t familiar territory. The challenges you describe - especially with overriding English tries, dealing with internal vs. regular non-terminals, and getting a Syntax.preform file to be recognized at the right point in the build process—were all issues I had to navigate as well.

Unfortunately, there is no single, well-defined workflow for developing a full language extension in recent Inform 7/10 versions. Getting Preform rules to apply correctly often requires experimentation with placement, ordering, and interactions with the built-in English Language bundle.

You can get some inspiration from my work, even though Greek will most certainly be not familiar to you.

3 Likes

Awesome, thanks so much! That’ll definitely be a big help. I’ve been looking at the French language bundle, but that was abandoned because of problems with the newer versions of Inform :melting_face:

In fact, with the most recent development version of Inform I’m currently getting a segmentation fault when building with my language bundle, so maybe I should just start fresh with your bundle as a template…

1 Like

Maintainer of the French extension here! I don’t have the time right now, but I something comes to mind I’ll try to help.

On the French repo there’s an old branch for Inform 10 that compiled (and it did have some Preform), but that was before the language bundles were introduced in the development version of Inform.

(The actual reason the development of the French translation has been abandoned is that I lost all motivation seeing all the features being developed to make translations better but having no proper Inform releases in years – which means most authors would not be able to use the translation.)

6 Likes

I’m not sure if this is something you had to navigate, but the problem I’m having now is getting Inform to recognize plurals in my language.

My language extension works fine without any Preform at all, until I write something like “Foo translates into Danish as Bar.” Then it doesn’t compile, saying the following:

→ An error occurred with the Preform syntax used to specify the grammar of
source text. If this occurs with English, that’s a bug in the compiler, and
should be reported. But if it occurs with languages other than English,
there’s an issue with the language definition, which should be reported to
its maintainer. At any rate, this compilation can’t go further. The
nonterminal causing problems is ‘noun-declension’. The natural language
affected is ‘Danish language’. The problem as reported by Preform is: noun
declensions seem not to be provided for this language.
→ An error occurred with the Preform syntax used to specify the grammar of
source text. If this occurs with English, that’s a bug in the compiler, and
should be reported. But if it occurs with languages other than English,
there’s an issue with the language definition, which should be reported to
its maintainer. At any rate, this compilation can’t go further. The
nonterminal causing problems is ‘grammatical-case-names’. The natural
language affected is ‘Danish language’. The problem as reported by Preform
is: not provided for this language.

That makes sense. If I include those definitions in the Preform grammar (in my extension - I still haven’t found a way to make it read a Syntax.preform file), the error message goes away, and the project builds. So that must mean that including Preform works, and it’s reading my inclusions.

However, if I try to add a <singular-noun-to-its-plural> to that Preform grammar in order to have plural inflections of nouns, that doesn’t work - it still uses the English plural inflections. So there’s still something I don’t understand here…

EDIT:

Oooookay, I got a step further by experimentation! This doesn’t work:

An ox is a kind of animal. [ Plural is set to “oxen”, so it’s following English grammar ]

However, this works:

An ox is a kind of animal. Ox translates into Danish as okse. [ Here the plural is correctly set in Danish. ]

That makes sense, in a way, I suppose, although it’s a little unintuitive. I guess this means authors need to define any object in both English and Danish, even though I’ve set my extension to both “played” (language of play) and “written” (language of syntax).

I’m sure my Preform adventures will continue, but now I’m having problems with defining adjectives. I think that looks like a bug in Inform, though, so I reported it, but if someone has encountered this before, please let me know!