jlp/doc/grammar.rst
Jonathan Bernard 7717439274 Experimenting with a different AST structure and ideas.
Ideas:

* For literate output, format like Docco, tables like

    Doc        | Code
    -----------|------------
    | docblock | codeblock |
    | docblock | codeblock |
    | docblock | codeblock |

* For javadoc output, maybe create a running 'pure source' object containing
  just the code lines. Then run an sup-parser for the language the code is
  written in and build a seperate AST for the code. This code AST then gets
  tagged onto the overall AST and is used in the generation phase for code
  comprehension. Would still need a way to map doc blocks to code blocks. I
  could probably use line numbers. In that case I would need to map the original
  source line from the commented input to the 'pure source' while processing the
  'pure source' and store the original line number in the code AST. That would
  give me a reliable way to lookup the closest code structure to a doc block.
* The code AST would need to made of generic pieces if I want to have
  language-agnostic generator code. What may be better is to allow the language
  parser to create it's code AST however is wants and just have some pluggable
  bit of the generator for each language. Would increase generator code
  complexity though.
2011-08-31 12:09:25 -05:00

30 lines
525 B
ReStructuredText

SourceFile ->
(Block / DocBlock / CodeBlock)+
Block ->
DocBlock CodeBlock
DocBlock ->
(Directive / DocText)+
Directive ->
DocLineStart AT (LongDirective / ShortDirective)
LongDirective ->
("author" / "doc" / "example") RemainingLine DocText?
ShortDirective ->
("org" / "copyright") RemainingLine
DocText ->
(DocLineStart !AT RemainingLine)+
DocLineStart ->
Space* DOC_LINE_START Space?
CodeBlock ->
(!DocLineStart RemainingLine)+
RemainingLine ->
((!EOL)* EOL) / ((!EOL)+ EOI)