]> ocean-lang.org Git - ocean/commitdiff
scanner: fix up detection of comments blended with marks.
authorNeilBrown <neil@brown.name>
Tue, 3 Jun 2014 11:07:58 +0000 (21:07 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 05:40:03 +0000 (15:40 +1000)
If we see the start of a comment in an unknown mark, we need to
finish the mark before the start of the comment.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/scanner.mdc

index 113c9d2ea199480e4f9d057a76f9c3895c5b6deb..cbb8d6f4311b9cf479ac9b789bdd467b4bbd1eaf 100644 (file)
@@ -347,25 +347,26 @@ Known marks are included in the same list as the list of known words.
                        return tk;
                }
                prev = ch;
-               if (prev == '/')
-                       save_unget_state(state);
+               save_unget_state(state);
                ch = get_char(state);
                if (!(ignored && (1<<TK_string)) && is_quote(ch))
                        break;
-               if (!(ignored && (1<<TK_line_comment)) &&
-                   prev == '/' && ch == '/') {
+               if (prev == '#')
+                       break;
+               if (prev == '/' && ch == '/' && tk.txt.len > 1) {
                        restore_unget_state(state);
                        break;
                }
-               if (!(ignored && (1<<TK_block_comment)) &&
-                   prev == '/' && ch == '*') {
+               if (prev == '/' && ch == '*' && tk.txt.len > 1) {
                        restore_unget_state(state);
                        break;
                }
        }
        unget_char(state);
-       if (tk.num != TK_error)
+       if (tk.num != TK_error) {
+               close_token(state, &tk);
                return tk;
+       }
 
 ###### unknown mark
        if (tk.txt.len) {
@@ -506,7 +507,7 @@ it would not suffer from this rule.
 
 These two comment types are reported as two separate token types, and
 consequently can be ignored separately.  When ignored a comment is
-parsed and discarded.
+still parsed, but is discarded.
 
 ###### token types
        TK_line_comment,