/* This is the Assembler Pre-Processor
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* App, the assembler pre-processor. This pre-processor strips out excess
spaces, turns single-quoted characters into a decimal constant, and turns
# <number> <filename> <garbage> into a .line <number>;.file <filename> pair.
This needs better error-handling.
#define bzero(s,n) memset(s,0,n)
#if !defined(__STDC__) && !defined(const)
#define const /* Nothing */
static const char symbol_chars
[] =
"$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
extern const char comment_chars
[];
extern const char line_comment_chars
[];
#define LEX_IS_SYMBOL_COMPONENT (1)
#define LEX_IS_WHITESPACE (2)
#define LEX_IS_LINE_SEPERATOR (4)
#define LEX_IS_COMMENT_START (8) /* JF added these two */
#define LEX_IS_LINE_COMMENT_START (16)
#define IS_SYMBOL_COMPONENT(c) (lex [c] & LEX_IS_SYMBOL_COMPONENT)
#define IS_WHITESPACE(c) (lex [c] & LEX_IS_WHITESPACE)
#define IS_LINE_SEPERATOR(c) (lex [c] & LEX_IS_LINE_SEPERATOR)
#define IS_COMMENT(c) (lex [c] & LEX_IS_COMMENT_START)
#define IS_LINE_COMMENT(c) (lex [c] & LEX_IS_LINE_COMMENT_START)
bzero (lex
, sizeof(lex
)); /* Trust NOBODY! */
lex
[' '] |= LEX_IS_WHITESPACE
;
lex
['\t'] |= LEX_IS_WHITESPACE
;
for (p
=symbol_chars
;*p
;++p
)
lex
[*p
] |= LEX_IS_SYMBOL_COMPONENT
;
lex
['\n'] |= LEX_IS_LINE_SEPERATOR
;
lex
[':'] |= LEX_IS_LINE_SEPERATOR
;
lex
[';'] |= LEX_IS_LINE_SEPERATOR
;
for (p
=comment_chars
;*p
;p
++)
lex
[*p
] |= LEX_IS_COMMENT_START
;
for (p
=line_comment_chars
;*p
;p
++)
lex
[*p
] |= LEX_IS_LINE_COMMENT_START
;
return scrub_string
== scrub_last_string
? EOF
: *scrub_string
++;
do_scrub_next_char(get
,unget
)
/* State 0: beginning of normal line
1: After first whitespace on normal line (flush more white)
2: After first non-white on normal line (keep 1white)
3: after second white on normal line (flush white)
4: after putting out a .line, put out digits
5: parsing a string, then go to old-state
6: putting out \ escape in a "d string.
7: After putting out a .file, put out string.
8: After putting out a .file string, flush until newline.
-1: output string in out_string and go to the state in old_state
-2: flush text until a '*' '/' is seen, then go to state old_state
while(ch
!=EOF
&& ch
!='\n' && ch
!='*');
if(ch
==EOF
|| (ch
>='0' && ch
<='9'))
while(ch
!=EOF
&& IS_WHITESPACE(ch
))
while(ch
!=EOF
&& ch
!='\n')
as_warn("End of file in string: inserted '\"'");
/* This is neet. Turn "string
more string" into "string\n more string"
as_warn("Unknown escape '\\%c' in string: Ignored",ch
);
as_warn("End of file in string: '\"' inserted");
while(ch
!=EOF
&& IS_WHITESPACE(ch
));
if(IS_COMMENT(ch
) || (state
==0 && IS_LINE_COMMENT(ch
)) || ch
=='/' || IS_LINE_SEPERATOR(ch
)) {
if(state
==0 || state
==2) {
} while(ch
!=EOF
&& ch
!='*');
as_warn("End of file in '/' '*' string: */ inserted");
if(IS_COMMENT('/') || (state
==0 && IS_LINE_COMMENT('/'))) {
as_warn("End-of-file after a ': \000 inserted");
sprintf(out_buf
,"(%d)",ch
&0xff);
if(state
==0 && IS_LINE_COMMENT(ch
)) {
while(ch
!=EOF
&& IS_WHITESPACE(ch
));
as_warn("EOF in comment: Newline inserted");
while(ch
!=EOF
&& ch
!='\n')
as_warn("EOF in Comment: Newline inserted");
} else if(IS_COMMENT(ch
)) {
while(ch
!=EOF
&& ch
!='\n');
as_warn("EOF in comment: Newline inserted");
as_warn("End-of-File not at end of a line");
char comment_chars
[] = "|";
char line_comment_chars
[] = "#";
while((ch
=do_scrub_next_char(stdin
))!=EOF
)