From 3243c9ab738c2609fe1db0c49ddc3596aeea11a0 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 22 Sep 2021 07:30:05 +0300 Subject: [PATCH] fix: escaped newline immediately after a char, resolves #100 (#102) --- corpus/programs.txt | 35 +++++++++++++++++++++++++++++++++++ src/scanner.cc | 1 + 2 files changed, 36 insertions(+) diff --git a/corpus/programs.txt b/corpus/programs.txt index 0e4d437..862631d 100644 --- a/corpus/programs.txt +++ b/corpus/programs.txt @@ -41,6 +41,41 @@ f=g \ (command_name (word)) (word))) +============================= +escaped newline immediately after a char +============================= + +echo a \ + b + +echo a\ + b + +echo a\ + b\ + c + + +----------------------------- + +(program + (command + (command_name + (word)) + (word) + (word)) + (command + (command_name + (word)) + (word) + (word)) + (command + (command_name + (word)) + (word) + (word) + (word))) + ============================= Escaped whitespace ============================ diff --git a/src/scanner.cc b/src/scanner.cc index 1faf40c..32243fc 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -172,6 +172,7 @@ struct Scanner { if (!( lexer->lookahead == 0 || iswspace(lexer->lookahead) || + lexer->lookahead == '\\' || lexer->lookahead == '>' || lexer->lookahead == '<' || lexer->lookahead == ')' ||