quit using sp?licing ranges

This commit is contained in:
satyr 2010-10-13 05:47:45 +09:00
parent 67eb966a75
commit 1d4d7e96fa
8 changed files with 17 additions and 19 deletions

View File

@ -37,7 +37,7 @@
if (!exists) {
throw new Error("Cakefile not found in " + (process.cwd()));
}
args = process.argv.slice(2, process.argv.length);
args = process.argv.slice(2);
CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
fileName: 'Cakefile'
});

View File

@ -38,12 +38,11 @@
separator = sources.indexOf('--');
flags = [];
if (separator >= 0) {
flags = sources.slice((separator + 1), sources.length);
sources = sources.slice(0, separator);
flags = sources.splice(separator + 1);
sources.pop();
}
if (opts.run) {
flags = sources.slice(1, sources.length + 1).concat(flags);
sources = [sources[0]];
flags = sources.splice(1).concat(flags);
}
process.ARGV = (process.argv = flags);
return compileScripts();
@ -204,7 +203,7 @@
parseOptions = function() {
var o;
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
o = (opts = optionParser.parse(process.argv.slice(2, process.argv.length)));
o = (opts = optionParser.parse(process.argv.slice(2)));
o.compile || (o.compile = !!o.output);
o.run = !(o.compile || o.print || o.lint);
o.print = !!(o.print || (o.eval || o.stdio && o.compile));

View File

@ -32,7 +32,7 @@
throw new Error("unrecognized option: " + arg);
}
if (!isOption) {
options.arguments = args.slice(i, args.length);
options.arguments = args.slice(i);
break;
}
}

View File

@ -46,7 +46,7 @@ helpers.extend global,
exports.run = ->
path.exists 'Cakefile', (exists) ->
throw new Error("Cakefile not found in #{process.cwd()}") unless exists
args = process.argv[2...process.argv.length]
args = process.argv.slice 2
CoffeeScript.run fs.readFileSync('Cakefile').toString(), fileName: 'Cakefile'
oparse = new optparse.OptionParser switches
return printTasks() unless args.length

View File

@ -62,11 +62,10 @@ exports.run = ->
separator = sources.indexOf '--'
flags = []
if separator >= 0
flags = sources[(separator + 1)...sources.length]
sources = sources[0...separator]
flags = sources.splice separator + 1
sources.pop()
if opts.run
flags = sources[1..sources.length].concat flags
sources = [sources[0]]
flags = sources.splice(1).concat flags
process.ARGV = process.argv = flags
compileScripts()
@ -176,7 +175,7 @@ printTokens = (tokens) ->
# `process.argv` that are specified in `SWITCHES`.
parseOptions = ->
optionParser = new optparse.OptionParser SWITCHES, BANNER
o = opts = optionParser.parse(process.argv[2...process.argv.length])
o = opts = optionParser.parse process.argv.slice 2
o.compile or= !!o.output
o.run = not (o.compile or o.print or o.lint)
o.print = !! (o.print or (o.eval or o.stdio and o.compile))

View File

@ -549,7 +549,7 @@ grammar =
if $2 is '!in'
new Op '!', new In $1, $3
else
new Op '!', new Parens new Op $2[1..], $1, $3
new Op '!', new Parens new Op $2.slice(1), $1, $3
else
if $2 is 'in' then new In $1, $3 else new Op $2, $1, $3
]

View File

@ -47,7 +47,7 @@ exports.Lexer = class Lexer
# At every position, run through this list of attempted matches,
# short-circuiting if any of them succeed. Their order determines precedence:
# `@literalToken` is the fallback catch-all.
while (@chunk = code[@i..])
while @chunk = code.slice @i
@identifierToken() or
@commentToken() or
@whitespaceToken() or
@ -445,9 +445,9 @@ exports.Lexer = class Lexer
i += 1
continue
unless letter is '#' and str.charAt(i+1) is '{' and
(expr = @balancedString str[i+1..], [['{', '}']])
(expr = @balancedString str.slice(i+1), [['{', '}']])
continue
tokens.push ['TO_BE_STRING', str[pi...i]] if pi < i
tokens.push ['TO_BE_STRING', str.slice(pi, i)] if pi < i
inner = expr.slice(1, -1).replace(LEADING_SPACES, '').replace(TRAILING_SPACES, '')
if inner.length
nested = new Lexer().tokenize inner, line: @line, rewrite: off
@ -458,7 +458,7 @@ exports.Lexer = class Lexer
tokens.push ['TOKENS', nested]
i += expr.length
pi = i + 1
tokens.push ['TO_BE_STRING', str[pi..]] if i > pi < str.length
tokens.push ['TO_BE_STRING', str.slice pi] if i > pi < str.length
return tokens if regex
return @token 'STRING', '""' unless tokens.length
tokens.unshift ['', ''] unless tokens[0][0] is 'TO_BE_STRING'

View File

@ -36,7 +36,7 @@ exports.OptionParser = class OptionParser
break
throw new Error "unrecognized option: #{arg}" if isOption and not matchedRule
if not isOption
options.arguments = args[i...args.length]
options.arguments = args.slice i
break
options