Skip to content

Commit

Permalink
Fix parsing comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillof committed May 2, 2024
1 parent af9e5b3 commit bd6cb2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ Tokenizer::Token Tokenizer::get_next() {
case '#':
while ((c = source.get()) != '\n' && c != EOF) {
}
if (c != EOF) {
source.unget();
continue;
}
// fallthrough

case EOF:
Expand Down
19 changes: 18 additions & 1 deletion tests/comment.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
arguments ..
file build.fninja <>
# empty file
# empty line

rule a
command = a $in

build out: a in
# comment in build

build out2: a in
end-of-inline-data
file in <>
end-of-inline-data
file build/build.ninja {} <>
# This file is automatically created by fast-ninja from ../build.fninja
Expand All @@ -11,9 +21,16 @@ source_directory = ..
top_build_directory = .
top_source_directory = ..

rule a
command = a $in

rule fast-ninja
command = fast-ninja ..
generator = 1

build out : a ../in

build out2 : a ../in

build build.ninja : fast-ninja ../build.fninja
end-of-inline-data

0 comments on commit bd6cb2c

Please sign in to comment.