* from: llscan.c,v 2.2 88/09/19 12:55:06 nhall Exp
* ************************* NOTICE *******************************
* This code is in the public domain. It cannot be copyrighted.
* This scanner was originally written by Keith Thompson for the
* University of Wisconsin Crystal project.
* It was subsequently modified significantly by Nancy Hall at the
* University of Wisconsin for the ARGO project.
* ****************************************************************
/* null, soh ^a, stx ^b etx ^c eot ^d enq ^e ack ^f bel ^g */
EOFILE
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
,
/* bs ^h ht ^i lf ^j vt ^k ff ^l cr ^m so ^n si ^o */
UNUSED
, IGNORE
, IGNORE
, UNUSED
, IGNORE
, IGNORE
, UNUSED
, UNUSED
,
/* dle ^p dc1 ^q dc2 ^r dc3 ^s dc4 ^t nak ^u syn ^v etb ^w */
UNUSED
, UNUSED
, UNUSED
, UNUSED
, EOFILE
, UNUSED
, UNUSED
, UNUSED
,
/* can ^x em ^y sub ^z esc ^] fs ^\ gs ^} rs ^` us ^/ */
UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
, UNUSED
,
IGNORE
, UNUSED
, OPCHAR
, UNUSED
, OPCHAR
, UNUSED
, OPCHAR
, OPCHAR
,
OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
,
DIGITS
, DIGITS
, DIGITS
, DIGITS
, DIGITS
, DIGITS
, DIGITS
, DIGITS
,
DIGITS
, DIGITS
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
, OPCHAR
,
UNUSED
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, OPCHAR
, UNUSED
, OPCHAR
, OPCHAR
, LETTER
,
UNUSED
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
, LETTER
,
LETTER
, LETTER
, LETTER
, OPCHAR
, UNUSED
, OPCHAR
, UNUSED
, UNUSED
extern FILE *astringfile
;
static char buffer
[2][LINELEN
];
static int currentbuf
= 1;
#define addbuf(x) *buffptr++ = x
while((chtype
[ch
] == IGNORE
) ) {
fprintf(stderr
,"Insert %s\n", llstrings
[t
->llterm
]);
fprintf(stderr
,"Delete %s\n", llstrings
[t
->llterm
]);
#define TVAL (t->llattrib)
(void) fputc(buffer
[currentbuf
][i
], stderr
);
(void) fputc('\n', stderr
);
static struct { char *key_word
; int term_type
; } keys
[] = {
{ "DEFAULT", T_DEFAULT
},
{ "NULLACTION", T_NULLACTION
},
{ "SYNONYM", T_SYNONYM
},
{ "TRANSITIONS", T_TRANSITIONS
},
{ "INCLUDE", T_INCLUDE
},
{ "PROTOCOL", T_PROTOCOL
},
for (i
= 0; keys
[i
].key_word
; i
++) {
if( !strcmp(c
, (*buf
= keys
[i
].key_word
) ) ) {
return ( keys
[i
].term_type
);
/* c is the string delimiter
* allow the delimiter to be escaped
* the messy part: translate $ID to
* where ID is an event with a non-zero obj_struc
* need we check for the field???
register int allow_nesting
= (o
==c
)?-1:1;
fprintf(stdout
,"getstr: ch=%c, delimiters %c %c\n",
fprintf(stdout
,"getstr: buffptr 0x%x, currentbuf 0x%x\n",
"Eof inside of a string, delims= %c,%c, nesting %d",c
,o
, nested
);
/* might be an attribute */
fprintf(stdout
,"getstr: atttribute?\n");
/* assume it's an event */
/* addbuf is a macro so this isn't as bad as
if( (ch
= getch()) == '$' ) {
addbuf('e'); addbuf('-'); addbuf('>');
addbuf('e'); addbuf('v'); addbuf('_');
addbuf('u'); addbuf('n'); addbuf('i');
addbuf('o'); addbuf('n');
AddCurrentEventName(& buffptr
);
} while(chtype
[ch
] & LETTER
);
if( !strcmp(obufp
, synonyms
[PCB_SYN
],
strlen(synonyms
[PCB_SYN
]) )) {
} else if( !strncmp(obufp
, synonyms
[EVENT_SYN
],
strlen(synonyms
[EVENT_SYN
]))) {
fprintf(stderr
, "Unknown synonym %s\n", obufp
);
addbuf('-'); addbuf('>');
/* needs to be checked for nesting */
/* end of attribute handling */
/* possible escape - this is kludgy beyond belief:
* \ is used to escape open and closing delimiters
* otherwise it's passed through to be compiled by C
if( (ch
!= o
) && (ch
!= c
) && (ch
!= '$') ) {
/* may need to handle case where \ is last char in file... */
/* don't treat is as escape; not open or close so
* don't have to worry about nesting either
if( ch
== o
) nested
+= allow_nesting
;
else if( ch
== c
) nested
--;
if ( (buffptr
- buffer
[currentbuf
]) > LINELEN
) {
"%s too long.\n", (o
=='{')?"Action":"Predicate"); /*}*/
"buffptr, currentbuf 0x%x, 0x%x\n",buffptr
,currentbuf
);
fprintf(stdout
,"loop in getstr: ch 0x%x,%c o=%c,c=%c nested=%d\n",
fprintf(stdout
,"exit getstr: got %s\n", buffer
[currentbuf
]);
fprintf(stdout
,"exit getstr: buffptr 0x%x, currentbuf 0x%x\n",
if ((int)c
== EOF
) c
= (char)0;
if (feof(infile
)) c
= (char) 0;
fprintf(stdout
, "getch: 0x%x\n", c
);
(void) fputc( c
, stdout
);
buffptr
= &buffer
[currentbuf
][0];
fprintf(stderr
, "Illegal character in input - 0x%x ignored.", ch
);
/* possible comment : elide ; kludge */
fprintf(stdout
, "Comment ch=%c\n", ch
);
fprintf(stderr
,"Syntax error : character(0x%x) ignored", ch
);
register int state
= 2, whatchar
=0;
/* done seen-star middle */
if( (c
= getch()) == (char)0)
whatchar
= (c
=='*')?0:(c
=='/'?1:2);
"comment: whatchar = %d, c = 0x%x,%c, oldstate=%d",
state
= dfa
[whatchar
][state
];
fprintf(stdout
, ", newstate=%d\n", state
);
"Syntax error: end of file inside a comment");
fprintf(stdout
, "end of comment at 0x%x,%c\n",ch
,ch
);
TVAL
.FSTRING
.address
= stash(buffer
[currentbuf
]);
TVAL
.PREDICATE
.address
= buffer
[currentbuf
];
TVAL
.ACTION
.address
= buffer
[currentbuf
];
fprintf(stderr
,"Syntax error : character(0x%x) ignored", ch
);
} while(chtype
[ch
] & (LETTER
| DIGITS
));
t
->llterm
= iskey(buffer
[currentbuf
], &TVAL
.ID
.address
);
TVAL
.ID
.address
= buffer
[currentbuf
];
fprintf(stdout
, "llscan: id or keyword 0x%x, %s\n",
TVAL
.ID
.address
, TVAL
.ID
.address
);
fprintf(stderr
, "Snark in llscan: chtype=0x%x, ch=0x%x\n",