diff --git a/examples/code.cs b/examples/code.cs index d976b55d..b7735800 100644 --- a/examples/code.cs +++ b/examples/code.cs @@ -59,7 +59,7 @@ race: => if tired then return sleep(). race(). -# Conditional operators: +# Conditional assignment: good ||= evil wine &&= cheese @@ -143,11 +143,11 @@ Exclaimer.prototype.hello: => super(this.name + "!"). # The child's "hello" c (new Exclaimer('Bob')).hello() # Run it. # Numbers. -a_googol: 1e100 - -hex: 0xff0000 - -negative: -1.0 +a_googol: 1e100 +hex: 0xff0000 +negative: -1.0 +infinity: Infinity +nan: NaN # Deleting. delete secret.identity \ No newline at end of file diff --git a/lib/coffee_script/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences b/lib/coffee_script/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences new file mode 100644 index 00000000..5847e50b --- /dev/null +++ b/lib/coffee_script/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences @@ -0,0 +1,24 @@ + + + + + name + comments + scope + source.cs + settings + + shellVariables + + + name + TM_COMMENT_START + value + # + + + + uuid + 0A92C6F6-4D73-4859-B38C-4CC19CBC191F + + diff --git a/lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage b/lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage new file mode 100644 index 00000000..82c83b73 --- /dev/null +++ b/lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage @@ -0,0 +1,329 @@ + + + + + comment + CoffeeScript Syntax: version 1 + fileTypes + + cs + coffeescript + + name + CoffeeScript + patterns + + + captures + + 1 + + name + entity.name.function.cs + + 2 + + name + keyword.operator.cs + + 3 + + name + variable.parameter.function.cs + + 4 + + name + storage.type.function.cs + + + comment + match stuff like: funcName: => … + match + ([a-zA-Z_?.$]*)\s*(=|:)\s*([\w,\s]*?)\s*(=>) + name + meta.function.cs + + + captures + + 1 + + name + variable.parameter.function.cs + + 2 + + name + storage.type.function.cs + + + comment + match stuff like: a => … + match + ([a-zA-Z_?.$]*)\s*(=>) + name + meta.inline.function.cs + + + captures + + 1 + + name + keyword.operator.new.cs + + 2 + + name + entity.name.type.instance.cs + + + match + (new)\s+(\w+(?:\.\w*)?) + name + meta.class.instance.constructor + + + match + \b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?))\b + name + constant.numeric.cs + + + begin + ' + beginCaptures + + 0 + + name + punctuation.definition.string.begin.cs + + + end + ' + endCaptures + + 0 + + name + punctuation.definition.string.end.cs + + + name + string.quoted.single.cs + patterns + + + match + \\(x\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.) + name + constant.character.escape.cs + + + + + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.begin.cs + + + end + " + endCaptures + + 0 + + name + punctuation.definition.string.end.cs + + + name + string.quoted.double.cs + patterns + + + match + \\(x\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.) + name + constant.character.escape.cs + + + + + begin + ` + beginCaptures + + 0 + + name + punctuation.definition.string.begin.cs + + + end + ` + endCaptures + + 0 + + name + punctuation.definition.string.end.cs + + + name + string.quoted.script.cs + patterns + + + match + \\(x\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.) + name + constant.character.escape.cs + + + + + captures + + 1 + + name + punctuation.definition.comment.cs + + + match + (#).*$\n? + name + comment.line.cs + + + match + \b(break|case|catch|continue|else|finally|for|if|return|switch|then|throw|try|unless|while)\b + name + keyword.control.cs + + + match + \btrue\b + name + constant.language.boolean.true.cs + + + match + \bfalse\b + name + constant.language.boolean.false.cs + + + match + \bnull\b + name + constant.language.null.cs + + + match + \b(super|this)\b + name + variable.language.cs + + + match + \b(debugger)\b + name + keyword.other.cs + + + match + !|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\?|\|\||\:|\*=|(?<!\()/=|%=|\+=|\-=|&=|\^=|\b(in|instanceof|new|delete|typeof|and|or|is|aint|not)\b + name + keyword.operator.cs + + + match + \b(Infinity|NaN|undefined)\b + name + constant.language.cs + + + begin + (?<=[=(:]|^|return)\s*(/)(?![/*+{}?]) + beginCaptures + + 1 + + name + punctuation.definition.string.begin.cs + + + end + (/)[igm]* + endCaptures + + 1 + + name + punctuation.definition.string.end.cs + + + name + string.regexp.cs + patterns + + + match + \\. + name + constant.character.escape.cs + + + + + match + \; + name + punctuation.terminator.statement.cs + + + match + ,[ |\t]* + name + meta.delimiter.object.comma.cs + + + match + \. + name + meta.delimiter.method.period.cs + + + match + \{|\} + name + meta.brace.curly.cs + + + match + \(|\) + name + meta.brace.round.cs + + + match + \[|\] + name + meta.brace.square.cs + + + scopeName + source.cs + uuid + 5B520980-A7D5-4E10-8582-1A4C889A8DE5 + + diff --git a/lib/coffee_script/CoffeeScript.tmbundle/info.plist b/lib/coffee_script/CoffeeScript.tmbundle/info.plist new file mode 100644 index 00000000..7a63123f --- /dev/null +++ b/lib/coffee_script/CoffeeScript.tmbundle/info.plist @@ -0,0 +1,10 @@ + + + + + name + CoffeeScript + uuid + A46E4382-F1AC-405B-8F22-65FF470F34D7 + + diff --git a/lib/coffee_script/command_line.rb b/lib/coffee_script/command_line.rb index 99b4f321..a9d479cc 100644 --- a/lib/coffee_script/command_line.rb +++ b/lib/coffee_script/command_line.rb @@ -98,25 +98,34 @@ Usage: File.join(dir, filename) end + def install_bundle + bundle_dir = File.expand_path('~/Library/Application Support/TextMate/Bundles/') + FileUtils.cp_r(File.dirname(__FILE__) + '/CoffeeScript.tmbundle', bundle_dir) + end + def parse_options @options = {} @option_parser = OptionParser.new do |opts| - opts.on('-o', '--output [DIR]', 'set the directory for compiled javascript') do |d| + opts.on('-o', '--output [DIR]', 'set the directory for compiled JavaScript') do |d| @options[:output] = d FileUtils.mkdir_p(d) unless File.exists?(d) end opts.on('-w', '--watch', 'watch scripts for changes, and recompile') do |w| @options[:watch] = true end - opts.on('-p', '--print', 'print the compiled javascript to stdout') do |d| + opts.on('-p', '--print', 'print the compiled JavaScript to stdout') do |d| @options[:print] = true end - opts.on('-l', '--lint', 'pipe the compiled javascript through JSLint') do |l| + opts.on('-l', '--lint', 'pipe the compiled JavaScript through JSLint') do |l| @options[:lint] = true end opts.on('-t', '--tokens', 'print the tokens that the lexer produces') do |t| @options[:tokens] = true end + opts.on_tail('--install-bundle', 'install the CoffeeScript TextMate bundle') do |i| + install_bundle + exit + end opts.on_tail('-v', '--version', 'display coffee-script version') do puts "coffee-script version #{CoffeeScript::VERSION}" exit