yasm_errwarn_propagate(errwarns, parser_gas.rept->startline);
}
+ /* Check for ending inside a comment */
+ if (parser_gas.state == COMMENT) {
+ yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment"));
+ /* XXX: Minus two to compensate for already having moved past the EOF
+ * in the linemap.
+ */
+ yasm_errwarn_propagate(errwarns,
+ yasm_linemap_get_current(parser_gas.linemap)-2);
+ }
+
gas_parser_cleanup(&parser_gas);
/* Free locallabel base if necessary */
Scanner s;
enum {
INITIAL,
+ COMMENT,
SECTION_DIRECTIVE,
INSTDIR
} state;
/* Jump to proper "exclusive" states */
switch (parser_gas->state) {
+ case COMMENT:
+ goto comment;
case SECTION_DIRECTIVE:
goto section_directive;
default:
RETURN(ID);
}
+ "/*" { parser_gas->state = COMMENT; goto comment; }
"#" (any \ [\n])* { goto scan; }
ws+ { goto scan; }
}
*/
+ /* C-style comment; nesting not supported */
+comment:
+ SCANINIT();
+
+ /*!re2c
+ /* End of comment */
+ "*/" { parser_gas->state = INITIAL; goto scan; }
+
+ "\n" {
+ if (parser_gas->save_input)
+ cursor = save_line(parser_gas, cursor);
+ RETURN(s->tok[0]);
+ }
+
+ any {
+ if (cursor == s->eof)
+ return 0;
+ goto comment;
+ }
+ */
+
/* .section directive (the section name portion thereof) */
section_directive:
SCANINIT();
TESTS += modules/parsers/gas/tests/bin/gas_bin_test.sh
EXTRA_DIST += modules/parsers/gas/tests/bin/gas_bin_test.sh
+EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.asm
+EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.errwarn
+EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.hex
EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.asm
EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.errwarn
EXTRA_DIST += modules/parsers/gas/tests/bin/reptempty.asm
--- /dev/null
+# This is a comment
+
+/* So is this */
+
+.byte 0 /* at end of line? */
+
+.byte 0 /* at end of line,
+multi-line? */
+
+/* start of line? */ .byte 0
+
+/* What about
+a multi-line
+comment? -- at start of line?
+*/ .byte 0
+
+.byte 0, /* in middle? */ 1
+
+# Illegal; 1 seen on next line
+#.byte 0, /* in middle,
+#spanning lines? */ 1
+
+/* EOF in comment?
--- /dev/null
+-:23: warning: end of file in comment
--- /dev/null
+00
+00
+00
+00
+00
+01