@@ -58,6 +58,34 @@ pub fn block_comment(input: Input<'_>) -> ParserResult<'_, &str> {
5858 . parse ( input)
5959}
6060
61+ /// Parses a typereference lexical item.
62+ ///
63+ /// #### X.680 12.2 Type references
64+ /// _A "typereference" shall consist of an arbitrary number (one or more) of letters, digits, and
65+ /// hyphens. The initial character shall be an upper-case letter. A hyphen shall not be the last
66+ /// character. A hyphen shall not be immediately followed by another hyphen. NOTE – The rules
67+ /// concerning hyphen are designed to avoid ambiguity with (possibly following) comment. 12.2.2A
68+ /// "typereference" shall not be one of the reserved character sequences listed in 12.38._
69+ pub fn type_reference ( input : Input < ' _ > ) -> ParserResult < ' _ , & ' _ str > {
70+ map_res (
71+ recognize ( pair (
72+ one_of ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ,
73+ many0 ( alt ( (
74+ preceded ( char ( '-' ) , into_inner ( alphanumeric1) ) ,
75+ into_inner ( alphanumeric1) ,
76+ ) ) ) ,
77+ ) ) ,
78+ |identifier| {
79+ if ASN1_KEYWORDS . contains ( & identifier. inner ( ) ) {
80+ Err ( MiscError ( "Identifier is ASN.1 keyword." ) )
81+ } else {
82+ Ok ( identifier. into_inner ( ) )
83+ }
84+ } ,
85+ )
86+ . parse ( input. clone ( ) )
87+ }
88+
6189/// Parses an ASN1 identifier.
6290///
6391/// * `input` [Input]-wrapped string slice reference used as an input for the lexer
@@ -97,33 +125,23 @@ pub fn value_reference(input: Input<'_>) -> ParserResult<'_, &'_ str> {
97125 . parse ( input)
98126}
99127
128+ /// Parses a modulereference lexical item.
129+ ///
130+ /// #### X.680 12.5 Module references
131+ /// _A "modulereference" shall consist of the sequence of characters specified for a
132+ /// "typereference" in 12.2. In analyzing an instance of use of this notation, a "modulereference"
133+ /// is distinguished from a "typereference" by the context in which it appears._
134+ pub fn module_reference ( input : Input < ' _ > ) -> ParserResult < ' _ , & ' _ str > {
135+ type_reference ( input)
136+ }
137+
100138pub fn into_inner < ' a , F > ( parser : F ) -> impl Parser < Input < ' a > , Output = & ' a str , Error = F :: Error >
101139where
102140 F : Parser < Input < ' a > , Output = Input < ' a > > ,
103141{
104142 map ( parser, Input :: into_inner)
105143}
106144
107- pub fn title_case_identifier ( input : Input < ' _ > ) -> ParserResult < ' _ , & str > {
108- map_res (
109- recognize ( pair (
110- one_of ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ,
111- many0 ( alt ( (
112- preceded ( char ( '-' ) , into_inner ( alphanumeric1) ) ,
113- into_inner ( alphanumeric1) ,
114- ) ) ) ,
115- ) ) ,
116- |identifier| {
117- if ASN1_KEYWORDS . contains ( & identifier. inner ( ) ) {
118- Err ( MiscError ( "Identifier is ASN.1 keyword." ) )
119- } else {
120- Ok ( identifier. into_inner ( ) )
121- }
122- } ,
123- )
124- . parse ( input. clone ( ) )
125- }
126-
127145pub fn skip_ws < ' a , F > ( inner : F ) -> impl Parser < Input < ' a > , Output = F :: Output , Error = F :: Error >
128146where
129147 F : Parser < Input < ' a > > ,
0 commit comments