Skip to content

Commit

Permalink
Fix #3: Detect CR Line Endings (\r) as line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed Aug 12, 2016
1 parent 3db9f0f commit a578923
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *Scanner) scanIdent() (tok Token, lit string) {
}

func isWhitespace(ch rune) bool {
return ch == ' ' || ch == '\t' || ch == '\n'
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'
}

func isLetter(ch rune) bool {
Expand Down
1 change: 1 addition & 0 deletions lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestScanner_Scan(t *testing.T) {
{s: ` `, tok: vdf.WS, lit: " "},
{s: "\t", tok: vdf.WS, lit: "\t"},
{s: "\n", tok: vdf.WS, lit: "\n"},
{s: "\r", tok: vdf.WS, lit: "\r"},

// Misc characters
{s: `{`, tok: vdf.CurlyBraceOpen, lit: "{"},
Expand Down

0 comments on commit a578923

Please sign in to comment.