Page MenuHomePhabricator

Improve parsing of namespaces
AbandonedPublic

Authored by joshuaspence on Nov 18 2015, 1:34 AM.
Tags
None
Referenced Files
F13992744: D14506.id.diff
Tue, Oct 22, 6:32 PM
F13975249: D14506.diff
Fri, Oct 18, 9:22 AM
F13975217: D14506.id.diff
Fri, Oct 18, 9:15 AM
F13975213: D14506.id35092.diff
Fri, Oct 18, 9:14 AM
F13975202: D14506.id35093.diff
Fri, Oct 18, 9:13 AM
F13965532: D14506.diff
Wed, Oct 16, 2:37 AM
Unknown Object (File)
Sep 13 2024, 11:18 PM
Unknown Object (File)
Sep 13 2024, 5:37 PM
Subscribers

Details

Summary

D14498 wasn't quite correct. Specifically, it incorrectly parsed the following code:

<?php

namespace A;

class A {}
class B {}
Test Plan
xhpast-before.png (404×191 px, 13 KB)
xhpast-after.png (432×204 px, 14 KB)
BeforeAfter }

Diff Detail

Repository
rPHU libphutil
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 8903
Build 10427: Run Core Tests
Build 10426: arc lint + arc unit

Event Timeline

joshuaspence retitled this revision from to Improve parsing of namespaces.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
support/xhpast/parser.y
57

I have no idea if this is okay.

support/xhpast/parser.y
57

The resolution does seem okay, but it's probably better to rewrite the grammar in a way that it's not ambiguous.

This would also make something like this parse badly:

namespace A;

class T { }

namespace B;

class T { }

Here, the second namespace statement would be a child of the first (according to the grammar), even though they're both top-level.

Hmm yeah, you are correct. I am wondering if maybe I should just revert D19948... It would still be possible to implement some sort of getNamespace() method (I think), but it would be significantly harder.