If the file does not end in a newline, then a node might not also.
This requires a little more care in parsing strings and comments.
Signed-off-by: NeilBrown <neil@brown.name>
* unget so the newline is seen,
* but return rest of string as an error.
*/
* unget so the newline is seen,
* but return rest of string as an error.
*/
+ if (is_newline(ch))
+ unget_char(state);
close_token(state, &tk);
tk.num = TK_error;
return tk;
close_token(state, &tk);
tk.num = TK_error;
return tk;
!(ignored & (1<<TK_string))) {
wchar_t first = tk.txt.txt[0];
reset_token(state, &tk);
!(ignored & (1<<TK_string))) {
wchar_t first = tk.txt.txt[0];
reset_token(state, &tk);
+ ch = get_char(state);
+ tk.num = TK_error;
+ while (!at_eon(state) && !is_newline(ch)) {
- while (ch != first && !is_newline(ch));
- tk.num = TK_string;
- if (is_newline(ch)) {
- unget_char(state);
- tk.num = TK_error;
+ if (ch == first) {
+ tk.num = TK_string;
+ break;
+ }
+ if (is_newline(ch)) {
+ unget_char(state);
+ break;
+ }
}
close_token(state, &tk);
return tk;
}
close_token(state, &tk);
return tk;
#### Single line comments
#### Single line comments
-A single-line comment continues up to, but not including the newline.
+A single-line comment continues up to, but not including the newline
+or end of node.
###### parse comment
if (is_line_comment(tk.txt)) {
###### parse comment
if (is_line_comment(tk.txt)) {
- while (!is_newline(ch))
+ while (!is_newline(ch) && !at_eon(state))
+ if (is_newline(ch))
+ unget_char(state);
close_token(state, &tk);
tk.num = TK_line_comment;
if (ignored & (1 << TK_line_comment))
close_token(state, &tk);
tk.num = TK_line_comment;
if (ignored & (1 << TK_line_comment))