706
707
Sink_printf(snk,"%c",(c_byte)c1);
707
708
if( *(p+i+3) == '.' )
709
assert0(i + 9 < len,"invalid start pattern or quotient token ID");
710
assert0(i + 9 <= len,"invalid start pattern or quotient token ID");
1472
1474
bug2(False,"\'Scn_defTokId(\"%s\",%d)\': Token not seen",Name,tid);
1477
c_bool Stream_hasTokId(Scn_Stream t, string Name)
1478
/* whether 'Name' is a token in scan stream 't' */
1479
{ int cnt, i, j, g = -1; Scn_Stream_IMP s = (Scn_Stream_IMP)t;
1480
size_t len = strlen(Name);
1481
if( s->cScanner->Groups == 0 )
1483
for (i = 1; i < s->cScanner->Tokens; i++)
1485
!strncmp(Name,s->cScanner->TokId[i],len) &&
1486
(s->cScanner->TokId[i][len] == '\0' ||
1487
s->cScanner->TokId[i][len] == SCN_SEP_TOK_ID_PATTERN))
1493
{ Scn_Stream_IMP x = (Scn_Stream_IMP)Stream_current(t);
1494
if( x->cEmbeds == (ROW(Any_T))NULL || x->Group < 0 )
1496
i = 0; cnt = s->cScanner->Groups;
1497
if( (g=s->Group) >= 0 )
1499
for (j = 1; j < s->cScanner->GrpScn[g]->Tokens; j++)
1500
if (!strncmp(Name,s->cScanner->GrpScn[g]->TokId[j],len) &&
1501
(s->cScanner->GrpScn[g]->TokId[j][len] == '\0' ||
1502
s->cScanner->GrpScn[g]->TokId[j][len] == SCN_SEP_TOK_ID_PATTERN))
1510
i = x->Group; cnt = x->Group + 1;
1512
for ( ; i < cnt; i++)
1514
if( i == g ) continue;
1515
for (j = 1; j < s->cScanner->GrpScn[i]->Tokens; j++)
1517
!strncmp(Name,s->cScanner->GrpScn[i]->TokId[j],len) &&
1518
(s->cScanner->GrpScn[i]->TokId[j][len] == '\0' ||
1519
s->cScanner->GrpScn[i]->TokId[j][len] == SCN_SEP_TOK_ID_PATTERN))
1475
1528
static void setIndTokKey(Scn_Stream t, symbol keysym)
1476
1529
{ Scn_Stream_IMP s = (Scn_Stream_IMP)t;
1477
1530
long klen, dlen, ilen;
1578
c_bool Stream_defDynKeyId(Scn_Stream t, symbol keysym, short tid)
1579
/* defines 'tid' as number for dynamic keyword 'keysym' in scan stream 't' */
1580
{ Scn_Stream_IMP s = (Scn_Stream_IMP)t;
1581
if( !MAP_defined(s->cdefkey,keysym) )
1583
MAP_dfndom(s->cdefkey,keysym,(long)tid);
1525
1589
void Stream_defKeyId(Scn_Stream t, string Text, short tid)
1526
1590
/* defines 'tid' as number for keyword 'Text' in scan stream 't' */
1527
1591
{ Scn_Stream_IMP s = (Scn_Stream_IMP)t;
1989
2055
if( s->wc2mb == (string (*)(wc_string wc))NULL )
1991
if( s->cC_eof == 0 && strstr(s->cBuf,pat) != (c_string)NULL )
1992
{ /* single byte text mode, pattern found */
1993
s->cTok = t->cPatTok;
1994
if( s->cScanner->Groups > 0 )
1995
Stream_switch_group(t,t->cPatGrp,C_True);
1996
t->cPatSym = (symbol)NULL;
2058
if( s->cC_eof == 0 && (p=strstr(s->cBuf,pat)) != (c_string)NULL )
2060
if( t->cPatCnt != 1 || *(p+strlen(pat)) != pat[0] )
2061
{ /* single byte text mode, pattern found */
2062
s->cTok = t->cPatTok;
2063
if( s->cScanner->Groups > 0 )
2064
Stream_switch_group(t,t->cPatGrp,C_True);
2065
t->cPatSym = (symbol)NULL;
1999
2069
if( s->cC_eof < 0 ) /* binary mode */
2014
2084
if( flg && s->cBuf[j] != pat[0] ) i=j;
2015
2085
else flg = C_False;
2017
if( len == k ) /* pattern found */
2019
s->cTok = t->cPatTok;
2020
if( s->cScanner->Groups > 0 )
2021
Stream_switch_group(t,t->cPatGrp,C_True);
2022
t->cPatSym = (symbol)NULL;
2089
if( t->cPatCnt != 1 || j >= s->cLen || s->cBuf[j] != pat[0] )
2090
{ /* pattern found */
2091
s->cTok = t->cPatTok;
2092
if( s->cScanner->Groups > 0 )
2093
Stream_switch_group(t,t->cPatGrp,C_True);
2094
t->cPatSym = (symbol)NULL;
2045
2118
if( flg && c != pat[0] ) i=j;
2046
2119
else flg = C_False;
2048
if( len == k ) /* pattern found */
2050
s->cTok = t->cPatTok;
2051
if( s->cScanner->Groups > 0 )
2052
Stream_switch_group(t,t->cPatGrp,C_True);
2053
t->cPatSym = (symbol)NULL;
2123
if( t->cPatCnt != 1 || j >= s->cLen || ((char)s->cWBuf[j]) != pat[0] )
2124
{ /* pattern found */
2125
s->cTok = t->cPatTok;
2126
if( s->cScanner->Groups > 0 )
2127
Stream_switch_group(t,t->cPatGrp,C_True);
2128
t->cPatSym = (symbol)NULL;
2541
2617
return x->cdeftok[0];
2621
if( s->cScanner->Groups > 0 && !strncmp("tok_",s->cScanner->GrpScn[s->Group]->Name,4) )
2622
return x->cdeftok[s->cTok];
2544
2623
return MAP_defined(x->cdefkey,s->cSym)
2545
2624
? MAP_apply_short(x->cdefkey,s->cSym)
2546
2625
: x->cdeftok[s->cTok];
2549
2629
short Stream_ctid_nokey(Scn_Stream t)