don't consume char after '.', do peek instead.
early errors should leave early.
This commit is contained in:
parent
df0b3d3a0d
commit
92cb3e34eb
45
C/scanner.c
45
C/scanner.c
@ -563,9 +563,7 @@ typedef struct scanner_extra_alloc {
|
|||||||
void *filler;
|
void *filler;
|
||||||
} ScannerExtraBlock;
|
} ScannerExtraBlock;
|
||||||
|
|
||||||
static TokEntry *
|
static TokEntry *CodeSpaceError(TokEntry *t, TokEntry *p, TokEntry *l) {
|
||||||
CodeSpaceError(TokEntry *t, TokEntry *p, TokEntry *l)
|
|
||||||
{
|
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
|
||||||
LOCAL_ErrorMessage = "Code Space Overflow";
|
LOCAL_ErrorMessage = "Code Space Overflow";
|
||||||
if (t) {
|
if (t) {
|
||||||
@ -574,11 +572,9 @@ CodeSpaceError(TokEntry *t, TokEntry *p, TokEntry *l)
|
|||||||
}
|
}
|
||||||
/* serious error now */
|
/* serious error now */
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TokEntry *
|
static TokEntry *TrailSpaceError(TokEntry *t, TokEntry *l) {
|
||||||
TrailSpaceError(TokEntry *t, TokEntry *l)
|
|
||||||
{
|
|
||||||
LOCAL_ErrorMessage = "Trail Overflow";
|
LOCAL_ErrorMessage = "Trail Overflow";
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL;
|
||||||
if (t) {
|
if (t) {
|
||||||
@ -588,9 +584,7 @@ TrailSpaceError(TokEntry *t, TokEntry *l)
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TokEntry *
|
static TokEntry *AuxSpaceError(TokEntry *p, TokEntry *l, const char *msg) {
|
||||||
AuxSpaceError(TokEntry *p, TokEntry *l, const char *msg)
|
|
||||||
{
|
|
||||||
/* huge atom or variable, we are in trouble */
|
/* huge atom or variable, we are in trouble */
|
||||||
LOCAL_ErrorMessage = (char *)msg;
|
LOCAL_ErrorMessage = (char *)msg;
|
||||||
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;
|
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;
|
||||||
@ -1403,7 +1397,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
LOCAL_StartLineCount = inp_stream->linecount;
|
LOCAL_StartLineCount = inp_stream->linecount;
|
||||||
LOCAL_StartLinePos = inp_stream->linepos;
|
LOCAL_StartLinePos = inp_stream->linepos;
|
||||||
do {
|
do {
|
||||||
wchar_t och;
|
wchar_t och, pch;
|
||||||
int quote, isvar;
|
int quote, isvar;
|
||||||
char *charp, *mp;
|
char *charp, *mp;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
@ -1669,7 +1663,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
++len;
|
++len;
|
||||||
if (charp > (char *)AuxSp - 1024) {
|
if (charp > (char *)AuxSp - 1024) {
|
||||||
/* Not enough space to read in the string. */
|
/* Not enough space to read in the string. */
|
||||||
return AuxSpaceError(t, l, "not enough space to read in string or quoted atom");
|
return AuxSpaceError(
|
||||||
|
t, l, "not enough space to read in string or quoted atom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wcharp) {
|
if (wcharp) {
|
||||||
@ -1730,12 +1725,29 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
case BS:
|
case BS:
|
||||||
if (ch == '\0') {
|
if (ch == '\0') {
|
||||||
t->Tok = Ord(kind = eot_tok);
|
t->Tok = Ord(kind = eot_tok);
|
||||||
|
if (chtype(pch) == EF) {
|
||||||
|
mark_eof(inp_stream);
|
||||||
|
t->TokInfo = TermEof;
|
||||||
|
} else {
|
||||||
|
t->TokInfo = TermNewLine;
|
||||||
|
}
|
||||||
t->TokInfo = TermEof;
|
t->TokInfo = TermEof;
|
||||||
return l;
|
return l;
|
||||||
} else
|
} else
|
||||||
ch = getchr(inp_stream);
|
ch = getchr(inp_stream);
|
||||||
break;
|
break;
|
||||||
case SY:
|
case SY:
|
||||||
|
if (ch == '.' && (pch = Yap_peek(inp_stream - GLOBAL_Stream)) &&
|
||||||
|
(chtype(pch) == BS || chtype(pch) == EF || pch == '%')) {
|
||||||
|
t->Tok = Ord(kind = eot_tok);
|
||||||
|
if (chtype(ch) == EF) {
|
||||||
|
mark_eof(inp_stream);
|
||||||
|
t->TokInfo = TermEof;
|
||||||
|
} else {
|
||||||
|
t->TokInfo = TermNewLine;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
if (ch == '`')
|
if (ch == '`')
|
||||||
goto quoted_string;
|
goto quoted_string;
|
||||||
och = ch;
|
och = ch;
|
||||||
@ -1982,7 +1994,8 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
}
|
}
|
||||||
if (charp > (char *)AuxSp - 1024) {
|
if (charp > (char *)AuxSp - 1024) {
|
||||||
/* Not enough space to read in the string. */
|
/* Not enough space to read in the string. */
|
||||||
return AuxSpaceError(t, l, "not enough space to read in string or quoted atom");
|
return AuxSpaceError(
|
||||||
|
t, l, "not enough space to read in string or quoted atom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = charp - TokImage;
|
len = charp - TokImage;
|
||||||
@ -2021,10 +2034,10 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
t->TokInfo = TermEof;
|
t->TokInfo = TermEof;
|
||||||
return l;
|
return l;
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
char err[1024];
|
char err[1024];
|
||||||
snprintf( err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n", ch, ch, chtype(ch) );
|
snprintf(err, 1023, "\n++++ token: unrecognised char %c (%d), type %c\n",
|
||||||
|
ch, ch, chtype(ch));
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
fprintf(stderr, "%s", err);
|
fprintf(stderr, "%s", err);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user