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, Dec 13, 8:51 AM
Unknown Object (File)
Tue, Dec 10, 4:22 AM
Unknown Object (File)
Nov 26 2024, 9:52 PM
Unknown Object (File)
Nov 26 2024, 9:05 PM
Unknown Object (File)
Nov 23 2024, 1:34 AM
Unknown Object (File)
Nov 22 2024, 12:52 AM
Unknown Object (File)
Nov 17 2024, 10:09 PM
Unknown Object (File)
Nov 14 2024, 10:41 AM
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.