doesn't that make you wonder?
Fletcher T. Penney
fletcher at fletcherpenney.net
Thu Oct 20 16:59:51 EDT 2011
Perhaps an (admittedly trivial) example will help:
peg-mmd:
Block = BlankLine*
( BlockQuote
| Verbatim
| &{ !extension(EXT_COMPATIBILITY) } DefinitionList
| &{ !extension(EXT_COMPATIBILITY) } Glossary
| Note
| Reference
| HorizontalRule
| HeadingSection
| OrderedList
| BulletList
| HtmlBlock
| StyleBlock
| &{ !extension(EXT_COMPATIBILITY) } Table
| &{ !extension(EXT_COMPATIBILITY) } ImageBlock
| !(Sp? HtmlBlockOpenDiv) Para
| Plain )
Composer:
Block = BlankLine*
( BlockQuote
| Verbatim
| &{ EXT(EXT_MMD) } DefinitionList
| &{ EXT(EXT_MMD) } Glossary
| Note
| Reference
| HorizontalRule
| HeadingSection
| OrderedList
| BulletList
| HtmlBlock
| StyleBlock
| &{ EXT(EXT_MMD) } Table
| &{ EXT(EXT_MMD) } FutureTable
| Para
| Plain )
The PEG is basically the same in defining what to match, but the C commands (inside the {}) are different based on the requirements of the separate programs.
It sounds like you want a single document that can be pasted into any program in any language and work. I suspect such a think doesn't exist.
A PEG in this style is close, in that it defines an algorithm for parsing the input text that can be reused in a variety of contexts, but it will require customization to suit the particular needs of the program.
F-
On Oct 20, 2011, at 3:16 PM, Tao Klerks wrote:
> OK, so just one follow-up, for my understanding if nothing else:
>
> If a PEG is a grammar, and you need to "hook in" to it to get it to do useful things like converting markdown to html, then why would you need to change that PEG (definition/grammar) to USE it to do some other thing, like produce some way to highlight some text in an OSX app? Wouldn't you just change the "hooks"? Did you really have to change the PEG, or did you just change the functions/events/[insert C-appropriate or PEG-appropriate keywords here… "Actions" maybe?] that hook into it? Is the problem that the two are interspersed in the current implementation/file? Sorry, I've only very briefly looked at the "markdown_parser.leg" files in peg-markdown and peg-multimarkdown, haven't yet had the chance to dive in and actually try to understand them - I was assuming the PEG itself is entirely defined between those strange looking "%}" and "%%" delimiters in the file.
>
> Sorry I'm harping on about this, but I'm trying to understand whether/how a completely new program, in a completely different environment, could correctly parse the input (let's forget about generating the output - obviously that portion will depend on the language/environment/framework) WITHOUT writing a new PEG or equivalent and hoping it's defining the same AST. I'm hoping (wishfully maybe) that it can simply be copy/pasted, and then another framework build around it for the "Actions".
>
--
Fletcher T. Penney
fletcher at fletcherpenney.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20111020/9b605bb9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4899 bytes
Desc: not available
Url : <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20111020/9b605bb9/attachment.bin>
More information about the Markdown-Discuss
mailing list