@@ -53,7 +53,9 @@ pub trait ASTVisitor<'a> {
5353 . unwrap_or ( & DEFAULT_NAME ) ,
5454 args. get ( 1 ) . unwrap_or ( & DEFAULT_EXPR ) ,
5555 ) ,
56- DefineFunctions :: PrivateFunction => {
56+ DefineFunctions :: PrivateFunction
57+ | DefineFunctions :: ReadOnlyFunction
58+ | DefineFunctions :: PublicFunction => {
5759 match args. get ( 0 ) . unwrap_or ( & DEFAULT_EXPR ) . match_list ( ) {
5860 Some ( signature) => {
5961 let name = signature
@@ -64,57 +66,20 @@ pub trait ASTVisitor<'a> {
6466 0 | 1 => None ,
6567 _ => match_pairs_list ( & signature[ 1 ..] ) ,
6668 } ;
67- self . traverse_define_private (
68- expr,
69- name,
70- params,
71- args. get ( 1 ) . unwrap_or ( & DEFAULT_EXPR ) ,
72- ) ;
73- }
74- _ => {
75- false ;
76- }
77- }
78- true
79- }
80- DefineFunctions :: ReadOnlyFunction => {
81- match args. get ( 0 ) . unwrap_or ( & DEFAULT_EXPR ) . match_list ( ) {
82- Some ( signature) => {
83- let name = signature
84- . get ( 0 )
85- . and_then ( |n| n. match_atom ( ) )
86- . unwrap_or ( & DEFAULT_NAME ) ;
87- let params = match signature. len ( ) {
88- 0 | 1 => None ,
89- _ => match_pairs_list ( & signature[ 1 ..] ) ,
90- } ;
91- self . traverse_define_read_only (
92- expr,
93- name,
94- params,
95- args. get ( 1 ) . unwrap_or ( & DEFAULT_EXPR ) ,
96- )
97- }
98- _ => false ,
99- }
100- }
101- DefineFunctions :: PublicFunction => {
102- match args. get ( 0 ) . unwrap_or ( & DEFAULT_EXPR ) . match_list ( ) {
103- Some ( signature) => {
104- let name = signature
105- . get ( 0 )
106- . and_then ( |n| n. match_atom ( ) )
107- . unwrap_or ( & DEFAULT_NAME ) ;
108- let params = match signature. len ( ) {
109- 0 | 1 => None ,
110- _ => match_pairs_list ( & signature[ 1 ..] ) ,
111- } ;
112- self . traverse_define_public (
113- expr,
114- name,
115- params,
116- args. get ( 1 ) . unwrap_or ( & DEFAULT_EXPR ) ,
117- )
69+ let body = args. get ( 1 ) . unwrap_or ( & DEFAULT_EXPR ) ;
70+
71+ match define_function {
72+ DefineFunctions :: PrivateFunction => {
73+ self . traverse_define_private ( expr, name, params, body)
74+ }
75+ DefineFunctions :: ReadOnlyFunction => {
76+ self . traverse_define_read_only ( expr, name, params, body)
77+ }
78+ DefineFunctions :: PublicFunction => {
79+ self . traverse_define_public ( expr, name, params, body)
80+ }
81+ _ => unreachable ! ( ) ,
82+ }
11883 }
11984 _ => false ,
12085 }
0 commit comments