if (n >= 0)
tk.num = TK_reserved + n;
else if (tk.num != TK_error) {
- /* found a longest-known-mark */
+ /* found a longest-known-mark, still need to
+ * check for comments
+ */
+ if (tk.txt.len == 2 && tk.txt.txt[0] == '/' &&
+ (ch == '/' || ch == '*')) {
+ /* Yes, this is a comment, not a '/' */
+ restore_unget_state(state);
+ tk.num = TK_error;
+ break;
+ }
unget_char(state);
close_token(state, &tk);
return tk;
ch = get_char(state);
if (!(ignored && (1<<TK_string)) && is_quote(ch))
break;
- if (prev == '#')
+ if (prev == '#' && n < 0)
+ /* '#' is not a known mark, so assume it is a comment */
break;
- if (prev == '/' && ch == '/' && tk.txt.len > 1) {
+ if (prev == '/' && ch == '/' && tk.txt.len == 1 && n < 0) {
+ close_token(state, &tk);
restore_unget_state(state);
break;
}
- if (prev == '/' && ch == '*' && tk.txt.len > 1) {
+ if (prev == '/' && ch == '*' && tk.txt.len == 1 && n < 0) {
+ close_token(state, &tk);
restore_unget_state(state);
break;
}