Page MenuHomePhabricator

Improve parsing of namespaces
AbandonedPublic

Authored by joshuaspence on Nov 18 2015, 1:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 12, 12:28 PM
Unknown Object (File)
Wed, Apr 10, 9:47 AM
Unknown Object (File)
Fri, Apr 5, 3:02 PM
Unknown Object (File)
Mar 17 2024, 8:40 PM
Unknown Object (File)
Mar 16 2024, 5:57 PM
Unknown Object (File)
Mar 16 2024, 5:36 PM
Unknown Object (File)
Mar 16 2024, 5:32 PM
Unknown Object (File)
Mar 16 2024, 5:20 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.