// -.1 Command-installing command. Install manually as COM 2 MakeNotPendingDelete MakeSecondary Operations ToPrimary EditText MakePDel DoEdit CommandNumber "1" // -.05 Do current substitution. Install as COM 3 DoSubstitute // 0. Provide type definitions for all procedure parameters and return values, and // for all "let" variables. Manually. // 1. Replace BCPL Comments by C Comments throughout PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "//" InsertLineBreak ReplaceBy "/* */" InsertLineBreak PopSelection DoSubstitute PushSelection SearchFor "*/" InsertLineBreak "/*" ReplaceBy InsertLineBreak " " MatchLiterally PopSelection DoSubstitute // 2. Change "get" to "include" throughout PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "get \'\".decl\'\"" InsertLineBreak ReplaceBy "#include \'<.h\'>" InsertLineBreak PopSelection DoSubstitute // 3. Manifests become defines throughout -- manual "Yes" PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "manifest =" InsertLineBreak ReplaceBy "#define " InsertLineBreak PopSelection // 4. Fix "size" specifications PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "\'#define {size /16}" InsertLineBreak ReplaceBy "(sizeof ()/2)" InsertLineBreak PopSelection // 5. Simple subst, bracket, semicolon transformations. PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "structure :[" ReplaceBy "struct {" PopSelection DoSubstitute PushSelection SearchFor "[" ReplaceBy "{" PopSelection DoSubstitute PushSelection SearchFor "]" ReplaceBy ";};" PopSelection DoSubstitute PushSelection SearchFor " ;" ReplaceBy "; " PopSelection DoSubstitute PushSelection SearchFor ";;" ReplaceBy ";" PopSelection DoSubstitute //5.5 Exchange types and ids in structure specifications PushSelection SearchFor "" MatchLiterally MatchPattern SubstituteInSel ReplaceBy ";" PopSelection // 6. Clean up structure references (simple minded -- assume all right lumps.) PushSelection MatchLiterally MatchAnywhere SubstituteInEntireDoc SearchFor ">>" ReplaceBy "++" PopSelection DoSubstitute PushSelection MatchPattern SearchFor "++." ReplaceBy "->" PopSelection DoSubstitute // 7. More simple substitutions, statement level PushSelection MatchLiterally MatchWords SubstituteInEntireDoc SearchFor "resultis" ReplaceBy "return" PopSelection DoSubstitute PushSelection MatchLiterally MatchAnywhere SubstituteInEntireDoc SearchFor "lv " ReplaceBy "&" PopSelection DoSubstitute PushSelection MatchLiterally MatchAnywhere SubstituteInEntireDoc SearchFor "@" ReplaceBy "*" PopSelection DoSubstitute // 8. Control structures // First, eliminate all ifs that don't have matching thens. Manually. // Then run this. You get to do the actual searching. PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "if then" ReplaceBy "if ()" PopSelection PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "test ifso" ReplaceBy "if ()" PopSelection PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "ifnot" ReplaceBy ";else" PopSelection PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "while do" ReplaceBy "while ()" PopSelection PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "switchon into" ReplaceBy "switch ()" PopSelection PushSelection MatchPattern MatchAnywhere SubstituteInEntireDoc SearchFor "selecton into" // You've got to deal with this one. // Indexing -- doesn't do very well. PushSelection MatchLiterally MatchAnywhere SubstituteInEntireDoc SearchFor "!(" ReplaceBy ":::(" PopSelection PushSelection MatchPattern SearchFor MatchAnywhere SubstituteInEntireDoc SearchFor ":::()" ReplaceBy "[]" PopSelection // Conditionals PushSelection MatchLiterally MatchWords SubstituteInEntireDoc SearchFor "eq" ReplaceBy "==" PopSelection DoSubstitute PushSelection SearchFor "ne" ReplaceBy "!=" PopSelection DoSubstitute PushSelection SearchFor "le" ReplaceBy "<=" PopSelection DoSubstitute PushSelection SearchFor "ge" ReplaceBy ">=" PopSelection DoSubstitute PushSelection SearchFor "gr" ReplaceBy ">" PopSelection DoSubstitute PushSelection SearchFor "ls" ReplaceBy "<" PopSelection DoSubstitute // External declarations; repair by adding return types. PushSelection MatchPattern MatchAnywhere SearchFor InsertLineBreak "{ }" InsertLineBreak ReplaceBy "extern ();" PopSelection