indent + EOF work in progress

This commit is contained in:
Vítor Santos Costa 2015-07-06 11:49:56 +01:00
parent f5b50a4179
commit 4c56769210
1 changed files with 1218 additions and 1198 deletions

View File

@ -502,7 +502,7 @@ static char chtype0[NUMBER_OF_CHARS + 1] = {
BS, BS, BS, BS, BS, BS, BS, BS, BS,
BS, BS, BS, BS, BS, BS, BS,
/*   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */
/* ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */
BS, SY, SY, SY, SY, SY, SY, SY, SY,
SY, LC, SY, SY, SY, SY, SY,
@ -1174,6 +1174,14 @@ static void close_comment(USES_REGS1) {
LOCAL_CommentsBuffLim = 0;
}
// mark that we reached EOF,
// next token will be end_of_file)
static void
mark_eof( struct stream_desc * inp_stream )
{
inp_stream->status |= Push_Eof_Stream_f;
}
static wchar_t *ch_to_wide(char *base, char *charp) {
CACHE_REGS
int n = charp - base, i;
@ -1314,6 +1322,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
goto restart;
} else {
t->Tok = Ord(kind = eot_tok);
mark_eof(inp_stream);
}
break;
@ -1532,6 +1541,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
}
} else if (chtype(ch) == EF && ch <= MAX_ISO_LATIN1) {
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
mark_eof(inp_stream);
t->Tok = Ord(kind = eot_tok);
break;
} else {
@ -1594,13 +1604,17 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
return l;
}
if (wcharp) {
utf8_wcscpy(mp, (const wchar_t *)TokImage);
wcscpy((wchar_t *)mp, (wchar_t *)TokImage);
} else {
strcpy(mp, TokImage);
}
t->TokInfo = Unsigned(mp);
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = StringTerm_tok);
if (wcharp) {
t->Tok = Ord(kind = WBQString_tok);
} else {
t->Tok = Ord(kind = BQString_tok);
}
} else {
if (wcharp) {
t->TokInfo = Unsigned(Yap_LookupWideAtom((wchar_t *)TokImage));
@ -1618,12 +1632,12 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
t->Tok = Ord(kind = Name_tok);
if (ch == '(')
solo_flag = FALSE;
solo_flag = false;
}
break;
case SY:
if (ch == '`' && trueGlobalPrologFlag(BACKQUOTED_STRING_FLAG))
if (ch == '`')
goto quoted_string;
och = ch;
ch = getchr(inp_stream);
@ -1650,6 +1664,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
}
if (chtype(ch) == EF) {
t->Tok = Ord(kind = eot_tok);
break;
} else {
/* leave comments */
ch = getchr(inp_stream);
@ -1672,6 +1687,9 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF)
;
t->Tok = Ord(kind = eot_tok);
if (chtype(chtype(ch)) == EF)
mark_eof(inp_stream);
break;
} else {
Atom ae;
TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE;
@ -1847,6 +1865,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
}
} else if (chtype(ch) == EF) {
Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage);
mark_eof(inp_stream);
t->Tok = Ord(kind = eot_tok);
break;
} else {
@ -1899,6 +1918,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
t->Tok = Ord(kind = Ponctuation_tok);
break;
case EF:
mark_eof(inp_stream);
t->Tok = Ord(kind = eot_tok);
break;