# HG changeset patch # User Matthew Russotto # Date 1603248660 14400 # Tue Oct 20 22:51:00 2020 -0400 # Branch old-adjectives # Node ID 379ec9d3bd051da0dcbdb018d99ea965114abc38 # Parent f6b1ae7318b36cd18a8f148506494eb18d5110ec Adjectives should be 2 bytes even when using a V3 parser on V4 diff -r f6b1ae7318b3 -r 379ec9d3bd05 src/Zilf/Compiler/Compilation.Objects.cs --- a/src/Zilf/Compiler/Compilation.Objects.cs Tue Oct 20 21:31:41 2020 -0400 +++ b/src/Zilf/Compiler/Compilation.Objects.cs Tue Oct 20 22:51:00 2020 -0400 @@ -628,15 +628,17 @@ var word = Context.ZEnvironment.GetVocabAdjective(atom, src); var wb = Vocabulary[word]; - if (Context.ZEnvironment.ZVersion == 3 || - Context.GetGlobalOption(StdAtom.FORCE_V3_PARSER_P)) + if (Context.ZEnvironment.ZVersion == 3) { tb.AddByte(Constants[ZilAtom.Parse("A?" + word.Atom.Text, Context)]); length++; } else { - tb.AddShort(wb); + if (Context.GetGlobalOption(StdAtom.FORCE_V3_PARSER_P)) + tb.AddShort(Constants[ZilAtom.Parse("A?" + word.Atom.Text, Context)]); + else + tb.AddShort(wb); length += 2; } } # HG changeset patch # User Matthew Russotto # Date 1603243901 14400 # Tue Oct 20 21:31:41 2020 -0400 # Branch old-adjectives # Node ID f6b1ae7318b36cd18a8f148506494eb18d5110ec # Parent 030125fba7b7f0e61a38ec3713293d3d13b22116 Make an atom, FORCE-V3-PARSER?, which can be set to 3 to use the V3 adjective systems under V4. diff -r 030125fba7b7 -r f6b1ae7318b3 src/Zilf/Compiler/Compilation.Objects.cs --- a/src/Zilf/Compiler/Compilation.Objects.cs Tue Oct 13 15:32:01 2020 -0700 +++ b/src/Zilf/Compiler/Compilation.Objects.cs Tue Oct 20 21:31:41 2020 -0400 @@ -442,7 +442,8 @@ GetAdjectiveValue = (atom, src) => { var word = Context.ZEnvironment.GetVocabAdjective(atom, src); - return Context.ZEnvironment.ZVersion == 3 + return (Context.ZEnvironment.ZVersion == 3 || + Context.GetGlobalOption(StdAtom.FORCE_V3_PARSER_P)) ? Constants[ZilAtom.Parse("A?" + word.Atom.Text, Context)] : Vocabulary[word]; }, @@ -627,7 +628,8 @@ var word = Context.ZEnvironment.GetVocabAdjective(atom, src); var wb = Vocabulary[word]; - if (Context.ZEnvironment.ZVersion == 3) + if (Context.ZEnvironment.ZVersion == 3 || + Context.GetGlobalOption(StdAtom.FORCE_V3_PARSER_P)) { tb.AddByte(Constants[ZilAtom.Parse("A?" + word.Atom.Text, Context)]); length++; diff -r 030125fba7b7 -r f6b1ae7318b3 src/Zilf/Language/StdAtom.cs --- a/src/Zilf/Language/StdAtom.cs Tue Oct 13 15:32:01 2020 -0700 +++ b/src/Zilf/Language/StdAtom.cs Tue Oct 20 21:31:41 2020 -0400 @@ -103,6 +103,8 @@ FIND, FIX, FLAGS, + [Atom("FORCE-V3-PARSER?")] + FORCE_V3_PARSER_P, FORM, FSUBR, FUNCTION, diff -r 030125fba7b7 -r f6b1ae7318b3 src/Zilf/ZModel/Vocab/OldParser/OldParserVocabFormat.cs --- a/src/Zilf/ZModel/Vocab/OldParser/OldParserVocabFormat.cs Tue Oct 13 15:32:01 2020 -0700 +++ b/src/Zilf/ZModel/Vocab/OldParser/OldParserVocabFormat.cs Tue Oct 20 21:31:41 2020 -0400 @@ -82,7 +82,8 @@ public void MakeSyntaxPreposition(IWord word, ISourceLine location) => MakePreposition(word, location); public void MakeAdjective(IWord word, ISourceLine location) => MakePart(word, location, - PartOfSpeech.Adjective, "adjectives", w => w.SetAdjective, ref nextAdjective, onlyNumberedInV3: true); + PartOfSpeech.Adjective, "adjectives", w => w.SetAdjective, ref nextAdjective, + onlyNumberedInV3: OldParserWord.IsFreeAdjective(ctx)); public void MakeObject(IWord result, ISourceLine location) { @@ -115,7 +116,7 @@ var rawWord = opw.Atom.Text; // adjective numbers only exist in V3 - if (ctx.ZEnvironment.ZVersion == 3 && + if (!OldParserWord.IsFreeAdjective(ctx) && (opw.PartOfSpeech & PartOfSpeech.Adjective) != 0) { yield return new KeyValuePair("A?" + rawWord, opw.GetValue(PartOfSpeech.Adjective)); diff -r 030125fba7b7 -r f6b1ae7318b3 src/Zilf/ZModel/Vocab/OldParser/OldParserWord.cs --- a/src/Zilf/ZModel/Vocab/OldParser/OldParserWord.cs Tue Oct 13 15:32:01 2020 -0700 +++ b/src/Zilf/ZModel/Vocab/OldParser/OldParserWord.cs Tue Oct 20 21:31:41 2020 -0400 @@ -111,6 +111,16 @@ return ctx.GetGlobalOption(StdAtom.COMPACT_VOCABULARY_P); } + public static bool IsFreeAdjective(Context ctx) + { + if (ctx.ZEnvironment.ZVersion < 4) + return false; + // Only valid in V4, FORCE_V3_PARSER? treats adjectives the old way, recording them + // in the dictionary. They count against parts of speech. The purpose is to allow + // old V3 games to be moved to V4 without changing the parser. + return !ctx.GetGlobalOption(StdAtom.FORCE_V3_PARSER_P); + } + /// /// Checks whether adding a new part of speech should set the relevant First flag. /// @@ -128,7 +138,7 @@ // ignore parts of speech that don't record values in the current context var pos = PartOfSpeech; - if (ctx.ZEnvironment.ZVersion >= 4) + if (IsFreeAdjective(ctx)) pos &= ~PartOfSpeech.Adjective; if (IsNewVoc(ctx)) pos &= ~PartOfSpeech.Object; @@ -201,7 +211,7 @@ // Adjective is always free in V4+ if ((PartOfSpeech & PartOfSpeech.Adjective) != 0) { - if (ctx.ZEnvironment.ZVersion > 3) + if (IsFreeAdjective(ctx)) { freeAdjective = true; count--; @@ -293,7 +303,7 @@ { if ((PartOfSpeech & PartOfSpeech.Adjective) == 0) { - if (ctx.ZEnvironment.ZVersion < 4 && ShouldSetFirst(ctx)) + if (!IsFreeAdjective(ctx) && ShouldSetFirst(ctx)) PartOfSpeech |= PartOfSpeech.AdjectiveFirst; PartOfSpeech |= PartOfSpeech.Adjective; @@ -418,7 +428,7 @@ if ((pos & PartOfSpeech.Adjective) != 0) { // in V4+, don't write a value for Adjective - if (ctx.ZEnvironment.ZVersion < 4) + if (!IsFreeAdjective(ctx)) { if ((pos & PartOfSpeech.FirstMask) == PartOfSpeech.AdjectiveFirst) partsToWrite.Insert(0, PartOfSpeech.Adjective);