summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lex.c10
-rw-r--r--test/invalid-hence/empty-10.hence6
-rw-r--r--test/invalid-hence/empty-10.hence.expected1
3 files changed, 14 insertions, 3 deletions
diff --git a/lex.c b/lex.c
index a209a6c..6dc38d2 100644
--- a/lex.c
+++ b/lex.c
@@ -164,14 +164,14 @@ lex_alphanum(void) {
}
static struct token
-lex_eol(void) {
+lex_eol(char eolchar) {
struct token t;
t.type = TOK_EOL;
t.loc = get_current_loc();
t.span = 1;
- expect('\n');
+ expect(eolchar);
return t;
}
@@ -208,7 +208,11 @@ lex_line(void) {
break;
case '\r':
case '\n':
- add_token(lex_eol());
+ add_token(lex_eol(buf[column_number]));
+ break;
+ case '#':
+ add_token(lex_eol(buf[column_number]));
+ return 0;
break;
default:
/* perform more broad checks */
diff --git a/test/invalid-hence/empty-10.hence b/test/invalid-hence/empty-10.hence
new file mode 100644
index 0000000..7a0896d
--- /dev/null
+++ b/test/invalid-hence/empty-10.hence
@@ -0,0 +1,6 @@
+#
+# foo
+ # foo # foo
+ #foo asdf
+ #foo
+#foo
diff --git a/test/invalid-hence/empty-10.hence.expected b/test/invalid-hence/empty-10.hence.expected
new file mode 100644
index 0000000..738f19c
--- /dev/null
+++ b/test/invalid-hence/empty-10.hence.expected
@@ -0,0 +1 @@
+invalid-hence/empty-10.hence: Error: Expected module declaration, got end of file