Check junk at end of line with the repeat directives.

This commit is contained in:
Olaf Seibert
2021-01-23 18:37:47 +01:00
parent 40b41c3087
commit 6f1af83101
4 changed files with 38 additions and 21 deletions

View File

@@ -25,21 +25,6 @@
static int check_eol(
STACK *stack,
char *cp)
{
cp = skipwhite(cp);
if (EOL(*cp)) {
return 1;
}
report(stack->top, "Junk at end of line ('%c')\n", *cp);
return 0;
}
#define CHECK_EOL check_eol(stack, cp)
/* assemble - read a line from the input stack, assemble it. */
@@ -281,7 +266,7 @@ static int assemble(
stack_push(stack, macstr); /* Push macro expansion
onto input stream */
return 1; /* TODO: CHECK_EOL */
return 1;
}
/* Try to resolve instruction or pseudo */
@@ -542,7 +527,7 @@ static int assemble(
break; /* EOF */
}
}
return 1; /* TODO: CHECK_EOL? */
return 1;
case P_IRP:
{
@@ -550,7 +535,7 @@ static int assemble(
if (str)
stack_push(stack, str);
return str != NULL; /* TODO: CHECK_EOL */
return str != NULL;
}
case P_IRPC:
@@ -559,7 +544,7 @@ static int assemble(
if (str)
stack_push(stack, str);
return str != NULL; /* TODO: CHECK_EOL */
return str != NULL;
}
case P_LIBRARY:
@@ -701,7 +686,7 @@ static int assemble(
{
MACRO *mac = defmacro(cp, stack, CALLED_NORMAL);
return mac != NULL; /* TODO: CHECK_EOL */
return mac != NULL;
}
case P_MEXIT:
@@ -730,7 +715,7 @@ static int assemble(
if (reptstr)
stack_push(stack, reptstr);
return reptstr != NULL; /* TODO: CHECK_EOL */
return reptstr != NULL;
}
case P_ENABL:

19
parse.c
View File

@@ -50,6 +50,25 @@ char *skipdelim_comma(
return cp;
}
/*
* check_eol - check that we're at the end of a line.
* Complain if not.
*/
int check_eol(
STACK *stack,
char *cp)
{
cp = skipwhite(cp);
if (EOL(*cp)) {
return 1;
}
report(stack->top, "Junk at end of line ('%s')\n", cp);
return 0;
}
/* Parses a string from the input stream. */
/* If not bracketed by <...> or ^/.../, then */
/* the string is delimited by trailing comma or whitespace. */

View File

@@ -23,6 +23,9 @@ char *skipdelim_comma(
SYMBOL *get_op(
char *cp,
char **endp);
int check_eol(
STACK *stack,
char *cp);
char *getstring(
char *cp,
char **endp);

View File

@@ -84,6 +84,12 @@ STREAM *expand_rept(
free_tree(value);
return NULL;
}
/*
* Reading the next lines-to-be-repeated overwrites the line buffer
* that the caller is using. So for junk-at-end-of-line checking we
* need to do it here.
*/
check_eol(stack, value->cp);
list_value(stack->top, value->data.lit);
@@ -214,6 +220,8 @@ STREAM *expand_irp(
return NULL;
}
check_eol(stack, cp);
gb = new_buffer();
levelmod = 0;
@@ -342,6 +350,8 @@ STREAM *expand_irpc(
return NULL;
}
check_eol(stack, cp);
gb = new_buffer();
levelmod = 0;