type machine_state = | DataState | CharRefDataState | TagOpenState | CloseTagOpenState | TagNameState | BeforeAttributeNameState | AttributeNameState | AfterAttributeNameState | BeforeAttributeValueState | AttributeValueDoubleQuotedState | AttributeValueSingleQuotedState | AttributeValueUnquotedState | CharRefInAttributeValueState_DoubleQuoted (* split into three - saves the complexity of another state variable when exiting the state *) | CharRefInAttributeValueState_SingleQuoted | CharRefInAttributeValueState_Unquoted | AfterAttributeValueQuotedState | SelfClosingStartTagState | BogusCommentState | BogusCommentState_Continue (* makes things fit the state-machine model better *) | MarkupDeclarationOpenState | CommentStartState | CommentStartDashState | CommentState | CommentEndDashState | CommentEndState | DoctypeState | BeforeDoctypeNameState | DoctypeNameState | AfterDoctypeNameState | BeforeDoctypePublicIdentifierState | DoctypePublicIdentifierDoubleQuotedState | DoctypePublicIdentifierSingleQuotedState | AfterDoctypePublicIdentifierState | BeforeDoctypeSystemIdentifierState | DoctypeSystemIdentifierDoubleQuotedState | DoctypeSystemIdentifierSingleQuotedState | AfterDoctypeSystemIdentifierState | BogusDoctypeState let string_of_machine_state = function | DataState -> "DataState" | CharRefDataState -> "CharRefDataState" | TagOpenState -> "TagOpenState" | CloseTagOpenState -> "CloseTagOpenState" | TagNameState -> "TagNameState" | BeforeAttributeNameState -> "BeforeAttributeNameState" | AttributeNameState -> "AttributeNameState" | AfterAttributeNameState -> "AfterAttributeNameState" | BeforeAttributeValueState -> "BeforeAttributeValueState" | AttributeValueDoubleQuotedState -> "AttributeValueDoubleQuotedState" | AttributeValueSingleQuotedState -> "AttributeValueSingleQuotedState" | AttributeValueUnquotedState -> "AttributeValueUnquotedState" | CharRefInAttributeValueState_DoubleQuoted -> "CharRefInAttributeValueState_DoubleQuoted" | CharRefInAttributeValueState_SingleQuoted -> "CharRefInAttributeValueState_SingleQuoted" | CharRefInAttributeValueState_Unquoted -> "CharRefInAttributeValueState_Unquoted" | AfterAttributeValueQuotedState -> "AfterAttributeValueQuotedState" | SelfClosingStartTagState -> "SelfClosingStartTagState" | BogusCommentState -> "BogusCommentState" | BogusCommentState_Continue -> "BogusCommentState_Continue" | MarkupDeclarationOpenState -> "MarkupDeclarationOpenState" | CommentStartState -> "CommentStartState" | CommentStartDashState -> "CommentStartDashState" | CommentState -> "CommentState" | CommentEndDashState -> "CommentEndDashState" | CommentEndState -> "CommentEndState" | DoctypeState -> "DoctypeState" | BeforeDoctypeNameState -> "BeforeDoctypeNameState" | DoctypeNameState -> "DoctypeNameState" | AfterDoctypeNameState -> "AfterDoctypeNameState" | BeforeDoctypePublicIdentifierState -> "BeforeDoctypePublicIdentifierState" | DoctypePublicIdentifierDoubleQuotedState -> "DoctypePublicIdentifierDoubleQuotedState" | DoctypePublicIdentifierSingleQuotedState -> "DoctypePublicIdentifierSingleQuotedState" | AfterDoctypePublicIdentifierState -> "AfterDoctypePublicIdentifierState" | BeforeDoctypeSystemIdentifierState -> "BeforeDoctypeSystemIdentifierState" | DoctypeSystemIdentifierDoubleQuotedState -> "DoctypeSystemIdentifierDoubleQuotedState" | DoctypeSystemIdentifierSingleQuotedState -> "DoctypeSystemIdentifierSingleQuotedState" | AfterDoctypeSystemIdentifierState -> "AfterDoctypeSystemIdentifierState" | BogusDoctypeState -> "BogusDoctypeState" let prettyStateName s = (* strip the "State" and everything after it *) let n = string_of_machine_state s in let rec f i = if String.sub n i 5 = "State" then String.sub n 0 i else f (i+1) in f 0;; let enumerate_machine_state = [ DataState; CharRefDataState; TagOpenState; CloseTagOpenState; TagNameState; BeforeAttributeNameState; AttributeNameState; AfterAttributeNameState; BeforeAttributeValueState; AttributeValueDoubleQuotedState; AttributeValueSingleQuotedState; AttributeValueUnquotedState; CharRefInAttributeValueState_DoubleQuoted; CharRefInAttributeValueState_SingleQuoted; CharRefInAttributeValueState_Unquoted; AfterAttributeValueQuotedState; SelfClosingStartTagState; BogusCommentState; BogusCommentState_Continue; MarkupDeclarationOpenState; CommentStartState; CommentStartDashState; CommentState; CommentEndDashState; CommentEndState; DoctypeState; BeforeDoctypeNameState; DoctypeNameState; AfterDoctypeNameState; BeforeDoctypePublicIdentifierState; DoctypePublicIdentifierDoubleQuotedState; DoctypePublicIdentifierSingleQuotedState; AfterDoctypePublicIdentifierState; BeforeDoctypeSystemIdentifierState; DoctypeSystemIdentifierDoubleQuotedState; DoctypeSystemIdentifierSingleQuotedState; AfterDoctypeSystemIdentifierState; BogusDoctypeState; ] type content_model = PCDATA | RCDATA | CDATA | PLAINTEXT let string_of_content_model = function PCDATA -> "PCDATA" | RCDATA -> "RCDATA" | CDATA -> "CDATA" | PLAINTEXT -> "PLAINTEXT" let enumerate_content_model = [PCDATA; RCDATA; CDATA; PLAINTEXT]