* Copyright (C) 1983 by Lee Moore. All rights reserved.
* Get one character from the input. Set flags.
static int GetCharacter1(ts
)
ts
->NotEndOfFile
= (c
!= EOF
);
* Get one character from the input. Set Flags. (see above)
static int GetCharacter(ts
)
if( c
== '\\' ) /* quote the next character? */
else if( c
== '#' ) /* if this a comment? */
while( c
!= '\n' && c
!= EOF
)
* Skip over blank space. Set LastTokenInLine if we see at a new-line.
static SkipBlankSpace(ts
)
ts
->LastTokenInLine
= FALSE
;
while( isspace(ts
->CurChar
) ) {
if( ts
->CurChar
== '\n' )
ts
->LastTokenInLine
= TRUE
;
ts
->CurChar
= GetCharacter(ts
); } }
* Initialize token package
struct TokenState
*InitTokenStream(from
)
ts
= (struct TokenState
*) malloc(sizeof(struct TokenState
));
ts
->LastTokenInLine
= FALSE
;
ts
->NotEndOfFile
= FALSE
,
ts
->CurChar
= GetCharacter(ts
);
* Close and release resources
* Get the next token in the input. Tokens are strings of characters that are
* delimited by <space>, <tab> and <new-line>
GetToken(ts
, arg
, maxSize
)
while( !isspace(ts
->CurChar
) && ts
->CurChar
!= EOF
&& maxSize
> 0 ) {
ts
->CurChar
= GetCharacter(ts
);
* Test if we have read all the tokens in the current line
return ts
->LastTokenInLine
; }
* return true if we have read all the tokens in the file
return !ts
->NotEndOfFile
; }