Parser stack overflow

Never mind. I figured it out. Never use “visible” in a grammar tag. Inform 7, ladies and gentlemen.

There’s a character in my WIP who will comment on things in the game of three kinds: (1) any visible thing; (2) any “interesting” thing (where interesting is a property of things); and (3) any visited room.

This all worked fine while there were two kinds: (1) any known thing; and (2) any visited room. But since this would lead to the character being able to comment on any random scenery in the game, which in turn led to ridiculous disambiguation. And who cares if a character can comment on a rock the player saw in the first room of the game?

Anyway, I added the interesting property and edited the understand statements to these:

“ask [someone] about [any interesting invisible thing]” - Quizzing it about
“ask [someone] about [any visible thing]” - Quizzing it about
“ask [someone] about [any visited room]” - Quizzing it about

(I’ve actually tried many variations always with the same result. This was my attempt to make the second noun tags mutually-exclusive, as if that matters.)

These may look familiar from Eric Eve’s Conversation Framework, where they originated.

Unfortunately. now I’m getting

Glulxe fatal error: Stack overflow in callstub.

when typing “ask beck about speeder”.

Trace output:

[ “ask” ask / “beck” beck / “about” about / “speeder” speeder ]
[Parsing for the verb ‘ask’ (16 lines)]

[line 0 * ‘for’ ‘help’ → A101_pleading]
[line rejected for not ending with correct preposition]

[line 1 * ‘about’ scope=Routine(581900) → A66_implicit_quizzing]
[line 1 token 1 word 2 : ‘about’]
[token resulted in failure with error type 1]

[line 2 * ‘about’ scope=Routine(581728) → A66_implicit_quizzing]
[line 2 token 1 word 2 : ‘about’]
[token resulted in failure with error type 1]

[line 3 * ‘for’ scope=Routine(582086) → A68_implicit_requesting]
[line 3 token 1 word 2 : ‘for’]
[token resulted in failure with error type 1]

[line 4 * ‘about’ scope=Routine(582430) → A66_implicit_quizzing]
[line 4 token 1 word 2 : ‘about’]
[token resulted in failure with error type 1]

[line 5 * ‘beck’ ‘for’ ‘help’ → A101_pleading]
[line rejected for not ending with correct preposition]

[line 6 * creature ‘about’ scope=Routine(581542) → A62_quizzing_it_about]
[line 6 token 1 word 2 : creature]
[Object list from word 2]
[Calling NounDomain on location and actor]
[NounDomain called at word 2
seeking definite object
Trying the building entryway (1106324) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying outside (1106068) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying Jones (1100852) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the speeder (1100916) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the windows (1106228) at word 2
Trying the turbines (1106260) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the wings (1106292) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the parking bays (1100948) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the disruptor pistol (1100884) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying Beck (1100404) at word 2
Matched (1)
[ND made 1 matches]
[ND returned Beck]
[token resulted in success]
[line 6 token 2 word 3 : ‘about’]
[token resulted in success]
[line 6 token 3 word 4 : scope=Routine(581542)]
[Scope routine called at stage 1]
[Scope routine returned multiple-flag of 0]
[Object list from word 4]
[Calling NounDomain on location and actor]
[NounDomain called at word 4
seeking definite object
[Scope routine called at stage 2]
[Scope routine called at stage 2]
[Scope routine called at stage 2]
[Scope routine called at stage 2]

etc…

Since I don’t have any insight into “Scope routine called at stage 2”, it’s hard for me to diagnose what’s going on. Maybe there’s a way to do what I want that doesn’t blow up the parser?

2 Likes

A stack overflow means some kind of infinite loop.

I haven’t tested, but I’m pretty sure the problem is “[any interesting invisible thing]” and “[any visible thing]”. Trying to check visibility inside a grammar line is likely to tie the parser in knots.

In any case, the point of “any” is to permit the grammar line to match non-visible things. So specifying “any visible” is redundant! You could just say

Understand "ask [someone] about [something]" ....

…and that would work, or at least would work better.

Removing “invisible” from the previous line should probably be fine. It doesn’t generally matter whether grammar lines are mutually exclusive.

Yeah I figured that out. See the first line of my post. Removing references to visibility fixed it. Thanks.

In case anyone’s wondering, this is because grammar tokens relating to objects call routines to determine scope, which because the definition of scope is tied up with visibility themselves call visibility routines

1 Like