Skip to content

Commit

Permalink
Remove code and message for preventing parameter in first position of…
Browse files Browse the repository at this point in the history
… syntax
  • Loading branch information
thoni56 committed Sep 1, 2019
1 parent b59c278 commit 43d21d5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 23 deletions.
7 changes: 3 additions & 4 deletions compiler/alan.lmk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%%OPTIONS

Prefix 'lm';
Listings single;
Limit 1000;
Prefix 'lm';
Listings single;
Limit 1000;
-- Message file;

%%MESSAGES English
Expand Down Expand Up @@ -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.';
Expand Down
30 changes: 11 additions & 19 deletions compiler/elm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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;
}


Expand All @@ -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;
}
Expand Down
13 changes: 13 additions & 0 deletions regression/parameterFirstInSyntax.alan
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions regression/parameterFirstInSyntax.expected
Original file line number Diff line number Diff line change
@@ -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 ?
1 change: 1 addition & 0 deletions regression/parameterFirstInSyntax.input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bob jump
Binary file modified regression/platforms/Darwin.a3c
Binary file not shown.

0 comments on commit 43d21d5

Please sign in to comment.