Author: kjs
Date: Mon Mar 12 16:19:22 2007
New Revision: 17453

Modified:
   trunk/languages/lua/src/ASTGrammar.tg
   trunk/languages/lua/src/lua.pg

Log:
languages/lua
* fix rule names (was error during rename recently)
* fix some tree transform; make function def work

Modified: trunk/languages/lua/src/ASTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/ASTGrammar.tg       (original)
+++ trunk/languages/lua/src/ASTGrammar.tg       Mon Mar 12 16:19:22 2007
@@ -6,7 +6,6 @@
     .local pmc past
     past = new 'PAST::Block'
     past.'init'('node'=>node, 'name'=>'anon')
-
     .local pmc blocknode, blockpast
     blocknode = node['block']
     blockpast = tree.'get'('past', blocknode, 'Lua::Grammar::block')
@@ -18,7 +17,6 @@
     .local pmc past
     past = new 'PAST::Stmts'
     past.'init'('node'=>node)
-
     .local pmc iter
     $P0 = node['statement']
     if null $P0 goto iter_end
@@ -43,12 +41,14 @@
 transform past (Lua::Grammar::statement) :language('PIR') {
     $S0 = node.'find_key'()
     $P0 = node[$S0]
+    #printerr $S0
     $S0 = concat 'Lua::Grammar::', $S0
     .return tree.'get'('past', $P0, $S0)
 }
 
 transform past (Lua::Grammar::last_statement) :language('PIR') {
     .local pmc past, cnode
+
   returnstat:
     cnode = node['return']
     if null cnode goto breakstat
@@ -58,8 +58,6 @@
     past.'init'('node'=>cnode, 'pasttype'=>'pirop', 'pirop'=>'return')
 
     cnode = node['expression_list']
-    #S0 = typeof cnode
-    #printerr S0
     if null cnode goto no_return_values
     exprpast = tree.'get'('past', cnode, 'Lua::Grammar::expression_list')
     #past.'push'(exprpast)
@@ -261,6 +259,7 @@
 }
 
 transform past (Lua::Grammar::function_args) :language('PIR') {
+    #printerr "function_args\n"
     node = node[0]
     $S0 = node.'find_key'()
     $P0 = node[$S0]
@@ -271,7 +270,13 @@
 transform past (Lua::Grammar::function_stat) :language('PIR') {
     .local pmc past
     past = new 'PAST::Op'
-    past.'init'('node'=>node, 'pasttype'=>'assign')
+    past.'init'('node'=>node, 'pasttype'=>'bind')
+
+    .local pmc namenode, namepast
+    namenode = node['functionname']
+    namepast = tree.'get'('past', namenode, 'Lua::Grammar::functionname')
+    past.'push'(namepast)
+
     .local pmc bodynode, bodypast
     bodynode = node['function_body']
     bodypast = tree.'get'('past', bodynode, 'Lua::Grammar::function_body')
@@ -279,6 +284,12 @@
     .return (past)
 }
 
+transform past (Lua::Grammar::functionname) :language('PIR') {
+    $P0 = node['name']
+    $P0 = $P0[0] #hack!
+    .return tree.'get'('past', $P0, 'Lua::Grammar::name')
+}
+
 
 # past (Lua::Grammar::body)
 #
@@ -288,7 +299,7 @@
     .local pmc past
     past = new 'PAST::Block'
     past.'init'('node'=>node)
-
+    #printerr "function body\n"
     # handle parameters
 
     # handle block

Modified: trunk/languages/lua/src/lua.pg
==============================================================================
--- trunk/languages/lua/src/lua.pg      (original)
+++ trunk/languages/lua/src/lua.pg      Mon Mar 12 16:19:22 2007
@@ -31,7 +31,7 @@
 }
 
 rule function_stat {
-  <'function'> <functionname> <body>
+  <'function'> <functionname> <function_body>
 }
 
 rule last_statement {
@@ -163,7 +163,6 @@
   | <':'> <name> <function_args>
   | <function_args>
   ]*
-
 }
 
 rule simple_expression {
@@ -174,7 +173,7 @@
   | <'false'>
   | <'...'>
   | <constructor>
-  | <'function'> <body>
+  | <'function'> <function_body>
   | <primary_expression>
 }
 

Reply via email to