Can't parse PHP namespaces #17

Closed
Weltraumschaf opened this Issue Nov 20, 2011 · 15 comments

Comments

Projects
None yet
9 participants
Contributor

Weltraumschaf commented Nov 20, 2011

I tried to call pfff - parse_php ./bin/ebnf with this file https://github.com/Weltraumschaf/ebnf/blob/master/bin/ebnf. It seems that the parse can't habdle PHPs namespace statement:

pfff -parse_php bin/ebnf 
PARSING: bin/ebnf
(ONCE) LEXER:unrecognised symbol, in token rule:\
parse error 
 = File "bin/ebnf", line 21, column 10,  charpos = 796
    around = 'de', whole content = namespace de\weltraumschaf\ebnf;
badcount: 26
bad: #!/usr/bin/env php
bad: <?php
bad: /**
bad:  * This program is free software: you can redistribute it and/or modify
bad:  * it under the terms of the GNU General Public License as published by
bad:  * the Free Software Foundation, either version 3 of the License, or
bad:  * (at your option) any later version.
bad:  *
bad:  * This program is distributed in the hope that it will be useful,
bad:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
bad:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
bad:  * GNU General Public License for more details.
bad:  *
bad:  * You should have received a copy of the GNU General Public License
bad:  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
bad:  *
bad:  * @author Vincent Tscherter <tscherter@karmin.ch>
bad:  * @author Sven Strittmatter <ich@weltraumschaf.de>
bad:  */
bad: 
BAD:!!!!! namespace de\weltraumschaf\ebnf;
bad: 
bad: use \Exception   as Exception;
bad: 
bad: require_once dirname(__DIR__) . "/src/Command.php";
bad: 
bad: exit(Command::main(getopt("s:f:o:hd"), basename(__FILE__)));



---------------------------------------------------------------
NB total files = 1; perfect = 0; =========> 0%
nb good = 0,  nb bad = 27 =========> 0.000000%
Contributor

aryx commented Nov 21, 2011

yes, there is no support for namespace yet ... we don't use them at facebook so I never bothered to implement it.
I'll try to port it this week.

any update here? failing for me as well.

killes commented Aug 24, 2012

I'd also appreciate support for namespaces

sanpii commented Sep 7, 2012

👍

rjha commented Nov 23, 2012

hello @aryx any plans to implement support for namespaces? I believe w/o namespaces support it is useless for anyone using PHP 5.3+

Contributor

aryx commented Nov 27, 2012

we don't use namespaces at facebook so this is unfortunately not on my priority list ... I might implement it once I have a little bit of free time, but lately I've been very busy ...

killes commented Dec 3, 2012

Could you maybe give some pointers to where the code would need to be added?

It's a bit sad that pfff doen't used more often due to this.

Contributor

aryx commented Dec 3, 2012

the parser for PHP is in lang_php/parsing/parser_php.mly and the lexer in lang_php/parsing/lexer_php.mll

killes referenced this issue Feb 21, 2013

Closed

Namespace support #45

mkonecny commented Jul 2, 2013

+1 for namespace support. Otherwise this project will be useless very soon...

Contributor

aryx commented Jul 2, 2013

I have a few commits almost ready to support namespace. Should be available by the end of this week.

mkonecny commented Jul 4, 2013

Really looking forward to this. Almost every new PHP project I've seen in the past year is using namespaces.

+1

FMCorz commented Aug 8, 2013

The Namespace supports seems to work for me, however, not with the following notation:

use Behat\Gherkin\Node\TableNode as TableNode,
    Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;

Resulting in

1 / 1parse error 
 = File "admin/tests/behat/behat_admin.php", line 31, column 45,  charpos = 1179
    around = ',', whole content = use Behat\Gherkin\Node\TableNode as TableNode,
Contributor

aryx commented Aug 14, 2013

The first issue is fixed. See 606ca18

Contributor

aryx commented Aug 14, 2013

The last error is fixed by b3ae7d0

aryx closed this Aug 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment