indent + EOF work in progress
This commit is contained in:
parent
f5b50a4179
commit
4c56769210
64
C/scanner.c
64
C/scanner.c
@ -453,7 +453,7 @@ Yap_setCurrentSourceLocation( struct stream_desc *s )
|
||||
else
|
||||
LOCAL_SourceFileName = s->name;
|
||||
LOCAL_SourceFileLineno = s->linecount;
|
||||
}
|
||||
}
|
||||
|
||||
/* token table with some help from Richard O'Keefe's PD scanner */
|
||||
static char chtype0[NUMBER_OF_CHARS + 1] = {
|
||||
@ -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,
|
||||
|
||||
@ -514,27 +514,27 @@ static char chtype0[NUMBER_OF_CHARS + 1] = {
|
||||
UC, UC, UC, UC, UC, UC, UC, UC, UC,
|
||||
UC, UC, UC, UC, UC, UC, UC,
|
||||
|
||||
/* Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß */
|
||||
#ifdef vms
|
||||
/* Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß */
|
||||
#ifdef vms
|
||||
UC, UC, UC, UC, UC, UC, UC, UC, UC,
|
||||
UC, UC, UC, UC, UC, UC, LC,
|
||||
#else
|
||||
#else
|
||||
UC, UC, UC, UC, UC, UC, UC, SY, UC,
|
||||
UC, UC, UC, UC, UC, UC, LC,
|
||||
#endif
|
||||
#endif
|
||||
/* à á â ã ä å æ ç è é ê ë ì í î ï */
|
||||
LC, LC, LC, LC, LC, LC, LC, LC, LC,
|
||||
LC, LC, LC, LC, LC, LC, LC,
|
||||
|
||||
/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last
|
||||
/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last
|
||||
* three because of lcc */
|
||||
#ifdef vms
|
||||
#ifdef vms
|
||||
LC, LC, LC, LC, LC, LC, LC, LC, LC,
|
||||
LC, LC, LC, LC, LC, LC, LC
|
||||
#else
|
||||
#else
|
||||
LC, LC, LC, LC, LC, LC, LC, SY, LC,
|
||||
LC, LC, LC, LC, LC, LC, LC
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
char *Yap_chtype = chtype0 + 1;
|
||||
@ -680,7 +680,7 @@ static int send_error_message(char s[]) {
|
||||
static wchar_t read_quoted_char(int *scan_nextp, struct stream_desc* inp_stream) {
|
||||
int ch;
|
||||
|
||||
/* escape sequence */
|
||||
/* escape sequence */
|
||||
do_switch:
|
||||
ch = getchrq(inp_stream);
|
||||
switch (ch) {
|
||||
@ -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;
|
||||
@ -1213,7 +1221,7 @@ static wchar_t *ch_to_wide(char *base, char *charp) {
|
||||
}
|
||||
|
||||
#define add_ch_to_utf8_buff(ch) \
|
||||
{ \
|
||||
{ \
|
||||
if ((ch & 0xff) == ch) { \
|
||||
*charp++ = ch; \
|
||||
} else { \
|
||||
@ -1269,7 +1277,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
else
|
||||
p->TokNext = t;
|
||||
p = t;
|
||||
restart:
|
||||
restart:
|
||||
while (chtype(ch) == BS) {
|
||||
ch = getchr(inp_stream);
|
||||
}
|
||||
@ -1281,7 +1289,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
if (store_comments) {
|
||||
CHECK_SPACE();
|
||||
open_comment(ch, inp_stream PASS_REGS);
|
||||
continue_comment:
|
||||
continue_comment:
|
||||
while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) {
|
||||
CHECK_SPACE();
|
||||
extend_comment(ch PASS_REGS);
|
||||
@ -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;
|
||||
|
||||
@ -1322,7 +1331,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
case LC:
|
||||
och = ch;
|
||||
ch = getchr(inp_stream);
|
||||
scan_name:
|
||||
scan_name:
|
||||
TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE;
|
||||
charp = TokImage;
|
||||
wcharp = NULL;
|
||||
@ -1330,7 +1339,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
add_ch_to_buff(och);
|
||||
for (; chtype(ch) <= NU; ch = getchr(inp_stream)) {
|
||||
if (charp == (char *)AuxSp - 1024) {
|
||||
huge_var_error:
|
||||
huge_var_error:
|
||||
/* huge atom or variable, we are in trouble */
|
||||
LOCAL_ErrorMessage = "Code Space Overflow due to huge atom";
|
||||
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
|
||||
@ -1495,7 +1504,7 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
|
||||
case QT:
|
||||
case DC:
|
||||
quoted_string:
|
||||
quoted_string:
|
||||
TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE;
|
||||
charp = TokImage;
|
||||
quote = ch;
|
||||
@ -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);
|
||||
@ -1665,13 +1680,16 @@ TokEntry *Yap_tokenizer( struct stream_desc *inp_stream,
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
enter_symbol:
|
||||
enter_symbol:
|
||||
if (och == '.' &&
|
||||
(chtype(ch) == BS || chtype(ch) == EF || chtype(ch) == CC)) {
|
||||
if (chtype(ch) == CC)
|
||||
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;
|
||||
|
||||
|
Reference in New Issue
Block a user