Skip to content

Commit

Permalink
gnu: Add coffee-script.
Browse files Browse the repository at this point in the history
* gnu/packages/coffee-script.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

coffeescript crap

To coffee-script 0.6 :D (boot10)

We be stuck <0.7.0

Bootstrapped to 22

formatting changes

Added up to 25

busy with backporting # support

Bootstrapv28

Added CS bootstrap to version 1.0.0

prettify and final fixes
  • Loading branch information
jellelicht committed Aug 23, 2016
1 parent e782f05 commit 8dbfab2
Show file tree
Hide file tree
Showing 17 changed files with 4,984 additions and 0 deletions.
1 change: 1 addition & 0 deletions gnu/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/ci.scm \
%D%/packages/cmake.scm \
%D%/packages/code.scm \
%D%/packages/coffee-script.scm \
%D%/packages/commencement.scm \
%D%/packages/compression.scm \
%D%/packages/conkeror.scm \
Expand Down
843 changes: 843 additions & 0 deletions gnu/packages/coffee-script.scm

Large diffs are not rendered by default.

700 changes: 700 additions & 0 deletions gnu/packages/patches/coffeescript-backport-default-arguments.patch

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions gnu/packages/patches/coffeescript-backport-destructuring.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
From 1ac2f75a02834d212568b3ae27826c60201fdf85 Mon Sep 17 00:00:00 2001
From: Jelle Licht <[email protected]>
Date: Sun, 21 Aug 2016 06:10:15 +0200
Subject: [PATCH] [BACKPORT] bad dynakeys: can now do destructuring assignments
To: [email protected]

---
src/nodes.coffee | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/nodes.coffee b/src/nodes.coffee
index 5deab74..be26ffa 100644
--- a/src/nodes.coffee
+++ b/src/nodes.coffee
@@ -786,12 +786,16 @@ exports.Assign = class Assign extends Base
if obj instanceof Assign
{variable: {base: idx}, value: obj} = obj
else
- idx = if isObject
- if obj.tags.this then obj.properties[0].name else obj
+ if obj.base instanceof Parens
+ [obj, idx] = @matchParens o, obj
else
- new Literal 0
- accessClass = if IDENTIFIER.test idx.value then Accessor else Index
- (value = Value.wrap value).properties.push new accessClass idx
+ idx = if isObject
+ if obj.tags.this then obj.properties[0].name else obj
+ else
+ new Literal 0
+ acc = IDENTIFIER.test idx.unwrap().value or 0
+ value = Value.wrap value
+ value.properties.push new (if acc then Accessor else Index) idx
return new Assign(obj, value).compile o
valVar = value.compile o, LEVEL_LIST
assigns = []
@@ -808,17 +812,23 @@ exports.Assign = class Assign extends Base
{variable: {base: idx}, value: obj} = obj
else
# A shorthand `{a, b, @c} = val` pattern-match.
- idx = if obj.tags.this then obj.properties[0].name else obj
+ if obj.base instanceof Parens
+ [obj, idx] = @matchParens o, obj
+ else
+ idx = if obj.tags.this then obj.properties[0].name else obj
unless obj instanceof Value or obj instanceof Splat
- throw SyntaxError 'pattern matching must use only identifiers on the left-hand side.'
- accessClass = if isObject and IDENTIFIER.test(idx.value) then Accessor else Index
+ throw SyntaxError \
+ 'destructuring assignment must use only identifiers on the left-hand side.'
if not splat and obj instanceof Splat
val = new Literal obj.compileValue o, valVar, i, olength - i - 1
splat = true
else
if typeof idx isnt 'object'
idx = new Literal(if splat then "#{valVar}.length - #{ olength - idx }" else idx)
- val = new Value new Literal(valVar), [new accessClass idx]
+ acc = no
+ else
+ acc = isObject and IDENTIFIER.test idx.unwrap().value or 0
+ val = new Value new Literal(valVar), [new (if acc then Accessor else Index) idx]
assigns.push new Assign(obj, val).compile o, LEVEL_LIST
assigns.push valVar unless top
code = assigns.join ', '
@@ -831,6 +841,13 @@ exports.Assign = class Assign extends Base
[left, rite] = @variable.cacheReference o
return new Op(@context.slice(0, -1), left, new Assign(rite, @value)).compile o

+ matchParens: (o, obj) ->
+ until obj is obj = obj.unwrap() then
+ unless obj instanceof Literal or obj instanceof Value
+ throw SyntaxError 'nonreference in destructuring assignment shorthand.'
+ [obj, idx] = Value.wrap(obj).cacheReference o
+
+
#### Code

# A function definition. This is the only node that creates a new Scope.
@@ -1067,8 +1084,6 @@ exports.Op = class Op extends Base

isUnary: -> not @second

- isComplex: -> @operator isnt '!' or @first.isComplex()
-
# Am I capable of
# [Python-style comparison chaining](http://docs.python.org/reference/expressions.html#notin)?
isChainable: -> @operator in ['<', '>', '>=', '<=', '===', '!==']
--
2.9.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From eee6747f9ddf521bff6496da5c3e39c17c71c76a Mon Sep 17 00:00:00 2001
From: Jelle Licht <[email protected]>
Date: Sat, 20 Aug 2016 18:55:44 +0200
Subject: [PATCH] [BACKPORT] waypoint commit with both # and $ performing
interpolation. Issue 544
To: [email protected]

---
src/lexer.coffee | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lexer.coffee b/src/lexer.coffee
index 6595640..d384830 100644
--- a/src/lexer.coffee
+++ b/src/lexer.coffee
@@ -118,7 +118,7 @@ exports.Lexer = class Lexer
stringToken: ->
return false unless starts(@chunk, '"') or starts(@chunk, "'")
return false unless string =
- @balancedToken(['"', '"'], ['${', '}']) or
+ @balancedToken(['"', '"'], ['${', '}'], ['#{', '}']) or
@balancedToken ["'", "'"]
@interpolateString string.replace STRING_NEWLINES, " \\\n"
@line += count string, "\n"
@@ -400,7 +400,7 @@ exports.Lexer = class Lexer
tokens.push ['IDENTIFIER', interp]
i += group.length - 1
pi = i + 1
- else if (expr = @balancedString str.substring(i), [['${', '}']])
+ else if (expr = @balancedString str.substring(i), [['${', '}'], ['#{', '}']])
tokens.push ['STRING', "$quote${ str.substring(pi, i) }$quote"] if pi < i
inner = expr.substring(2, expr.length - 1)
if inner.length
@@ -509,7 +509,7 @@ JS_FORBIDDEN = JS_KEYWORDS.concat RESERVED
IDENTIFIER = /^([a-zA-Z\$_](\w|\$)*)/
NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-]?[0-9]+)?)))\b/i
HEREDOC = /^("{6}|'{6}|"{3}\n?([\s\S]*?)\n?([ \t]*)"{3}|'{3}\n?([\s\S]*?)\n?([ \t]*)'{3})/
-INTERPOLATION = /^\$([a-zA-Z_@]\w*(\.\w+)*)/
+INTERPOLATION = /^[$#]([a-zA-Z_@]\w*(\.\w+)*)/
OPERATOR = /^(-[\-=>]?|\+[+=]?|[*&|\/%=<>:!?]+)([ \t]*)/
WHITESPACE = /^([ \t]+)/
COMMENT = /^(\s*#{3}(?!#)[ \t]*\n+([\s\S]*?)[ \t]*\n+[ \t]*#{3}|(\s*#(?!##[^#])[^\n]*)+)/
--
2.9.3

Loading

0 comments on commit 8dbfab2

Please sign in to comment.