123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194(* This module contains the token type, emitted by the lexer, and consumed by
the comment syntax parser. It also contains two functions that format tokens
for error messages. *)typesection_heading=[`Begin_section_headingofint*stringoption]typestyle=[`Bold|`Italic|`Emphasis|`Superscript|`Subscript]typeparagraph_style=[`Left|`Center|`Right]typetag=[`Tagof[`Authorofstring|`Deprecated|`Paramofstring|`Raiseofstring|`Return|`Seeof[`Url|`File|`Document]*string|`Sinceofstring|`Beforeofstring|`Versionofstring|`Canonicalofstring|`Inline|`Open|`Closed|`Hidden]]typet=[(* End of input. *)`End|(* Runs of whitespace. [Blank_line] is any run of whitespace that contains two
or more newline characters. [Single_newline] is any run of whitespace that
contains exactly one newline character. [Space] is any run of whitespace
that contains no newline characters.
It is an important invariant in the parser that no adjacent whitespace
tokens are emitted by the lexer. Otherwise, there would be the need for
unbounded lookahead, a (co-?)ambiguity between
[Single_newline Single_newline] and [Blank_line], and other problems. *)`Spaceofstring|`Single_newlineofstring|`Blank_lineofstring|(* A right curly brace ([}]), i.e. end of markup. *)`Right_brace|`Right_code_delimiter|(* Words are anything that is not whitespace or markup. Markup symbols can be
be part of words if escaped.
Words can contain plus and minus symbols, but those are emitted as [Plus]
and [Minus] tokens. The parser combines plus and minus into words, except
when they appear first on a line, in which case the tokens are list item
bullets. *)`Wordofstring|`Code_spanofstring|`Raw_markupofstringoption*string|`Math_spanofstring|`Math_blockofstring|`Begin_styleofstyle|`Begin_paragraph_styleofparagraph_style|(* Other inline element markup. *)`Simple_referenceofstring|`Begin_reference_with_replacement_textofstring|`Simple_linkofstring|`Begin_link_with_replacement_textofstring|(* Leaf block element markup. *)`Code_blockof(stringLoc.with_location*stringLoc.with_locationoption)option*string*stringLoc.with_location*bool|`Verbatimofstring|`Modulesofstring|(* List markup. *)`Begin_listof[`Unordered|`Ordered]|`Begin_list_itemof[`Li|`Dash]|(* Table markup. *)`Begin_table_light|`Begin_table_heavy|`Begin_table_row|`Begin_table_cellof[`Header|`Data]|`Minus|`Plus|`Bar|section_heading|tag]letprint:[<t]->string=function|`Begin_paragraph_style`Left->"'{L'"|`Begin_paragraph_style`Center->"'{C'"|`Begin_paragraph_style`Right->"'{R'"|`Begin_style`Bold->"'{b'"|`Begin_style`Italic->"'{i'"|`Begin_style`Emphasis->"'{e'"|`Begin_style`Superscript->"'{^'"|`Begin_style`Subscript->"'{_'"|`Begin_reference_with_replacement_text_->"'{{!'"|`Begin_link_with_replacement_text_->"'{{:'"|`Begin_list_item`Li->"'{li ...}'"|`Begin_list_item`Dash->"'{- ...}'"|`Begin_table_light->"{t"|`Begin_table_heavy->"{table"|`Begin_table_row->"'{tr'"|`Begin_table_cell`Header->"'{th'"|`Begin_table_cell`Data->"'{td'"|`Minus->"'-'"|`Plus->"'+'"|`Bar->"'|'"|`Begin_section_heading(level,label)->letlabel=matchlabelwithNone->""|Somelabel->":"^labelinPrintf.sprintf"'{%i%s'"levellabel|`Tag(`Author_)->"'@author'"|`Tag`Deprecated->"'@deprecated'"|`Tag(`Param_)->"'@param'"|`Tag(`Raise_)->"'@raise'"|`Tag`Return->"'@return'"|`Tag(`See_)->"'@see'"|`Tag(`Since_)->"'@since'"|`Tag(`Before_)->"'@before'"|`Tag(`Version_)->"'@version'"|`Tag(`Canonical_)->"'@canonical'"|`Tag`Inline->"'@inline'"|`Tag`Open->"'@open'"|`Tag`Closed->"'@closed'"|`Tag`Hidden->"'@hidden"|`Raw_markup(None,_)->"'{%...%}'"|`Raw_markup(Sometarget,_)->"'{%"^target^":...%}'"(* [`Minus] and [`Plus] are interpreted as if they start list items. Therefore,
for error messages based on [Token.describe] to be accurate, formatted
[`Minus] and [`Plus] should always be plausibly list item bullets. *)letdescribe:[<t|`Comment]->string=function|`Wordw->Printf.sprintf"'%s'"w|`Code_span_->"'[...]' (code)"|`Raw_markup_->"'{%...%}' (raw markup)"|`Begin_paragraph_style`Left->"'{L ...}' (left alignment)"|`Begin_paragraph_style`Center->"'{C ...}' (center alignment)"|`Begin_paragraph_style`Right->"'{R ...}' (right alignment)"|`Begin_style`Bold->"'{b ...}' (boldface text)"|`Begin_style`Italic->"'{i ...}' (italic text)"|`Begin_style`Emphasis->"'{e ...}' (emphasized text)"|`Begin_style`Superscript->"'{^...}' (superscript)"|`Begin_style`Subscript->"'{_...}' (subscript)"|`Math_span_->"'{m ...}' (math span)"|`Math_block_->"'{math ...}' (math block)"|`Simple_reference_->"'{!...}' (cross-reference)"|`Begin_reference_with_replacement_text_->"'{{!...} ...}' (cross-reference)"|`Simple_link_->"'{:...} (external link)'"|`Begin_link_with_replacement_text_->"'{{:...} ...}' (external link)"|`End->"end of text"|`Space_->"whitespace"|`Single_newline_->"line break"|`Blank_line_->"blank line"|`Right_brace->"'}'"|`Right_code_delimiter->"']}'"|`Code_block_->"'{[...]}' (code block)"|`Verbatim_->"'{v ... v}' (verbatim text)"|`Modules_->"'{!modules ...}'"|`Begin_list`Unordered->"'{ul ...}' (bulleted list)"|`Begin_list`Ordered->"'{ol ...}' (numbered list)"|`Begin_list_item`Li->"'{li ...}' (list item)"|`Begin_list_item`Dash->"'{- ...}' (list item)"|`Begin_table_light->"'{t ...}' (table)"|`Begin_table_heavy->"'{table ...}' (table)"|`Begin_table_row->"'{tr ...}' (table row)"|`Begin_table_cell`Header->"'{th ... }' (table header cell)"|`Begin_table_cell`Data->"'{td ... }' (table data cell)"|`Minus->"'-' (bulleted list item)"|`Plus->"'+' (numbered list item)"|`Bar->"'|'"|`Begin_section_heading(level,_)->Printf.sprintf"'{%i ...}' (section heading)"level|`Tag(`Author_)->"'@author'"|`Tag`Deprecated->"'@deprecated'"|`Tag(`Param_)->"'@param'"|`Tag(`Raise_)->"'@raise'"|`Tag`Return->"'@return'"|`Tag(`See_)->"'@see'"|`Tag(`Since_)->"'@since'"|`Tag(`Before_)->"'@before'"|`Tag(`Version_)->"'@version'"|`Tag(`Canonical_)->"'@canonical'"|`Tag`Inline->"'@inline'"|`Tag`Open->"'@open'"|`Tag`Closed->"'@closed'"|`Tag`Hidden->"'@hidden"|`Comment->"top-level text"letdescribe_element=function|`Reference(`Simple,_,_)->describe(`Simple_reference"")|`Reference(`With_text,_,_)->describe(`Begin_reference_with_replacement_text"")|`Link_->describe(`Begin_link_with_replacement_text"")|`Heading(level,_,_)->describe(`Begin_section_heading(level,None))