Issue #1547 'use strict' octal escape sequences prohibited

RegExp updated (thanks @michaelficarra)
and hex escapes for colors in Cakefile

tests updated (thanks @satyr)

error message conforms to existing Lexer SyntaxErrors
This commit is contained in:
Gerald Lewis
2012-01-09 12:50:51 -05:00
parent cad108eca0
commit 3a694d7dfa
3 changed files with 20 additions and 9 deletions

View File

@@ -11,10 +11,10 @@ unless process.platform is 'win32'
bold = red = green = reset = ''
if enableColors
bold = '\033[0;1m'
red = '\033[0;31m'
green = '\033[0;32m'
reset = '\033[0m'
bold = '\x1B[0;1m'
red = '\x1B[0;31m'
green = '\x1B[0;32m'
reset = '\x1B[0m'
# Built file header.
header = """

View File

@@ -156,6 +156,8 @@ exports.Lexer = class Lexer
@token 'STRING', @escapeLines string
else
return 0
if octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test string
@error "octal escape sequences #{string} are not allowed"
@line += count string, '\n'
string.length

View File

@@ -31,11 +31,20 @@ test "Octal Integer Literals prohibited", ->
strictOk '`01`'
test "Octal Escape Sequences prohibited", ->
strict 'e = "\\01"'
strict 'e = "\\0777"'
strictOk 'e = "\\09"'
strictOk 'e = "\\07777"'
strictOk "e = `'\033[0;1m'`"
strict '"\\0"'
strict '"\\7"'
strict '"\\000"'
strict '"\\777"'
strict '"_\\0"'
strict '"\\0_"'
strict '"_\\0_"'
strict '"\\08"'
strict '"\\\\\\0"'
strictOk '"\\8"'
strictOk '"\\\\0"'
strictOk '"\\\\\\\\0"'
strictOk "`'\\0'`"
test "duplicate property definitions in `Object Literal`s are prohibited", ->
strict 'o = {x:1,x:1}'