btwael / mammouth

Unfancy PHP
http://mammouth.boutglay.com
MIT License
214 stars 22 forks source link

Unable to invoke methods on an object instance #32

Closed pwhelan closed 10 years ago

pwhelan commented 10 years ago

I was unable to invoke methods on an instance of a class.

Example:

class Foo ->
    public Bar ->
        echo "Foobar"

bar = new Foo
bar.Bar

I would expect bar.Bar to execute the Bar method of the Foo class. I was unable to find out how to do this in the documentation.

btwael commented 10 years ago

@pwhelan, try this: http://mammouth.wamalaka.com/#try:{{%0Aclass%20Foo%20-%3E%0A%20public%20Bar%20-%3E%0A%20%20echo%20%22Foobar%22%0Abar%20%3D%20new%20Foo%0Abar.Bar%28%29%0A}}

pwhelan commented 10 years ago

That is more or less what I was doing before. This code works fine on the website with try but not with the compiled version I have.

Code:

{{

require 'goutte.phar'

client = new Goutte\Client

crawler = client.request('GET', 'http://example.com')
crawler.filter('button.select')

}}

Generated code (website):

<?php 
require 'goutte.phar';
$client = new Goutte\Client();
$crawler = $client->request('GET', 'http://example.com');
$crawler->filter('button.select');
?>

Local version:

<?php 
require 'goutte.phar';
$client = new Goutte\Client();
$crawler = ('GET', 'http://example.com');
('button.select');
?>
pwhelan commented 10 years ago

This seems to be an between master and v0.2.3 (v0.2.3 works perfectly).

pwhelan commented 10 years ago

The error must be somewhere in parser.pegjs in here: https://github.com/btwael/mammouth/compare/v0.2.3...master

btwael commented 10 years ago

@pwhelan, please use npm version, it works perfectly. we are working in a new better version.

pwhelan commented 10 years ago

I checked out the v0.2.3 tag and everything works fine.

btwael commented 10 years ago

A new mammouth version http://mammouth.wamalaka.com/