Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added a shorthand syntax for function one liner

  • Loading branch information...
commit 8718cb42bcae6a62128ccf53e835c6723e185337 1 parent d26c13e
thoefer2 thoefer2 authored

Showing 3 changed files with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 0  Ex1Test.g
  2. +4 0 Ex1Walker.g
  3. +4 2 index.html
2  Ex1Test.g
@@ -8,6 +8,7 @@ options {
8 8 tokens {
9 9 FN_CALL;
10 10 FN_DEF;
  11 + FN_DEF_INLINE;
11 12 EX;
12 13 }
13 14
@@ -20,6 +21,7 @@ prog: exprStmt* EOF -> exprStmt*
20 21
21 22 exprStmt: ID ':' expr ';' -> ^(':' ID expr)
22 23 | name=ID ':' '{' (arg+=ID)? (',' arg+=ID)* '=>' body+=exprStmt* '}' ';' -> ^(FN_DEF $name $arg* $body*)
  24 + | name=ID ':' '=>' inline=exprStmt -> ^(FN_DEF_INLINE $name $inline)
23 25 | expr ';' -> ^(EX expr)
24 26 ;
25 27
4 Ex1Walker.g
@@ -410,6 +410,10 @@ exprStmt returns [node]
410 410 this.popScope();
411 411 }
412 412 | ^(EX expr) { $node = $expr.node; }
  413 + | ^(FN_DEF_INLINE name=ID {var node = new L.FunctionDef(this.currentScope, $name.text, this.pushScope()); } (e=exprStmt { node.body.push($e.node); }) ) {
  414 + $node = node;
  415 + this.popScope();
  416 + }
413 417 ;
414 418
415 419 expr returns [node]
6 index.html
@@ -29,8 +29,10 @@
29 29 };
30 30 fnResult: someFn(77, 9);
31 31 assert(fnResult(10) == 200);
32   -
33   -
  32 +
  33 + voidFn: => puts(777);
  34 + voidFn();
  35 +
34 36 </script>
35 37
36 38

0 comments on commit 8718cb4

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