Scriptor / pharen

Lisp to PHP Compiler
http://pharen.org
BSD 3-Clause "New" or "Revised" License
218 stars 31 forks source link

problem with macro generating a method in class #31

Closed francescoagati closed 13 years ago

francescoagati commented 13 years ago

i have try to create a macro that returning a method with public access.

This is the example code in phn

(defmacro public_var (nm value)
  '(access public (local ~nm ~value )))

(defmacro protected_var (nm value)
    '(access protected (local ~nm ~value )))

(defmacro public-fn (nm args &body)
  '(access public (fn ~-nm ~args
     ~@body
     FALSE
     )))

(class-extends Controller_Hello (Controller)

  (public_var template "site")
  (protected_var template2 "site")

  (public-fn action_index ()
    (local (-> this template message) "ciao")
  )

)

and how result i get this php

<?php
require_once('/Users/Francesco/pharen2/pharen/lang.php');
Lexical::$scopes['oop'] = array();
class Controller_Hello extends Controller{
        public $template = "site";
        protected $template2 = "site";
        public function action_index(){
        $this->template->message = $ciao;
        return FALSE;
    }
    ;
}

the error is Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /Users/Francesco/pharen2/pharen/examples/test/tests/oop.php on line 11

when the macro create the function it add a ; to the end of function that can't be put inside the body of class after the function, but in a normal function can be used