From 32cbffe7b89bf4baa5efbafcd90c45e88aa5927d Mon Sep 17 00:00:00 2001 From: Robert Krimen Date: Wed, 17 Oct 2012 01:05:52 -0700 Subject: [PATCH] Avoid backing up when checking for line terminator --- builtin.go | 1 + lexer.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin.go b/builtin.go index bb58768..6b33d10 100644 --- a/builtin.go +++ b/builtin.go @@ -25,6 +25,7 @@ func builtinGlobal_eval(call FunctionCall) Value { runtime := call.runtime runtime.EnterEvalExecutionContext(call) defer runtime.LeaveExecutionContext() + // TODO Catch syntax error and convert to... SyntaxError returnValue := runtime.evaluate(program) if returnValue.isEmpty() { return UndefinedValue() diff --git a/lexer.go b/lexer.go index 84f4ba9..be4c3e3 100644 --- a/lexer.go +++ b/lexer.go @@ -95,8 +95,8 @@ func (self *_lexer) scanEndOfLine(chr rune, consume bool) bool { if consume { self.Next() } - if chr == '\r' && self.Next() != '\n' { - self.Back() // Back because the next character was NOT \n + if chr == '\r' && self.Peek() == '\n' { + self.Next() // Consume \n } self.Line += 1 return true