xsawyerx / guacamole

Guacamole is a parser toolkit for Standard Perl. It provides fully static BNF-based parsing capability to a reasonable subset of Perl.
https://metacpan.org/pod/Guacamole
20 stars 8 forks source link

Syntax: inline POD #20

Closed xsawyerx closed 4 years ago

xsawyerx commented 4 years ago

Inline POD presents a unique problem:

We need to match the beginning of line specifically, then we need to gobble everything, including all spacing until we match the =cut.

Marpa's BFN regex supports ^ so we might be able to get away with it with ^[#] and ^=cut$ but I'm not sure if that's for beginning/end of lines.

Hm, I wonder what it would look like if you tried to write a BNF for Pod from this.

-- perlpodscpec

xsawyerx commented 4 years ago

We should look at how C-style comments are done in Marpa.

xsawyerx commented 4 years ago

https://gist.github.com/jeffreykegler/5011021#file-show_comments-pl-L48

xsawyerx commented 4 years ago

Following thoughts on #21, I decided that while perl, the interpreter, understands inline POD syntax, it's not part of the language specification. It has its own specification as its own documentation language.

This means that we could approach this in two ways:

  1. We could parse it in Marpa as just ^= until ^=cut$ and give that to the user to deal with
    • The user would probably then pass this by a POD parser, many of which exist
  2. We could remove all POD prior to parsing this in Marpa as an input cleanup phase
    • We would need to keep the line numbers, so we'll replace ever POD line with an empty line
    • We will need to replace every character with a space character so the position reporting of Marpa will be correct but the parsing will not break

@gonzus Your thoughts on this will be appreciated.

gonzus commented 4 years ago

My comments in https://github.com/xsawyerx/reimagined-guacamole/issues/21#issuecomment-643982243 apply here, probably even more so. If you want the parser to also parse POD, then this is exactly the problem I mentioned before: how do you parse two different syntaxes with the same parser?

xsawyerx commented 4 years ago

Agreed.