Skip to content

Commit cca8034

Browse files
committed
making all assignment-y operators use a colon -- now it's +: -: *: /:, and friends
1 parent 4412f59 commit cca8034

File tree

5 files changed

+950
-919
lines changed

5 files changed

+950
-919
lines changed

‎examples/poignant.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
hit: damage =>
8282
p_up: Math.rand( this.charisma )
8383
if p_up % 9 is 7
84-
this.life += p_up / 4
84+
this.life +: p_up / 4
8585
puts( "[" + this.name + " magick powers up " + p_up + "!]" ).
86-
this.life -= damage
86+
this.life -: damage
8787
if this.life <= 0 then puts( "[" + this.name + " has died.]" )..
8888

8989
# This method takes one turn in a fight.

‎lib/coffee_script/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
</dict>
242242
<dict>
243243
<key>match</key>
244-
<string>!|\$|%|&amp;|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|&lt;=|&gt;=|&lt;&lt;=|&gt;&gt;=|&gt;&gt;&gt;=|&lt;&gt;|&lt;|&gt;|!|&amp;&amp;|\?|\|\||\:|\*=|(?&lt;!\()/=|%=|\+=|\-=|&amp;=|\^=|\b(in|instanceof|new|delete|typeof|and|or|is|isnt|not)\b</string>
244+
<string>!|\$|%|&amp;|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|&lt;=|&gt;=|&lt;&lt;=|&gt;&gt;=|&gt;&gt;&gt;=|&lt;&gt;|&lt;|&gt;|!|&amp;&amp;|\?|\|\||\:|\*:|(?&lt;!\()/=|%:|\+:|\-:|&amp;=|\^=|\b(in|instanceof|new|delete|typeof|and|or|is|isnt|not)\b</string>
245245
<key>name</key>
246246
<string>keyword.operator.cs</string>
247247
</dict>

‎lib/coffee_script/grammar.y

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ prechigh
2626
left '<=' '<' '>' '>='
2727
right '==' '!=' IS ISNT
2828
left '&&' '||' AND OR
29-
right '-=' '+=' '/=' '*='
29+
right '-:' '+:' '/:' '*:' '%:'
3030
right DELETE INSTANCEOF TYPEOF
3131
left "."
3232
right THROW FOR IN WHILE NEW SUPER
@@ -179,10 +179,11 @@ rule
179179
| Expression AND Expression { result = OpNode.new(val[1], val[0], val[2]) }
180180
| Expression OR Expression { result = OpNode.new(val[1], val[0], val[2]) }
181181
182-
| Expression '-=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
183-
| Expression '+=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
184-
| Expression '/=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
185-
| Expression '*=' Expression { result = OpNode.new(val[1], val[0], val[2]) }
182+
| Expression '-:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
183+
| Expression '+:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
184+
| Expression '/:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
185+
| Expression '*:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
186+
| Expression '%:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
186187
| Expression '||:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
187188
| Expression '&&:' Expression { result = OpNode.new(val[1], val[0], val[2]) }
188189

‎lib/coffee_script/nodes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ class OpNode < Node
359359
'is' => '===',
360360
"isnt" => "!==",
361361
'not' => '!',
362+
'+:' => '+=',
363+
'-:' => '-=',
364+
'*:' => '*=',
365+
'/:' => '/=',
366+
'%:' => '%='
362367
}
363368
CONDITIONALS = ['||:', '&&:']
364369
PREFIX_OPERATORS = ['typeof', 'delete']

0 commit comments

Comments
 (0)