From 43d21d53efc3e611a11e762405ba7ef704912996 Mon Sep 17 00:00:00 2001 From: Thomas Nilefalk Date: Sun, 1 Sep 2019 12:48:33 +0200 Subject: [PATCH] Remove code and message for preventing parameter in first position of syntax --- compiler/alan.lmk | 7 +++-- compiler/elm.c | 30 ++++++++------------- regression/parameterFirstInSyntax.alan | 13 +++++++++ regression/parameterFirstInSyntax.expected | 15 +++++++++++ regression/parameterFirstInSyntax.input | 1 + regression/platforms/Darwin.a3c | Bin 48889 -> 48889 bytes 6 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 regression/parameterFirstInSyntax.alan create mode 100644 regression/parameterFirstInSyntax.expected create mode 100644 regression/parameterFirstInSyntax.input diff --git a/compiler/alan.lmk b/compiler/alan.lmk index a3189af81..d6b719a91 100644 --- a/compiler/alan.lmk +++ b/compiler/alan.lmk @@ -1,8 +1,8 @@ %%OPTIONS - Prefix 'lm'; - Listings single; - Limit 1000; + Prefix 'lm'; + Listings single; + Limit 1000; -- Message file; %%MESSAGES English @@ -45,7 +45,6 @@ 206 'Incompatible parameters lists for multiple syntax definitions for verb \'%1\'. Multiple syntaxes for the same verb must contain the same number of parameters with the same name, but the order of the parameters can be changed.'; 207 'VERB \'%1\' is not defined.'; 208 '\'%1\' is not a VERB.'; -209 'First element in a SYNTAX must be a player word.'; 210 'Action qualification not allowed here.'; 211 'Adventure must start at an instance inheriting from \'location\'.'; 212 'Syntax parameter \'%1\' overrides symbol.'; diff --git a/compiler/elm.c b/compiler/elm.c index 3e9e5370c..877278493 100644 --- a/compiler/elm.c +++ b/compiler/elm.c @@ -34,9 +34,9 @@ static int level = 0; /*----------------------------------------------------------------------*/ static Element *newElement(Srcp *srcp, - ElementKind kind, - Id *id, - int flags) + ElementKind kind, + Id *id, + int flags) { Element *new; /* The newly created node */ @@ -130,18 +130,10 @@ List *analyzeElements(List *elements, List *restrictions, Syntax *syntax) int parameterCount = 1; Bool multiple = FALSE; -#ifdef REQUIRE_VERB_FIRST - if (firstElement->kind != WORD_ELEMENT) - /* First element must be a player word */ - lmLog(&firstElement->srcp, 209, sevERR, ""); - else - firstElement->id->code = newVerbWord(firstElement->id->string, syntax); -#else if (firstElement->kind == WORD_ELEMENT) { firstElement->id->code = newVerbWord(firstElement->id->string, syntax); - elements = elements->next; /* Done with the first element */ - } -#endif + elements = elements->next; /* Done with the first element */ + } /* Analyze the elements, number parameters and find the restriction */ for (list = elements; list != NULL; list = list->next) { @@ -199,12 +191,12 @@ static Bool equalElements(List *element1, List *element2) static List *advance(List *elmsList) /* IN - The list to advance */ { List *list; - List *copy = copyList(elmsList); + List *copy = copyList(elmsList); for (list = copy; list != NULL; list = list->next) { list->member.lst = list->member.lst->next; } - return copy; + return copy; } @@ -271,7 +263,7 @@ static ElementEntry *newEntryForPartition(List **entries) { /*----------------------------------------------------------------------*/ static Aaddr restrictionTableAddress(List *partition) { - return partition->member.lst->member.elm->stx->restrictionsAddress; + return partition->member.lst->member.elm->stx->restrictionsAddress; } @@ -296,9 +288,9 @@ static void entryForParameter(ElementEntry *entry, List *partition, Syntax *stx) entry->code = 0; entry->flags = partition->member.lst->member.elm->flags; - /* TODO: ORing flags here is a problem, might actually give some - syntaxes different flags than intended which is not at all good - (omnipotent!!!) */ + /* TODO: ORing flags here is a problem, might actually give some + syntaxes different flags than intended which is not at all good + (omnipotent!!!) */ ITERATE(element, partition->next) { entry->flags |= element->member.lst->member.elm->flags; } diff --git a/regression/parameterFirstInSyntax.alan b/regression/parameterFirstInSyntax.alan new file mode 100644 index 000000000..a100bd845 --- /dev/null +++ b/regression/parameterFirstInSyntax.alan @@ -0,0 +1,13 @@ +The l Isa location +End The l. + +The bob Isa actor At l + Verb jump + Does + "Jump" + End Verb. +End The bob. + +Syntax jump = (a) jump Where a Isa actor Else "You can only order people about." + +Start At l. \ No newline at end of file diff --git a/regression/parameterFirstInSyntax.expected b/regression/parameterFirstInSyntax.expected new file mode 100644 index 000000000..cd3a7cd26 --- /dev/null +++ b/regression/parameterFirstInSyntax.expected @@ -0,0 +1,15 @@ +########## parameterFirstInSyntax ########## + + No warnings or errors detected. + + + +L +There is a bob here. + +> bob jump +Jump + +> + +Do you want to UNDO, RESTART, RESTORE or QUIT ? diff --git a/regression/parameterFirstInSyntax.input b/regression/parameterFirstInSyntax.input new file mode 100644 index 000000000..90f57e47c --- /dev/null +++ b/regression/parameterFirstInSyntax.input @@ -0,0 +1 @@ +bob jump diff --git a/regression/platforms/Darwin.a3c b/regression/platforms/Darwin.a3c index 667f244c7aad433cf1bbc6cf601b31bc40a22a76..bc8f8dcd2afa7d47252f251f262c7d842b520ab0 100644 GIT binary patch delta 714 zcmezQm+9wUCLTv0M?Yo;wj>4yCb@|`>$s9)7$Cr5;}L;uu2=Usz+9Fmlka7Fp>ky> z`{(GQ3oS+$l9>D{#|T-KUM`9`O{m;^*%FiA<)UZ+2|4AV2-W4Gm;qAp3RQ(#K8A`( z`6yq}59-c^EP245)(7i30NDT*1}P*rf1p=gLh q<%0B|DnrrFR*s?pq@t)CMa4Q)6-*Uq8e}IISD+;~sm(_!Ox*ws0^xE1 delta 714 zcmezQm+9wUCLTv0M?Yo;wj>4yrtXP6>$t317$CrC;}L;uuIH>AU@phr$@j9oP`R>` z{d08Dg%+a=NlgBfV}z_qFBip}CRFadY>CP5a#1vZgq-qFgzEB8%mAr)g{nd=A4A2Y zd=xXzVXCkyKv7XvfMSMRq2%Pp1%}9ekt;+|QH07phRV$=lALT@grYyM2t_|g#cfm- zAg}2aqc|(87)8@QR4zz^Rtbs*zEa7_^(814?