mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 01:07:55 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4bc24817d | ||
|
|
9eeac9b272 | ||
|
|
f859eb6cec | ||
|
|
b29afc2c09 |
@@ -1,12 +1,17 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'coffee-script'
|
||||
s.version = '0.1.0' # Keep version in sync with coffee-script.rb
|
||||
s.version = '0.1.1' # Keep version in sync with coffee-script.rb
|
||||
s.date = '2009-12-24'
|
||||
|
||||
s.homepage = "http://jashkenas.github.com/coffee-script/"
|
||||
s.summary = "The CoffeeScript Compiler"
|
||||
s.description = <<-EOS
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
CoffeeScript is a little language that compiles into JavaScript. Think
|
||||
of it as JavaScript's less ostentatious kid brother -- the same genes,
|
||||
roughly the same height, but a different sense of style. Apart from a
|
||||
handful of bonus goodies, statements in CoffeeScript correspond
|
||||
one-to-one with their equivalent in JavaScript, it's just another
|
||||
way of saying it.
|
||||
EOS
|
||||
|
||||
s.authors = ['Jeremy Ashkenas']
|
||||
|
||||
@@ -405,6 +405,11 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||
Integration with Processing.js's JavaScript API (this would depend on
|
||||
having a JavaScript version of the compiler).
|
||||
</li>
|
||||
<li>
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
string manipulation. Techniques for cleaning this up across the board
|
||||
would be appreciated.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="change_log">Change Log</h2>
|
||||
|
||||
@@ -784,6 +784,11 @@ world...";
|
||||
Integration with Processing.js's JavaScript API (this would depend on
|
||||
having a JavaScript version of the compiler).
|
||||
</li>
|
||||
<li>
|
||||
A lot of the code generation in <tt>nodes.rb</tt> gets into messy
|
||||
string manipulation. Techniques for cleaning this up across the board
|
||||
would be appreciated.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="change_log">Change Log</h2>
|
||||
|
||||
@@ -9,7 +9,7 @@ require "coffee_script/parse_error"
|
||||
# Namespace for all CoffeeScript internal classes.
|
||||
module CoffeeScript
|
||||
|
||||
VERSION = '0.1.0' # Keep in sync with the gemspec.
|
||||
VERSION = '0.1.1' # Keep in sync with the gemspec.
|
||||
|
||||
# Compile a script (String or IO) to JavaScript.
|
||||
def self.compile(script)
|
||||
|
||||
@@ -10,8 +10,8 @@ token TRY CATCH FINALLY THROW
|
||||
token BREAK CONTINUE
|
||||
token FOR IN WHILE
|
||||
token SWITCH WHEN
|
||||
token DELETE INSTANCEOF TYPEOF
|
||||
token SUPER
|
||||
token DELETE
|
||||
token NEWLINE
|
||||
token COMMENT
|
||||
token JS
|
||||
@@ -27,7 +27,7 @@ prechigh
|
||||
right '==' '!=' IS AINT
|
||||
left '&&' '||' AND OR
|
||||
right '-=' '+=' '/=' '*='
|
||||
right DELETE
|
||||
right DELETE INSTANCEOF TYPEOF
|
||||
left "."
|
||||
right THROW FOR IN WHILE NEW
|
||||
left UNLESS IF ELSE
|
||||
@@ -185,6 +185,8 @@ rule
|
||||
| Expression '&&:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
|
||||
| DELETE Expression { result = OpNode.new(val[0], val[1]) }
|
||||
| TYPEOF Expression { result = OpNode.new(val[0], val[1]) }
|
||||
| Expression INSTANCEOF Expression { result = OpNode.new(val[1], val[0], val[2]) }
|
||||
;
|
||||
|
||||
# Function definition.
|
||||
|
||||
@@ -15,7 +15,7 @@ module CoffeeScript
|
||||
"for", "in", "while",
|
||||
"switch", "when",
|
||||
"super",
|
||||
"delete"]
|
||||
"delete", "instanceof", "typeof"]
|
||||
|
||||
# Token matching regexes.
|
||||
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
||||
|
||||
@@ -342,7 +342,8 @@ module CoffeeScript
|
||||
"aint" => "!==",
|
||||
'not' => '!',
|
||||
}
|
||||
CONDITIONALS = ['||:', '&&:']
|
||||
CONDITIONALS = ['||:', '&&:']
|
||||
PREFIX_OPERATORS = ['typeof', 'delete']
|
||||
|
||||
attr_reader :operator, :first, :second
|
||||
|
||||
@@ -369,7 +370,7 @@ module CoffeeScript
|
||||
end
|
||||
|
||||
def compile_unary(o)
|
||||
space = @operator.to_s == 'delete' ? ' ' : ''
|
||||
space = PREFIX_OPERATORS.include?(@operator.to_s) ? ' ' : ''
|
||||
parts = [@operator.to_s, space, @first.compile(o)]
|
||||
parts.reverse! if @flip
|
||||
parts.join('')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10
test/fixtures/execution/keyword_operators.cs
vendored
Normal file
10
test/fixtures/execution/keyword_operators.cs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
a: 5
|
||||
atype: typeof a
|
||||
|
||||
b: "hello"
|
||||
btype: typeof b
|
||||
|
||||
Klass: => .
|
||||
k: new Klass()
|
||||
|
||||
print(atype is 'number' and btype is 'string' and k instanceof Klass)
|
||||
10
test/fixtures/execution/keyword_operators.js
vendored
Normal file
10
test/fixtures/execution/keyword_operators.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
(function(){
|
||||
var a = 5;
|
||||
var atype = typeof a;
|
||||
var b = "hello";
|
||||
var btype = typeof b;
|
||||
var Klass = function() {
|
||||
};
|
||||
var k = new Klass();
|
||||
print(atype === 'number' && btype === 'string' && k instanceof Klass);
|
||||
})();
|
||||
Reference in New Issue
Block a user