Reflect newlines after pipes in fish grammar

The previous attempt to support newlines after pipes changed the lexer to
swallow newlines after encountering a pipe. This has two problems that are
difficult to fix:

1. comments cannot be placed after the pipe
2. fish_indent won't know about the newlines, so it will erase them

Address these problems by removing the lexer behavior, and replacing it
with a new parser symbol "optional_newlines" allowing the newlines to be
reflected directly in the fish grammar.
This commit is contained in:
ridiculousfish
2018-02-18 14:37:44 -08:00
parent ea4e997dc9
commit fd2a0dffa9
12 changed files with 50 additions and 80 deletions

View File

@@ -739,6 +739,18 @@ static void test_parser() {
err(L"leading pipe not reported properly");
}
if (parse_util_detect_errors(L"true | # comment") != PARSER_TEST_INCOMPLETE) {
err(L"comment after pipe not reported as incomplete");
}
if (parse_util_detect_errors(L"true | # comment \n false ")) {
err(L"comment and newline after pipe wrongly reported as error");
}
if (parse_util_detect_errors(L"true | ; false ") != PARSER_TEST_ERROR) {
err(L"semicolon after pipe not detected as error");
}
if (detect_argument_errors(L"foo")) {
err(L"simple argument reported as error");
}