Skip to content
Browse files

a first crack at adding await into the grammar

  • Loading branch information...
1 parent 5c93811 commit 57c164c3375ae7e9bd1a7d417240bc8baa2ad80e @maxtaco committed Nov 14, 2011
Showing with 22 additions and 1 deletion.
  1. +5 −0 src/grammar.coffee
  2. +1 −1 src/lexer.coffee
  3. +16 −0 src/nodes.coffee
View
5 src/grammar.coffee
@@ -79,6 +79,11 @@ grammar =
o 'Return'
o 'Comment'
o 'STATEMENT', -> new Literal $1
+ o 'Await'
+ ]
+
+ Await: [
+ o 'AWAIT Block', -> new Await $2
]
# All the different types of expressions in our language. The basic unit of
View
2 src/lexer.coffee
@@ -557,7 +557,7 @@ JS_KEYWORDS = [
]
# CoffeeScript-only keywords.
-COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when']
+COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when', 'await' ]
COFFEE_ALIAS_MAP =
and : '&&'
View
16 src/nodes.coffee
@@ -1567,6 +1567,22 @@ exports.In = class In extends Base
toString: (idt) ->
super idt, @constructor.name + if @negated then '!' else ''
+#### Await
+
+exports.Await = class Await extends Base
+ constructor : (body) ->
+ @body = body
+
+ children: ['body']
+
+ isStatement: YES
+
+ compileNode: (o) ->
+ body = @body.compile o, LEVEL_TOP
+ """(function () { /* await translation */
+ #{body}
+ })();"""
+
#### Try
# A classic *try/catch/finally* block.

0 comments on commit 57c164c

Please sign in to comment.
Something went wrong with that request. Please try again.