[02] [Parse] lexer refactor unify skipToEndOfLine - omochi/swift GitHub Wiki
Lexer
には機能のよく似た skipToEndOfLine
と skipUpToEndOfLine
がある。
これを単一化する。
挙動の違いはヒットした改行の手前で止まるか後ろで止まるかなので、
これを EatNewline
引数で制御できるようにする。
また、 lexTrivia
は この改行に関する挙動のため、
skipSlashSlashComment
と skipHashbang
を再利用していない。
そこで EatNewline
引数をこれらの関数にも適用して、
lexTrivia
から共通利用する。
--
Lexer
has two similar ones which are skipToEndOfLine
and skipUpToEndOfLine
.
This PR unify them.
The only difference in them are that
it will stop at which before or after of newline hit,
so add EatNewline
parameter to function to control this.
And because of behavior about newline reason,
lexTrivia
does not reuse skipSlashSlashComment
and skipHashbang
.
So add EatNewline
to them, use in common from lexTrivia