Re: Creating an experimental syntax
| From: | Rune Kaagaard | Date: | Mon, 12 Oct 2009 11:51:10 +0000 |
| Subject: | Re: Creating an experimental syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45740@lists.php.net to get a copy of this message | ||
Dear Internals
Ok... So i figured out that the way to make a scala style multi line
function declaration was simply to do this:
### zend_language_parser.y ###
unticked_function_declaration_statement:
function is_reference T_STRING {
zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL
TSRMLS_CC); }
'(' parameter_list ')' '=' '{'
inner_statement_list '}' {
zend_do_end_function_declaration(&$1 TSRMLS_CC); }
;
### PHP ###
def new_function() = {
echo "It works!\n";
}
But I have been stuck the last couple of hours trying to make support
for a one line function declaration without the '{}'. Example:
def double($x) = return 2 * $x;
I cant seem to find out what token to use for a new line? Any thoughts?
Thx a lot from confused guy
Rune Kaagaard
Denmark