Skip to content

Commit

Permalink
Add longer bodies to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 3, 2024
1 parent d8f48a6 commit 84e57b2
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,19 @@ bool tree_sitter_just_external_scanner_scan(void *payload, TSLexer *lexer,
while (std::iswspace(lookahead)) {
switch (lookahead) {
case '\n':
// state->eol = true;
return false;

case '\t':
case ' ':
skip(lexer);
break;
}

// if (lexer->eof(lexer)) {
// if (valid_symbols[DEDENT]) {
// return true;
// }
// }
}

uint32_t indent = lexer->get_column(lexer);
Expand Down
119 changes: 117 additions & 2 deletions test/corpus/recipes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@ recipe
foo:
body

bar:
body

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(DEDENT))))
(item
(recipe
(recipeheader
Expand Down Expand Up @@ -88,7 +104,10 @@ foo: bar baz
arguments
================================================================================

foo bar *baz:
foo bar:
body

baz qux *quux:
body

--------------------------------------------------------------------------------
Expand All @@ -97,6 +116,22 @@ foo bar *baz:
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME)
(parameters
(parameter
(NAME))))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE))))
(DEDENT))))
(item
(recipe
(recipeheader
Expand Down Expand Up @@ -187,7 +222,6 @@ foo:
(eol
(NEWLINE))))


================================================================================
shebang
================================================================================
Expand Down Expand Up @@ -236,3 +270,84 @@ foo:
(notcomment)
(NEWLINE)))))
(DEDENT)))))

================================================================================
longer bodies
================================================================================

foo:
body

more body

# same body
and even more

bar:
body

more body

# same body
and even more

--------------------------------------------------------------------------------

(source_file
(item
(eol
(NEWLINE)))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE)))
(line
(recipeline
(notcomment)
(TEXT)
(NEWLINE)))
(line
(comment
(NEWLINE)))
(line
(recipeline
(notcomment)
(TEXT)
(TEXT)
(NEWLINE))))
(DEDENT))))
(item
(recipe
(recipeheader
(NAME))
(NEWLINE)
(body
(INDENT)
(recipe_body
(line
(recipeline
(notcomment)
(NEWLINE)))
(line
(recipeline
(notcomment)
(TEXT)
(NEWLINE)))
(line
(comment
(NEWLINE)))
(line
(recipeline
(notcomment)
(TEXT)
(TEXT)
(NEWLINE))))
(DEDENT)))))

0 comments on commit 84e57b2

Please sign in to comment.