[ ] and {} should be handled by the scanner, not the parser (obs from Paulo Moura).
This commit is contained in:
parent
1176f71f3a
commit
97a27bd4b6
30
C/parser.c
30
C/parser.c
@ -581,31 +581,19 @@ ParseTerm(int prio, JMPBUFF *FailBuff)
|
|||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
NextToken;
|
NextToken;
|
||||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok) &&
|
t = ParseList(FailBuff);
|
||||||
Unsigned(Yap_tokptr->TokInfo) == ']') {
|
checkfor((Term) ']', FailBuff);
|
||||||
t = TermNil;
|
|
||||||
NextToken;
|
|
||||||
} else {
|
|
||||||
t = ParseList(FailBuff);
|
|
||||||
checkfor((Term) ']', FailBuff);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
NextToken;
|
NextToken;
|
||||||
if (Yap_tokptr->Tok == Ord(Ponctuation_tok) &&
|
t = ParseTerm(1200, FailBuff);
|
||||||
Unsigned(Yap_tokptr->TokInfo) == '}') {
|
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
||||||
t = MkAtomTerm(NameOfFunctor(FunctorBraces));
|
/* check for possible overflow against local stack */
|
||||||
NextToken;
|
if (H > ASP-4096) {
|
||||||
} else {
|
Yap_ErrorMessage = "Stack Overflow";
|
||||||
t = ParseTerm(1200, FailBuff);
|
FAIL;
|
||||||
t = Yap_MkApplTerm(FunctorBraces, 1, &t);
|
|
||||||
/* check for possible overflow against local stack */
|
|
||||||
if (H > ASP-4096) {
|
|
||||||
Yap_ErrorMessage = "Stack Overflow";
|
|
||||||
FAIL;
|
|
||||||
}
|
|
||||||
checkfor((Term) '}', FailBuff);
|
|
||||||
}
|
}
|
||||||
|
checkfor((Term) '}', FailBuff);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FAIL;
|
FAIL;
|
||||||
|
18
C/scanner.c
18
C/scanner.c
@ -1194,6 +1194,24 @@ Yap_tokenizer(int inp_stream, Term *tposp)
|
|||||||
if (t->TokInfo == '(' && !solo_flag) {
|
if (t->TokInfo == '(' && !solo_flag) {
|
||||||
t->TokInfo = 'l';
|
t->TokInfo = 'l';
|
||||||
solo_flag = TRUE;
|
solo_flag = TRUE;
|
||||||
|
} else if (och == '[') {
|
||||||
|
while (chtype(ch) == BS) { ch = Nxtch(inp_stream); };
|
||||||
|
if (ch == ']') {
|
||||||
|
t->TokInfo = Unsigned(AtomNil);
|
||||||
|
t->Tok = Ord(kind = Name_tok);
|
||||||
|
ch = Nxtch(inp_stream);
|
||||||
|
solo_flag = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (och == '{') {
|
||||||
|
while (chtype(ch) == BS) { ch = Nxtch(inp_stream); };
|
||||||
|
if (ch == '}') {
|
||||||
|
t->TokInfo = Unsigned(AtomBraces);
|
||||||
|
t->Tok = Ord(kind = Name_tok);
|
||||||
|
ch = Nxtch(inp_stream);
|
||||||
|
solo_flag = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t->Tok = Ord(kind = Ponctuation_tok);
|
t->Tok = Ord(kind = Ponctuation_tok);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user