as: support line-comments starting with '#'

This commit is contained in:
Mikael Pettersson
2015-04-20 23:07:27 +02:00
parent b0aaba8f9a
commit bedc35abc5
2 changed files with 20 additions and 3 deletions

4
TODO
View File

@@ -43,9 +43,7 @@ Tools:
- readelf: add support for relocs
- readelf: add support for program headers
- as:
* add line-comment character, e.g. '#'
+ use it in doc/MUUO.txt
+ use it in as/tests/*.s
* add C /* ... */ comments
* support .ident:
+ change strtab to have a finalizer which returns an image array,
+ use standard output_section for strtab

View File

@@ -311,6 +311,23 @@ static enum token do_number(struct scan_state *scan_state, union token_attribute
return T_UINTEGER;
}
static int do_line_comment(struct scan_state *scan_state)
{
for (;;) {
int ch = scan_getchar();
switch (ch) {
case '\n':
++scan_state->linenr;
return T_NEWLINE;
case EOF:
badchar(scan_state, ch, "in line comment");
return T_ERROR;
default:
continue;
}
}
}
enum token scan_token(struct scan_state *scan_state, union token_attribute *token_attr)
{
int ch;
@@ -327,6 +344,8 @@ enum token scan_token(struct scan_state *scan_state, union token_attribute *toke
case '\n':
++scan_state->linenr;
return T_NEWLINE;
case '#':
return do_line_comment(scan_state);
case EOF:
return T_EOF;
case '@':