1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00

Fix and test case for Mantis bug 2027

This commit is contained in:
Graham Nelson 2022-04-09 15:41:45 +01:00
parent 0dc42eb46f
commit 3441f24979
5 changed files with 343 additions and 290 deletions

View file

@ -1,33 +1,37 @@
100.0% in inform7 run
69.1% in compilation to Inter
47.9% in //Sequence::undertake_queued_tasks//
4.6% in //MajorNodes::pre_pass//
3.5% in //MajorNodes::pass_1//
2.4% in //RTPhrasebook::compile_entries//
68.1% in compilation to Inter
47.7% in //Sequence::undertake_queued_tasks//
4.5% in //MajorNodes::pre_pass//
3.2% in //MajorNodes::pass_1//
2.3% in //RTPhrasebook::compile_entries//
1.8% in //ImperativeDefinitions::assess_all//
1.5% in //RTKindConstructors::compile//
1.1% in //Sequence::lint_inter//
0.5% in //ImperativeDefinitions::compile_first_block//
1.0% in //Sequence::lint_inter//
0.5% in //MajorNodes::pass_2//
0.5% in //Sequence::undertake_queued_tasks//
0.5% in //Sequence::undertake_queued_tasks//
0.5% in //World::stage_V//
0.1% in //CompletionModule::compile//
0.4% in //ImperativeDefinitions::compile_first_block//
0.4% in //Sequence::undertake_queued_tasks//
0.4% in //Sequence::undertake_queued_tasks//
0.2% in //CompletionModule::compile//
0.2% in //RTKindConstructors::compile_permissions//
0.1% in //InferenceSubjects::emit_all//
0.1% in //RTKindConstructors::compile_permissions//
0.1% in //Task::make_built_in_kind_constructors//
0.1% in //Understand::traverse//
0.1% in //World::stages_II_and_III//
2.2% not specifically accounted for
28.1% in running Inter pipeline
10.1% in step 14/15: generate inform6 -> auto.inf
7.3% in step 5/15: load-binary-kits
6.2% in step 6/15: make-synoptic-module
2.1% not specifically accounted for
29.2% in running Inter pipeline
10.2% in step 14/15: generate inform6 -> auto.inf
7.6% in step 5/15: load-binary-kits
6.8% in step 6/15: make-synoptic-module
1.5% in step 9/15: make-identifiers-unique
0.3% in step 12/15: eliminate-redundant-operations
0.3% in step 4/15: compile-splats
0.3% in step 7/15: shorten-wiring
0.4% in step 12/15: eliminate-redundant-operations
0.4% in step 4/15: compile-splats
0.4% in step 7/15: shorten-wiring
0.3% in step 8/15: detect-indirect-calls
0.1% in step 11/15: eliminate-redundant-labels
1.3% not specifically accounted for
0.2% in step 11/15: eliminate-redundant-labels
0.1% in step 10/15: reconcile-verbs
0.1% in step 2/15: parse-insertions
0.1% in step 3/15: resolve-conditional-compilation
0.7% not specifically accounted for
2.2% in supervisor
0.4% not specifically accounted for

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,5 @@
The School for Gifted Kiddies is a room.
Professor Zaphier is in the School.
Understand "Prof/--" as Professor Zaphier.

View file

@ -0,0 +1,11 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 19 words long.
I've also read Basic Inform by Graham Nelson, which is 7691 words long.
I've also read English Language by Graham Nelson, which is 2328 words long.
I've also read Standard Rules by Graham Nelson, which is 32092 words long.
Problem__ PM_EmptyUnderstandLine
>--> You wrote 'Understand "Prof/--" as Professor Zaphier' (source text, line 5):
but the optional '--' word has been used here in such a way that it would
be possible for a completely empty phrase to be understood in this context,
but that isn't allowed.
Inform 7 has finished.

View file

@ -269,6 +269,8 @@ void CGLines::slash(command_grammar *cg) {
@<Annotate the CG tokens with slash-class and slash-dash-dash@>;
@<Throw a problem if slash has been used with non-literal tokens@>;
@<Calculate the lexeme count@>;
if ((cg->cg_is != CG_IS_COMMAND) &&
(cg->cg_is != CG_IS_TOKEN)) @<Disallow a potentially empty line@>;
}
}
@ -367,6 +369,37 @@ lexemes +--+ +-------+ +---------+
cgl->lexeme_count++;
}
@ The following catches grammar such as:
= (text as Inform 7)
Understand "Prof/--" as Professor Zaphier.
=
which would otherwise compile fine, but lead to a hang of the story file when
attempting to recognise Zaphier's name.
@<Disallow a potentially empty line@> =
int possibly_empty = TRUE;
LOOP_THROUGH_CG_TOKENS(cgt, cgl) {
int i = cgt->slash_class;
if (i == 0) possibly_empty = FALSE;
else {
int dashdashed = FALSE;
while (TRUE) {
if (cgt->slash_dash_dash) dashdashed = TRUE;
if ((cgt->next_token) &&
(cgt->next_token->slash_class == i)) cgt = cgt->next_token;
else break;
}
if (dashdashed == FALSE) possibly_empty = FALSE;
}
}
if (possibly_empty)
StandardProblems::sentence_problem(Task::syntax_tree(),
_p_(PM_EmptyUnderstandLine),
"the optional '--' word has been used here in such a way that it "
"would be possible for a completely empty phrase to be understood "
"in this context",
"but that isn't allowed.");
@h Determining the line.
Here the aim is to find the //determination_type// of a CGL. Sneakily, though,
we also take the opportunity to calculate its two "sorting bonuses", which