char *isl_stream_read_ident_if_available(struct isl_stream *s);
int isl_stream_eat(struct isl_stream *s, int type);
int isl_stream_is_empty(struct isl_stream *s);
+int isl_stream_skip_line(struct isl_stream *s);
enum isl_token_type isl_stream_register_keyword(struct isl_stream *s,
const char *name);
return ISL_TOKEN_IDENT;
}
+int isl_stream_skip_line(struct isl_stream *s)
+{
+ int c;
+
+ while ((c = isl_stream_getc(s)) != -1 && c != '\n')
+ /* nothing */
+ ;
+
+ return c == -1 ? -1 : 0;
+}
+
static struct isl_token *next_token(struct isl_stream *s, int same_line)
{
int c;
/* skip spaces and comment lines */
while ((c = isl_stream_getc(s)) != -1) {
if (c == '#') {
- while ((c = isl_stream_getc(s)) != -1 && c != '\n')
- /* nothing */
- ;
- if (c == -1 || (same_line && c == '\n'))
+ if (isl_stream_skip_line(s) < 0)
+ break;
+ c = '\n';
+ if (same_line)
break;
} else if (!isspace(c) || (same_line && c == '\n'))
break;