Hirse / brackets-outline-list

Extension for Brackets and Phoenix to display a list of the functions or definitions in the currently opened document.
MIT License
79 stars 30 forks source link

Proposal for #57: PHP parser. #58

Closed yfwz100 closed 8 years ago

yfwz100 commented 8 years ago

I drafted a simple parser using lex. I don't know how to include such dependency so I just created a file in thirdparty folder.

This proposal is for #57 and it seems to fix #42 .

Hirse commented 8 years ago

That sounds great. Thanks for your contribution.

Before I merge, could you add a few comments and explanations to your parser function so I am going to be able to understand and expand this when required?

yfwz100 commented 8 years ago

It's a state machine defined via lex. The main component of the modification is the parse() method. parse() method parse the source text: when it came across keyword(function/class/(/)/{/}), it stores the identity word hierarchically.

I try to find a well-known PHP parser but I couldn't find one implemented in JavaScript.

yfwz100 commented 8 years ago

I added some comments on the code, @Hirse.

Hirse commented 8 years ago

@yfwz100, I have modified your code a little bit and started with adding tests for it. If you feel like helping out some more, more tests are always welcome. :wink:

yfwz100 commented 8 years ago

The code structure is nice :smile: . I am glad to help improve this plugin if I have time. It's really nice to show the meaningful code structure when navigating in a large file.