| Home | Libraries | People | FAQ | More

## Library Document Grammar

    doc_info =
            space
        >>  '['
        >>  (   str_p("book")
            |   "article"
            |   "library"
            |   "chapter"
            |   "part"
            )
        >> hard_space
        >>  (  *(anychar_p -
                (ch_p('[') | ']' | eol_p)
                )
            )
        >> *( doc_version
            | doc_id
            | doc_dirname
            | doc_copyright
            | doc_purpose
            | doc_category
            | doc_authors
            | doc_license
            | doc_last_revision
            )
        >> ']' >> +eol_p
        ;

    doc_version =
            space
        >> "[version" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_id =
            space
        >> "[id" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_dirname =
            space
        >> "[dirname" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_copyright =
            space
        >> "[copyright" >> hard_space
        >> +( repeat_p(4)[digit_p]
              >> space
            )
        >> space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_purpose =
            space
        >> "[purpose" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_category =
            space
        >> "[category" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_author =
            space
        >>  '[' >> space
        >>  (*(anychar_p - ','))
        >>  ',' >> space
        >>  (*(anychar_p - ']'))
        >>  ']'
        ;

    doc_authors =
            space
        >> "[authors" >> hard_space
        >> doc_author
        >> *(   ','
                >>  doc_author
            )
        >> ']' >> +eol_p
        ;

    doc_license =
            space
        >> "[license" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_last_revision =
            space
        >> "[last-revision" >> hard_space
        >> (*(anychar_p - ']'))
        >> ']' >> +eol_p
        ;

    doc_source_mode =
        space
        >> "[source-mode" >> hard_space
        >> (
              str_p("c++")
           |  "python"
           )
        >> space >> ']' >> +eol_p
        ;

    comment =
        "[/" >> *(anychar_p - ']') >> ']'
        ;

    space =
        *(space_p | comment)
        ;

    hard_space =
        (eps_p - (alnum_p | '_')) >> space  // must not be followed by
        ;                                   // alpha-numeric or underscore

| Copyright © 2002, 2004 Joel de Guzman, Eric Niebler