waypoint -- going to try to clean up regex_token
This commit is contained in:
parent
3291bd2a4a
commit
3396dce2bb
4
Cakefile
4
Cakefile
|
@ -28,8 +28,8 @@ task 'build', 'build the CoffeeScript language from source', ->
|
|||
run ['-c', '-o', 'lib'].concat(files)
|
||||
|
||||
|
||||
task 'build:full', 'checkout /lib, rebuild the source twice, and run the tests', ->
|
||||
exec 'git checkout lib && bin/cake build && bin/cake build && bin/cake test', (err, stdout, stderr) ->
|
||||
task 'build:full', 'rebuild the source twice, and run the tests', ->
|
||||
exec 'bin/cake build && bin/cake build && bin/cake test', (err, stdout, stderr) ->
|
||||
print stdout if stdout
|
||||
print stderr if stderr
|
||||
throw err if err
|
||||
|
|
14
lib/lexer.js
14
lib/lexer.js
|
@ -175,13 +175,13 @@
|
|||
if (!(starts(this.chunk, '/'))) {
|
||||
return false;
|
||||
}
|
||||
if (include(NOT_REGEX, this.tag())) {
|
||||
return false;
|
||||
}
|
||||
if (!((regex = this.balanced_token(['/', '/'])))) {
|
||||
return false;
|
||||
}
|
||||
if (regex.length < 3 || regex.match(/^\/\s+|\n/)) {
|
||||
return false;
|
||||
}
|
||||
if (include(NOT_REGEX, this.tag())) {
|
||||
if (regex.length < 3 || regex.match(/^\/\s+/m)) {
|
||||
return false;
|
||||
}
|
||||
flags = ['i', 'm', 'g', 'y'];
|
||||
|
@ -462,10 +462,10 @@
|
|||
i += 1;
|
||||
}
|
||||
if (levels.length) {
|
||||
if (!(delimited[0][0] === '/')) {
|
||||
throw new Error("SyntaxError: Unterminated " + (levels.pop()[0]) + " starting on line " + (this.line + 1));
|
||||
if (delimited[0][0] === '/') {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
throw new Error("SyntaxError: Unterminated " + (levels.pop()[0]) + " starting on line " + (this.line + 1));
|
||||
}
|
||||
if (i === 0) {
|
||||
return false;
|
||||
|
|
|
@ -127,9 +127,9 @@ exports.Lexer: class Lexer
|
|||
# JavaScript and Ruby.
|
||||
regex_token: ->
|
||||
return false unless starts @chunk, '/'
|
||||
return false unless regex: @balanced_token ['/', '/']
|
||||
return false if regex.length < 3 or regex.match /^\/\s+|\n/
|
||||
return false if include NOT_REGEX, @tag()
|
||||
return false unless regex: @balanced_token ['/', '/']
|
||||
return false if regex.length < 3 or regex.match /^\/\s+/m
|
||||
flags: ['i', 'm', 'g', 'y']
|
||||
while (index: flags.indexOf @chunk.substr regex.length, 1) >= 0
|
||||
regex += flags[index]
|
||||
|
@ -337,8 +337,8 @@ exports.Lexer: class Lexer
|
|||
break unless levels.length
|
||||
i += 1
|
||||
if levels.length
|
||||
throw new Error "SyntaxError: Unterminated ${levels.pop()[0]} starting on line ${@line + 1}" unless delimited[0][0] is '/'
|
||||
return false
|
||||
return false if delimited[0][0] is '/'
|
||||
throw new Error "SyntaxError: Unterminated ${levels.pop()[0]} starting on line ${@line + 1}"
|
||||
return false if i is 0
|
||||
return str.substring(0, i)
|
||||
|
||||
|
|
Loading…
Reference in New Issue