mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
beginnings of a build script
This commit is contained in:
parent
fa63288f52
commit
2f389f1d51
6 changed files with 47 additions and 20 deletions
7
README
7
README
|
@ -43,4 +43,9 @@
|
|||
is in the works. Check out /src for the details. To try it out, use
|
||||
bin/node_coffee. To have CoffeeScript recompile itself, run:
|
||||
|
||||
bin/node_coffee -o lib/coffee_script src/*.coffee
|
||||
build compiler
|
||||
|
||||
To rebuild the Jison parser (takes about 30 seconds), run:
|
||||
|
||||
build grammar
|
||||
|
24
build.coffee
Executable file
24
build.coffee
Executable file
|
@ -0,0 +1,24 @@
|
|||
# Custom build scripts, replacing the Rakefile. To invoke (for example):
|
||||
#
|
||||
# bin/node_coffee -r build.coffee -- parser
|
||||
|
||||
fs: require 'fs'
|
||||
|
||||
# Print the usage message for the build scripts.
|
||||
usage: ->
|
||||
puts "build.coffee usage goes here..."
|
||||
|
||||
# Rebuild the Jison parser from the compiled lib/grammar.js file.
|
||||
build_parser: ->
|
||||
parser: require('grammar').parser
|
||||
js: parser.generate()
|
||||
parser_path: 'lib/coffee_script/parser.js'
|
||||
fs.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback (fd) ->
|
||||
fs.write(fd, js)
|
||||
|
||||
switch process.ARGV[0]
|
||||
when undefined then usage()
|
||||
when 'compiler' then build_compiler()
|
||||
when 'parser' then build_parser()
|
||||
when 'highlighter' then build_highlighter()
|
||||
when 'underscore' then build_underscore()
|
|
@ -15,6 +15,7 @@
|
|||
option_parser = null;
|
||||
// The CommandLine handles all of the functionality of the `coffee` utility.
|
||||
exports.run = function run() {
|
||||
var flags, separator;
|
||||
parse_options();
|
||||
if (options.interactive) {
|
||||
return require('./repl');
|
||||
|
@ -25,6 +26,13 @@
|
|||
if (!(sources.length)) {
|
||||
usage();
|
||||
}
|
||||
separator = sources.indexOf('--');
|
||||
flags = [];
|
||||
if (separator >= 0) {
|
||||
flags = sources.slice((separator + 1), sources.length);
|
||||
sources = sources.slice(0, separator);
|
||||
}
|
||||
process.ARGV = flags;
|
||||
compile_scripts();
|
||||
return this;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(function(){
|
||||
var Parser, _1, _2, _3, _4, _5, _6, bnf, fs, grammar, js, name, non_terminal, o, operators, option, parser, parser_path, part, tokens, unwrap;
|
||||
var Parser, _1, _2, _3, _4, _5, _6, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
Parser = require('jison').Parser;
|
||||
// DSL ===================================================================
|
||||
|
@ -544,7 +544,7 @@
|
|||
}).call(this);
|
||||
}
|
||||
tokens = tokens.join(" ");
|
||||
parser = new Parser({
|
||||
exports.parser = new Parser({
|
||||
tokens: tokens,
|
||||
bnf: bnf,
|
||||
operators: operators.reverse(),
|
||||
|
@ -552,12 +552,4 @@
|
|||
}, {
|
||||
debug: false
|
||||
});
|
||||
js = parser.generate();
|
||||
// Save the parser to a file.
|
||||
// puts parser.generate()
|
||||
fs = require('fs');
|
||||
parser_path = 'lib/coffee_script/parser.js';
|
||||
fs.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback(function(fd) {
|
||||
return fs.write(fd, js);
|
||||
});
|
||||
})();
|
|
@ -36,6 +36,12 @@ exports.run: ->
|
|||
return require './repl' if options.interactive
|
||||
return puts coffee.compile sources[0] if options.eval
|
||||
usage() unless sources.length
|
||||
separator: sources.indexOf '--'
|
||||
flags: []
|
||||
if separator >= 0
|
||||
flags: sources[(separator + 1)...sources.length]
|
||||
sources: sources[0...separator]
|
||||
process.ARGV = flags
|
||||
compile_scripts()
|
||||
this
|
||||
|
||||
|
|
|
@ -450,12 +450,4 @@ for name, non_terminal of grammar
|
|||
option[1] = "return " + option[1]
|
||||
option
|
||||
tokens: tokens.join(" ")
|
||||
parser: new Parser({tokens: tokens, bnf: bnf, operators: operators.reverse(), startSymbol: 'Root'}, {debug: false})
|
||||
js: parser.generate()
|
||||
|
||||
# Save the parser to a file.
|
||||
# puts parser.generate()
|
||||
fs: require 'fs'
|
||||
parser_path: 'lib/coffee_script/parser.js'
|
||||
fs.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback (fd) ->
|
||||
fs.write(fd, js)
|
||||
exports.parser: new Parser({tokens: tokens, bnf: bnf, operators: operators.reverse(), startSymbol: 'Root'}, {debug: false})
|
||||
|
|
Loading…
Reference in a new issue