parsica-php / parsica

Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
https://parsica-php.github.io/
MIT License
405 stars 18 forks source link

How to parse annotations #11

Closed f3l1x closed 4 years ago

f3l1x commented 4 years ago

Hi! ✋ This library looks great and I would like to take a closer look.

Let's say I would like to practice on annotations.

/**
* @foo Simple line
* @bar Advanced line with !@#$%^&*()
* @baz Multi line
*            with extra line
*/

Could you please point me how to start with it? :-)

Thank you, Felix

mathiasverraes commented 4 years ago

I assume you've seen the docs at https://parsica.verraes.net/ ? Have a look at the code as well, especially the /tests and the json example.

A good heuristic is to start from the inside. Parse a text line, parse a @, parse a keyword, and then combine those. For multilines, you could parse many whitespace * whitespace text line combos. Finally use between() for the outsides.

Does that help?

On Tue, 1 Sep 2020 at 20:06, Milan Felix Šulc notifications@github.com wrote:

Hi! ✋ This library looks great and I would like to take a closer look.

Let's say I would like to practice on annotations.

/**

  • @foo Simple line

  • @bar Advanced line with !@#$%^&*()

  • @baz Multi line

  • with extra line

*/

Could you please point me how to start with it? :-)

Thank you, Felix

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mathiasverraes/parsica/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADXQLHENQT36GNR2TUFQHLSDUZZJANCNFSM4QSAM4PA .

bar commented 4 years ago

@f3l1x OMG what did I do?

f3l1x commented 4 years ago

@mathiasverraes Thank you for pointing me. I was hoping for some more specific code example, but I can learn it from the tests.