Changeset 51d4040 in mainline
- Timestamp:
- 2009-09-16T23:22:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1fb1d1
- Parents:
- cf7b3e0
- Location:
- contrib/arch
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/arch/hadlbppp.py
rcf7b3e0 r51d4040 35 35 36 36 # TODO: 37 # - alternative token38 # - iface protocol repetition39 37 # - interface inheritance 40 38 … … 130 128 return True 131 129 132 def preproc_bp(name, tokens):130 def tentative_bp(name, tokens): 133 131 "Preprocess tentative statements in Behavior Protocol" 134 132 … … 153 151 if (level == 0): 154 152 result.append("(") 155 result.extend( preproc_bp(name, tokens[start:(i - 1)]))153 result.extend(tentative_bp(name, tokens[start:(i - 1)])) 156 154 result.append(")") 157 155 result.append("+") … … 162 160 print "%s: Syntax error in tentative statement" % name 163 161 else: 164 print "%s: Unexpected token intentative statement" % name162 print "%s: Expected '{' for tentative statement" % name 165 163 else: 166 164 result.append(tokens[i]) … … 170 168 return result 171 169 170 def alternative_bp(name, tokens): 171 "Preprocess alternative statements in Behavior Protocol" 172 173 result = [] 174 i = 0 175 176 while (i < len(tokens)): 177 if (tokens[i] == "alternative"): 178 if ((i + 1 < len(tokens)) and (tokens[i + 1] == "(")): 179 i += 2 180 reps = [] 181 182 while ((i < len(tokens)) and (tokens[i] != ")")): 183 reps.append(tokens[i]) 184 if ((i + 1 < len(tokens)) and (tokens[i + 1] == ";")): 185 i += 2 186 else: 187 i += 1 188 189 if (len(reps) >= 2): 190 if ((i + 1 < len(tokens)) and (tokens[i + 1] == "{")): 191 i += 2 192 193 start = i 194 level = 1 195 196 while ((i < len(tokens)) and (level > 0)): 197 if (tokens[i] == "{"): 198 level += 1 199 elif (tokens[i] == "}"): 200 level -= 1 201 202 i += 1 203 204 if (level == 0): 205 first = True 206 207 for rep in reps[1:]: 208 retokens = [] 209 for token in tokens[start:(i - 1)]: 210 parts = token.split(".") 211 if ((len(parts) == 2) and (parts[0] == reps[0])): 212 retokens.append("%s.%s" % (rep, parts[1])) 213 else: 214 retokens.append(token) 215 216 if (first): 217 first = False 218 else: 219 result.append("+") 220 221 result.append("(") 222 result.extend(alternative_bp(name, retokens)) 223 result.append(")") 224 225 if (i < len(tokens)): 226 result.append(tokens[i]) 227 else: 228 print "%s: Syntax error in alternative statement" % name 229 else: 230 print "%s: Expected '{' for alternative statement body" % name 231 else: 232 print "%s: At least one pattern and one replacement required for alternative statement" % name 233 else: 234 print "%s: Expected '(' for alternative statement head" % name 235 else: 236 result.append(tokens[i]) 237 238 i += 1 239 240 return result 241 172 242 def split_bp(protocol): 173 243 "Convert Behavior Protocol to tokens" … … 176 246 177 247 def extend_bp(name, tokens, iface): 178 " Add interface to incoming messages"179 180 result = [ ]248 "Convert interface Behavior Protocol to generic protocol" 249 250 result = ["("] 181 251 i = 0 182 252 … … 198 268 i += 1 199 269 270 result.append(")") 271 result.append("*") 272 200 273 return result 201 274 … … 227 300 "Parse Behavior Protocol" 228 301 229 tokens = preproc_bp(name, tokens) 302 tokens = tentative_bp(name, tokens) 303 tokens = alternative_bp(name, tokens) 230 304 231 305 indent = base_indent -
contrib/arch/uspace/lib/libfs/fnc.libfs_lookup
rcf7b3e0 r51d4040 1 1 ( 2 alternative fs tmpfs fat devfs{2 alternative (fs; tmpfs; fat; devfs) { 3 3 !fs.lookup 4 4 } -
contrib/arch/uspace/lib/libfs/fnc.libfs_mount
rcf7b3e0 r51d4040 1 1 ?ipc_m_connection_clone ; 2 2 ?ipc_m_data_write /* mount options */ { 3 alternative fs tmpfs fat devfs{3 alternative (fs; tmpfs; fat; devfs) { 4 4 !fs.ipc_m_connect_to_me ; 5 5 !fs.mounted ; -
contrib/arch/uspace/srv/vfs/vfs.bp
rcf7b3e0 r51d4040 21 21 ( 22 22 /* root fs */ 23 alternative fs tmpfs fat devfs{23 alternative (fs; tmpfs; fat; devfs) { 24 24 !fs.mounted ; 25 25 !fs.ipc_m_data_write /* mount options */ … … 29 29 /* non-root fs */ 30 30 tentative { 31 alternative fs tmpfs fat devfs{31 alternative (fs; tmpfs; fat; devfs) { 32 32 [fnc.vfs_lookup_internal] ; 33 33 tentative { … … 55 55 ?ipc_m_data_write /* path */ ; 56 56 tentative { 57 alternative fs tmpfs fat devfs{57 alternative (fs; tmpfs; fat; devfs) { 58 58 [fnc.vfs_lookup_internal] ; 59 59 tentative { … … 68 68 69 69 ?open_node { 70 alternative fs tmpfs fat devfs{70 alternative (fs; tmpfs; fat; devfs) { 71 71 [fnc.vfs_open_node_internal] ; 72 72 tentative { … … 80 80 ?close { 81 81 tentative { 82 alternative fs tmpfs fat devfs{82 alternative (fs; tmpfs; fat; devfs) { 83 83 [fnc.vfs_grab_phone] ; 84 84 !fs.close ; … … 91 91 tentative { 92 92 ?ipc_m_data_read { 93 alternative fs tmpfs fat devfs{93 alternative (fs; tmpfs; fat; devfs) { 94 94 [fnc.vfs_grab_phone] ; 95 95 !fs.read ; … … 104 104 tentative { 105 105 ?ipc_m_data_write { 106 alternative fs tmpfs fat devfs{106 alternative (fs; tmpfs; fat; devfs) { 107 107 [fnc.vfs_grab_phone] ; 108 108 !fs.write ; … … 116 116 ?truncate { 117 117 tentative { 118 alternative fs tmpfs fat devfs{118 alternative (fs; tmpfs; fat; devfs) { 119 119 [fnc.vfs_grab_phone] ; 120 120 !fs.truncate ; … … 127 127 tentative { 128 128 ?ipc_m_data_read /* struct stat */ { 129 alternative fs tmpfs fat devfs{129 alternative (fs; tmpfs; fat; devfs) { 130 130 [fnc.vfs_grab_phone] ; 131 131 !fs.stat ; … … 141 141 tentative { 142 142 ?ipc_m_data_read /* struct stat */ { 143 alternative fs tmpfs fat devfs{143 alternative (fs; tmpfs; fat; devfs) { 144 144 [fnc.vfs_lookup_internal] ; 145 145 tentative { … … 155 155 ?ipc_m_data_write /* path */ ; 156 156 tentative { 157 alternative fs tmpfs fat devfs{157 alternative (fs; tmpfs; fat; devfs) { 158 158 [fnc.vfs_lookup_internal] 159 159 } … … 164 164 ?ipc_m_data_write /* path */ ; 165 165 tentative { 166 alternative fs tmpfs fat devfs{166 alternative (fs; tmpfs; fat; devfs) { 167 167 [fnc.vfs_lookup_internal] 168 168 } … … 175 175 ?ipc_m_data_write /* new path */ ; 176 176 tentative { 177 alternative fs tmpfs fat devfs{177 alternative (fs; tmpfs; fat; devfs) { 178 178 [fnc.vfs_lookup_internal] /* lookup old path */ ; 179 179 tentative { … … 196 196 ?sync { 197 197 tentative { 198 alternative fs tmpfs fat devfs{198 alternative (fs; tmpfs; fat; devfs) { 199 199 !fs.sync 200 200 }
Note:
See TracChangeset
for help on using the changeset viewer.