1414 limitations under the License.
1515*/
1616
17- use celma_v0_core:: parser:: core:: eos;
17+ use celma_v0_core:: parser:: core:: { eos, returns , Returns } ;
1818use celma_v0_core:: parser:: literal:: { delimited_char, delimited_string} ;
1919
2020use celma_v0_macro:: parsec_rules;
2121use celma_v1_ast:: syntax:: ASTParsec :: {
22- PAtom , PAtoms , PBind , PCheck , PChoice , PCode , PIdent , PLookahead , PMap , PNot , POptional ,
23- PRepeat , PSequence , PTry ,
22+ PAtom , PAtoms , PBind , PCheck , PChoice , PCode , PIdent , PMap , PNot , POptional , PRepeat ,
23+ PSequence , PTry ,
2424} ;
2525use celma_v1_ast:: syntax:: { ASTParsec , ASTParsecRule } ;
2626
@@ -63,11 +63,11 @@ fn mk_ast_parsec(
6363 occ
6464 } ;
6565
66- let add = if let Some ( value ) = add {
67- if value . 0 {
68- PChoice ( bind. wrap ( ) , value . 1 . wrap ( ) )
66+ let add = if let Some ( ( choice , parser ) ) = add {
67+ if choice {
68+ PChoice ( bind. wrap ( ) , parser . wrap ( ) )
6969 } else {
70- PSequence ( bind. wrap ( ) , value . 1 . wrap ( ) )
70+ PSequence ( bind. wrap ( ) , parser . wrap ( ) )
7171 }
7272 } else {
7373 bind
@@ -85,22 +85,25 @@ fn mk_atom(operation: Option<char>, parsec: ASTParsec<char>) -> ASTParsec<char>
8585 Some ( '^' ) => PNot ( parsec. wrap ( ) ) ,
8686 Some ( '!' ) => PTry ( parsec. wrap ( ) ) ,
8787 Some ( '#' ) => PCheck ( parsec. wrap ( ) ) ,
88- Some ( '/' ) => PLookahead ( parsec. wrap ( ) ) ,
8988 _ => parsec,
9089 }
9190}
9291
92+ fn epsilon ( ) -> Returns < ( ) > {
93+ returns ( ( ) )
94+ }
95+
9396parsec_rules ! (
9497 let skip = ( ' ' |'\t' |'\n' |'\r' ) * -> { }
9598 let ident: { String } = ( skip i=#( alpha ( alpha|digit|'_' ) * ) skip) -> { i. into_iter( ) . collect( ) }
9699
97- let rkind = ( /'>' -> { } )
98- | ( ^( '<' |'>' ) + rkind -> { } )
100+ let rkind = ( ^( '<' |'>' ) + rkind -> { } )
99101 | ( '<' rkind '>' rkind -> { } )
102+ | epsilon
100103
101- let rcode = ( /'}' -> { } )
102- | ( ^( '}' |'{' ) + rcode -> { } )
104+ let rcode = ( ^( '}' |'{' ) + rcode -> { } )
103105 | ( '{' rcode '}' rcode -> { } )
106+ | epsilon
104107
105108 let kind: { String } = ( skip '<' c=#rkind '>' skip) -> { c. into_iter( ) . collect( ) }
106109 let code: { String } = ( skip '{' c=#rcode '}' skip) -> { c. into_iter( ) . collect( ) }
0 commit comments