mirror of
https://github.com/robertkrimen/otto
synced 2025-10-05 19:19:10 +08:00
Avoid backing up when checking for line terminator
This commit is contained in:
parent
a780c85861
commit
32cbffe7b8
|
@ -25,6 +25,7 @@ func builtinGlobal_eval(call FunctionCall) Value {
|
||||||
runtime := call.runtime
|
runtime := call.runtime
|
||||||
runtime.EnterEvalExecutionContext(call)
|
runtime.EnterEvalExecutionContext(call)
|
||||||
defer runtime.LeaveExecutionContext()
|
defer runtime.LeaveExecutionContext()
|
||||||
|
// TODO Catch syntax error and convert to... SyntaxError
|
||||||
returnValue := runtime.evaluate(program)
|
returnValue := runtime.evaluate(program)
|
||||||
if returnValue.isEmpty() {
|
if returnValue.isEmpty() {
|
||||||
return UndefinedValue()
|
return UndefinedValue()
|
||||||
|
|
4
lexer.go
4
lexer.go
|
@ -95,8 +95,8 @@ func (self *_lexer) scanEndOfLine(chr rune, consume bool) bool {
|
||||||
if consume {
|
if consume {
|
||||||
self.Next()
|
self.Next()
|
||||||
}
|
}
|
||||||
if chr == '\r' && self.Next() != '\n' {
|
if chr == '\r' && self.Peek() == '\n' {
|
||||||
self.Back() // Back because the next character was NOT \n
|
self.Next() // Consume \n
|
||||||
}
|
}
|
||||||
self.Line += 1
|
self.Line += 1
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user