Changeset 21193 for misc/sm0p/sm0p.pm
- Timestamp:
- 07/03/08 22:05:08 (5 months ago)
- Files:
-
- 1 modified
-
misc/sm0p/sm0p.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
misc/sm0p/sm0p.pm
r20888 r21193 1 1 grammar sm0p; 2 2 token frame { 3 <ws> <identifier> <ws> '=' <ws> 'q:sm0p' <ws> '{' <ws> <node>+ <ws> '}' <ws> ';'3 <ws> <identifier> <ws> '=' <ws> 'q:sm0p' <ws> '{' <ws> <nodes> <ws> '}' <ws> ';'? 4 4 { make $<identifier> ~ ' = SMOP_DISPATCH(interpreter, ' 5 5 ~ 'SMOP__SLIME__Frame, SMOP__ID__new, SMOP__NATIVE__capture_create(' 6 6 ~ 'interpreter, SMOP__SLIME__Frame, (SMOP__Object*[]){ ' 7 ~ ($$<node>).join(',') ~ ' }, NULL)); ' } 8 }; 7 ~ $<nodes> ~ ' }, NULL)); ' } 8 } 9 10 token nodes { 11 <node>* 12 { make $<node>.join(', ') } 13 } 9 14 10 15 token node { 16 <node_empty> { make $<node_empty> ~ '' } 17 || <node_result> { make $<node_result> ~ '' } 18 || <node_capturized> { make $<node_capturized> ~ '' } 19 || <node_full> { make $<node_full> ~ '' } 20 } 21 22 token node_empty { 23 # <ws> 24 ';' 25 { make 'SMOP_DISPATCH(interpreter, SMOP__SLIME__Node, SMOP__ID__new, ' 26 ~ ' SMOP__NATIVE__capture_create(interpreter, SMOP__SLIME__Node, NULL, NULL))' } 27 } 28 29 token node_full { 11 30 <ws> <responder> '.' <identifier> '(' 12 [ < ws> <invocant> <ws> ':' ]? <ws> <positional> <ws> <named> <ws> ')' ';'31 [ <invocant>||'' ] <ws> <named> <ws> <positional> <ws> ')' <ws> ';' <ws> 13 32 { make 'SMOP_DISPATCH(interpreter, SMOP__SLIME__Node, SMOP__ID__new, ' 14 33 ~ ' SMOP__NATIVE__capture_create(interpreter, SMOP__SLIME__Node, NULL, (SMOP__Object*[]){' 15 ~ ' SMOP__ID__responder, SMOP_R I(' ~ $<responder> ~ '), '16 ~ ' SMOP__ID__identifier, ' ~ $<identifier> ~ ', '34 ~ ' SMOP__ID__responder, SMOP_REFERENCE(interpreter,(SMOP__Object*)SMOP_RI(' ~ $<responder> ~ ')), ' 35 ~ ' SMOP__ID__identifier, SMOP_REFERENCE(interpreter,' ~ $<identifier> ~ '), ' 17 36 ~ ' SMOP__ID__capture, SMOP__NATIVE__capture_create(interpreter, ' 18 ~ ($<invocant> ?? $<invocant> !! $<responder>) ~ ', '~ $<positional> ~', '~ $<named> ~') ' 19 ~ ',NULL }))' } 20 | <ws> <identifier> <ws> ';' 37 ~ 'SMOP_REFERENCE(interpreter,' ~ ($<invocant> ?? $<invocant> !! $<responder>) ~ '), '~ $<positional> ~', '~ $<named> ~') ' 38 ~ ' , NULL }))' } 39 } 40 41 token node_capturized { 42 <ws> <responder> '.' <identifier> '(' 43 <ws> '|' <identifier2> <ws> ')' <ws> ';' <ws> 21 44 { make 'SMOP_DISPATCH(interpreter, SMOP__SLIME__Node, SMOP__ID__new, ' 22 45 ~ ' SMOP__NATIVE__capture_create(interpreter, SMOP__SLIME__Node, NULL, (SMOP__Object*[]){' 23 ~ ' SMOP__ID__result, ' ~ $<identifier> 24 ~ ',NULL }))' } 25 | <ws> ';' 46 ~ ' SMOP__ID__responder, SMOP_REFERENCE(interpreter,(SMOP__Object*)SMOP_RI(' ~ $<responder> ~ ')), ' 47 ~ ' SMOP__ID__identifier, SMOP_REFERENCE(interpreter,' ~ $<identifier> ~ '), ' 48 ~ ' SMOP__ID__capture, ' ~ $<identifier2> 49 ~ ' , NULL }))' } 50 } 51 52 token node_result { 53 <ws> <identifier> <ws> ';' 26 54 { make 'SMOP_DISPATCH(interpreter, SMOP__SLIME__Node, SMOP__ID__new, ' 27 ~ ' SMOP__NATIVE__capture_create(interpreter, SMOP__SLIME__Node, NULL, NULL))' } 28 }; 55 ~ ' SMOP__NATIVE__capture_create(interpreter, SMOP__SLIME__Node, NULL, (SMOP__Object*[]){' 56 ~ ' SMOP__ID__result, SMOP_REFERENCE(interpreter,' ~ $<identifier> ~ ')' 57 ~ ' , NULL}))' } 58 } 29 59 30 60 token invocant { 31 <identifier> 32 }; 61 <ws> <identifier> <ws> ':' <ws> 62 { make $<identifier> ~ '' } 63 } 33 64 34 65 token responder { 35 66 <identifier> 36 }; 67 { make $<identifier> ~ '' } 68 } 37 69 38 70 token positional { 39 71 <positionals> 40 { make '(SMOP__Object*[]){' ~ ($$<positionals>).join(',') ~ ',NULL}' }41 | { make 'NULL' }42 } ;72 { make '(SMOP__Object*[]){' ~ $<positionals> ~ '}' } 73 ||{ make ' NULL' } 74 } 43 75 44 76 token positionals { 45 77 <identifier> 46 78 [ 47 |<ws> \, <ws> <positionals>48 { make [ $$<identifier>, ( $$<positionals> ).values ]}49 | <ws> [ \, <ws> | '' ]50 { make [ $$<identifier> ]}79 || <ws> \, <ws> <positionals> 80 { make $<identifier> ~ ', ' ~ $<positionals> } 81 || <ws> 82 { make $<identifier> ~ ', NULL' } 51 83 ] 52 | { make [ ] }53 84 } 54 85 55 86 token named { 56 87 <pairs> 57 { make '(SMOP__Object*[]){' ~ ($$<pairs>).join(',') ~ ',NULL}' }58 | { make 'NULL' }59 } ;88 { make '(SMOP__Object*[]){' ~ $<pairs> ~ '}' } 89 ||{ make ' NULL' } 90 } 60 91 61 92 token pairs { 62 93 <pair> 63 94 [ 64 |<ws> \, <ws> <pairs>65 { make [ $$<pair>, ( $$<pairs> ).values ]}66 |<ws> [ \, <ws> | '' ]67 { make [ $$<pair> ]}95 <ws> \, <ws> <pairs> 96 { make $<pair> ~ ', ' ~ $<pairs> } 97 || <ws> [ \, <ws> | '' ] 98 { make $<pair> ~ ', NULL' } 68 99 ] 69 | { make [ ] }70 100 } 71 101 … … 73 103 <identifier> <ws> '=>' <ws> <identifier2> 74 104 { make $<identifier> ~ ', ' ~ $<identifier2> } 75 } ;105 } 76 106 77 107 token identifier2 { 78 <identifier> 79 } ;108 <identifier> { make $<identifier> ~ '' } 109 } 80 110 81 111 token identifier { 82 '$' <name> { make $<name> } 83 | <idconst> { make $<idconst> } 84 | <name> { make $<name> } 85 }; 112 <capturize> { make $<capturize> ~ '' } 113 ||'$' <name> { make $<name> ~ '' } 114 ||<idconst> { make $<idconst> ~ ''} 115 ||<name> { make $<name> ~ '' } 116 ||<nativeint> { make $<nativeint> ~ '' } 117 } 86 118 87 119 token idconst { 88 new { make 'SMOP__ID__new' } 89 | lexical { make 'SMOP__ID__lexical' } 90 }; 120 <idconst_list> { make 'SMOP__ID__' ~ $/ ~ '' } 121 } 122 123 token idconst_list {(new|lexical|back|capture|continuation|continues|copy|current|debug|drop|DESTROYALL|eval|forget|free|goto|has_next|identifier|jail|lexical|loop|move_capturize|move_identifier|move_responder|new|next|past|push|responder|result|setr|outer)} 91 124 92 125 token name { 93 < .alpha> [ <.alpha> | <.digit> ]+94 } ;126 <nameP5> 127 } 95 128 96 token ws { 97 [ \s | \n | '#' .+? \n ]* 98 }; 129 token ws {\s*} 99 130 100 token digit { 101 <[0-9]> 102 }; 131 token capturize { 132 <ws> SMOP__SLIME__Capturize '.' new '(' <ws> 133 <cint1> <ws> ',' <ws> <cintlist1> <ws> ',' <ws> 134 <cintlist2> <ws> ',' <ws> <cint2> ')' 135 { make 'SMOP__SLIME__Capturize_create(' ~ $<cint1> ~ ',' 136 ~ $<cintlist1> ~ ',' ~ $<cintlist2> ~ ',' 137 ~ $<cint2> ~ ')' } 138 } 139 140 token cint1 { <cint> { make $<cint> ~ '' } } 141 token cint2 { <cint> { make $<cint> ~ '' } } 142 token cint { 143 <digitsP5> { make $/ ~ '' } 144 } 145 146 token cintlist1 { <cintlist> { make $<cintlist> ~ '' } } 147 token cintlist2 { <cintlist> { make $<cintlist> ~ '' } } 148 token cintlist { 149 '(' 150 [ <cintlistbody> ')' {make '(int[]){ '~ $<cintlistbody> ~ ' }' } 151 ||')' {make 'NULL'} ] 152 ||'' {make 'NULL'} 153 } 154 155 token cintlistbody { 156 <ws> <cint> <ws> 157 [ 158 ',' <ws> <cintlistbody> <ws> 159 { make $<cint> ~ ', ' ~ $<cintlistbody> } 160 ||'' { make $<cint> ~ ', 0 '} 161 ] 162 } 163 164 token nativeint { 165 <digitsP5> { make 'SMOP__NATIVE__int_create(' ~ $/ ~ ')' } 166 } 167 168 token nativeint_list { 169 '(' <nativeint_list_body> 170 ')' {make '(SMOP__Object*[]){ '~ $<nativeint_list_body> ~ ' }' } 171 ||'' {make 'NULL'} 172 } 173 174 token nativeint_list_body { 175 <ws> <nativeint> <ws> 176 [ 177 ',' <ws> <nativeint_list_body> <ws> 178 { make $<nativeint> ~ ', ' ~ $<nativeint_list_body> } 179 ||'' { make $<nativeint> ~ ', NULL '} 180 ] 181 } 182 183 token nameP5 {<[a-zA-Z_]>\w*} 184 #token nameP5 {<[a-zA-Z_]>\w*} 185 token digitsP5 {\d+}
