* Copyright (c) 1982 Regents of the University of California
static char sccsid
[] = "@(#)asscan2.c 4.14 7/6/83";
static inttoktype oval
= NL
;
char inbuffer
[ASINBUFSIZ
];
char *Ginbufptr
= inbuffer
;
got
= read(stdin
->_file
, inbuffer
+ nread
, goal
);
* getchar assumes that Ginbufcnt and Ginbufptr
* are adjusted as if one character has been removed
Ginbufptr
= inbuffer
+ 1;
struct tokbufdesc
*bufferbox
;
reg
int ryylval
; /* local copy of lexical value */
extern int yylval
; /* global copy of lexical value */
reg
int val
; /* the value returned */
int i
; /* simple counter */
int ch
; /* treated as a character */
int ch1
; /* shadow value */
reg ptrall bufptr
; /* where to stuff tokens */
ptrall bufub
; /* where not to stuff tokens */
long intval
; /* value of int */
int linescrossed
; /* when doing strings and comments */
reg
int strlg
; /* the length of a string */
(bytetoktype
*)bufptr
= (bytetoktype
*) & (bufferbox
->toks
[0]);
(bytetoktype
*)bufub
= &(bufferbox
->toks
[AVAILTOKS
]);
ryylval
= (int)savestr(newfname
, strlen(newfname
)+1, STR_BOTH
);
switch(ryylval
= (type
+1)[ch
= getchar()]) {
ptoken(bufptr
, PARSEEOF
);
case DIV
: /*process C style comments*/
if ( (ch
= getchar()) == '*') { /*comment prelude*/
ch
= getchar(); /*skip over the * */
} else { /*just an ordinary DIV*/
* Attempt to recognize a C preprocessor
* style comment '^#[ \t]*[0-9]*[ \t]*".*"
ch
= getchar(); /*bump the #*/
while (INCHARSET(ch
, SPACE
))
ch
= getchar();/*bump white */
if (INCHARSET(ch
, DIGIT
)){
while(INCHARSET(ch
, DIGIT
)){
intval
= intval
*10 + ch
- '0';
while (INCHARSET(ch
, SPACE
))
if (ch
== '"' || ch
== '\n'){
pint(bufptr
, intval
- 1);
* The '"' has already been
* it is given to the parser
* Well, its just an ordinary decadent comment
while ((ch
!= '\n') && (ch
!= EOFCHAR
))
val
= ryylval
= oval
= NL
;
oval
= SP
; /*invalidate ^# meta comments*/
case REGOP
: /* % , could be used as modulo, or register*/
if (INCHARSET(ch
, DIGIT
)){
if (INCHARSET( (ch
= getchar()), REGDIGIT
))
* God only knows what the original author
* wanted this undocumented feature to
while(INCHARSET( (ch
= getchar()), SIGN
)) {
if (INCHARSET(ch
, SZSPECBEGIN
)){
if( (ch
= getchar()) == '`' || ch
== '^'){
ch1
|= 0100; /*convert to lower*/
case 'b': ryylval
= 1; break;
case 'w': ryylval
= 2; break;
case 'l': ryylval
= 4; break;
default: ryylval
= d124
; break;
ch
= ch1
; /*restore first character*/
if (rcp
< &yytext
[NCPName
])
} while (INCHARSET ( (ch
= getchar()), ALPHA
| DIGIT
));
while (INCHARSET(ch
, SPACE
))
switch((op
= *lookup(1))->s_tag
){
* Its a name... (Labels are subsets of name)
opstruct
= ( (struct instab
*)op
)->i_opcode
;
ryylval
= ( (struct instab
*)op
)->i_opcode
;
* restore local inbufptr and inbufcnt
* yylval or yybignum has been stuffed as a side
* effect to number(); get the global yylval
* into our fast local copy in case it was an INT.
* We allow the C style operators
* << and >>, as well as < and >
if ( (ch1
= getchar()) != ch
)
if ( (ch
= getchar()) =='(')
if ((ryylval
= getchar()) == '\n')
scanlineno
++; /*not entirely correct*/
for (strlg
= 0; /*VOID*/; strlg
++){
yywarning("New line in a string constant");
ch
= getchar(); /*skip the '\\'*/
if ( INCHARSET(ch
, BSESCAPE
)){
case 'b': ch
= '\b'; goto stuff
;
case 'f': ch
= '\f'; goto stuff
;
case 'n': ch
= '\n'; goto stuff
;
case 'r': ch
= '\r'; goto stuff
;
case 't': ch
= '\t'; goto stuff
;
if ( !(INCHARSET(ch
, OCTDIGIT
)) )
while ( (i
< 3) && (INCHARSET(ch
, OCTDIGIT
))){
* account for any lines that were crossed
ptoken(bufptr
, ILINESKIP
);
pint(bufptr
, linescrossed
);
* Cheat: append a trailing null to the string
* and then adjust the string length to ignore
* the trailing null. If any STRING client requires
* the trailing null, the client can just change STRLEN
ryylval
= (int)savestr((char *)0, strlg
+ 1, STR_FILE
);
((struct strdesc
*)ryylval
)->sd_strlen
-= 1;
yyerror("Illegal character mapped: %d, char read:(octal) %o",
* here with one token, so stuff it
case BFINT
: plong(bufptr
, ryylval
);
case INT
: plong(bufptr
, ryylval
);
case BIGNUM
: pnumber(bufptr
, yybignum
);
case STRING
: pptr(bufptr
, (int)(char *)ryylval
);
case NAME
: pptr(bufptr
, (int)(struct symtab
*)ryylval
);
case REG
: pchar(bufptr
, ryylval
);
popcode(bufptr
, opstruct
);
popcode(bufptr
, opstruct
);
pptr(bufptr
, (int)(struct symtab
*)symalloc());
pptr(bufptr
, (int)(struct symtab
*)symalloc());
} /*end of the while to stuff the buffer*/
bufferbox
->tok_count
= (bytetoktype
*)bufptr
- &(bufferbox
->toks
[0]);
* We put the last token in the buffer to be a MINUS
* symbol. This last token will never be picked up
* in the normal way, but can be looked at during
* a peekahead look that the short circuit expression
* evaluator uses to see if an expression is complicated.
* Consider the following situation:
* the peekahead would want to look across the buffer,
* but will look in the buffer end zone, see the minus, and