As in "gst-convert -r 'MessageSend->DirectedMessage' ff.st -" or also
"./gst -f ../scripts/Convert.st -r '`@x value->`@x foo' < ff.st". Paolo * looking for [hidden email]--2004b/smalltalk--devo--2.2--patch-468 to compare with * auto-adding [hidden email]--2004b/smalltalk--devo--2.2--patch-468 to greedy revision library /Users/bonzinip/Archives/revlib * found immediate ancestor revision in library ([hidden email]--2004b/smalltalk--devo--2.2--patch-467) * patching for this revision ([hidden email]--2004b/smalltalk--devo--2.2--patch-468) * comparing to [hidden email]--2004b/smalltalk--devo--2.2--patch-468 M scripts/Convert.st * modified files --- orig/scripts/Convert.st +++ mod/scripts/Convert.st @@ -153,7 +153,7 @@ EmittedEntity subclass: EmittedEval [ STInST.STClassLoader subclass: SyntaxConverter [ - | stuffToEmit classesToEmit createdNamespaces filter outStream | + | stuffToEmit classesToEmit createdNamespaces filter outStream rewriter | <comment: 'A class loader that creates a set of "EmittedEntity" based on the contents of the given file being loaded. @@ -217,21 +217,43 @@ STInST.STClassLoader subclass: SyntaxCon outStream := out. ] + rewrite: node [ + ^rewriter isNil + ifTrue: [ node ] + ifFalse: [ rewriter executeTree: node; tree ]. + ] + evaluate: node [ <category: 'overrides'> + | rewritten | + rewritten := self rewrite: node. node comments isEmpty ifFalse: [ stuffToEmit add: (EmittedComments comments: node comments source: node source) ]. ^super evaluate: node ] + addRule: searchString [ + | tree rule | + tree := RBParser parseRewriteExpression: searchString. + tree isMessage ifFalse: [ self error: 'expected ->' ]. + tree selector = #-> ifFalse: [ self error: 'expected ->' ]. + rule := RBStringReplaceRule + searchForTree: tree receiver + replaceWith: tree arguments first. + + rewriter isNil ifTrue: [ rewriter := ParseTreeRewriter new ]. + rewriter addRule: rule + ] + compile: node [ <category: 'collecting entities'> - | method | + | rewritten method | - method := self defineMethod: node. + rewritten := self rewrite: node. + method := self defineMethod: rewritten. (classesToEmit includesKey: currentClass asClass) ifTrue: [ self addMethod: method toLoadedClass: currentClass ] ifFalse: [ self addMethod: method toExtensionClass: currentClass ] @@ -384,6 +406,7 @@ Options: matches REGEX -c, --category=-REGEX do not convert classes whose category matches REGEX + -r, --rule=''CODE->REPL'' look for CODE and replace it with REPL -o, --output OUTFILE concatenate multiple input files into a single converted output file @@ -392,7 +415,7 @@ Options: ' % {formats keys asSortedCollection fold: [ :a :b | a, ', ', b ]}. Smalltalk - arguments: '-h|--help --version -q|--quiet -v|-V|--verbose + arguments: '-h|--help --version -q|--quiet -v|-V|--verbose -r|--rule: -C|--class: -c|--category: -f|--format: -o|--output: -I|--image-file: --kernel-directory:' do: [ :opt :arg | @@ -418,6 +441,9 @@ Options: ObjectMemory quit: 1 ]. outFile := arg ]. + opt = 'rule' ifTrue: [ + converter addRule: arg ]. + opt = 'class' ifTrue: [ [ 'a' ~ arg ] on: Error do: [ :ex | helpString displayOn: stderr. _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Fri, 2007-07-13 at 19:12 +0200, Paolo Bonzini wrote:
> As in "gst-convert -r 'MessageSend->DirectedMessage' ff.st -" or also > "./gst -f ../scripts/Convert.st -r '`@x value->`@x foo' < ff.st". This is cool. I'll add for anyone thinking of how to use this one rewrite tip: '``@x value->``@x foo' would usually work better, thanks to the way pattern variable bindings are searched recursively. -- ;;; Stephen Compall ** http://scompall.nocandysw.com/blog ** "Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as well as fifth in line after kilo, mega, giga, and tera. -- Lee Gomes, performing every Wednesday in his tech column "Portals" on page B1 of The Wall Street Journal _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk signature.asc (196 bytes) Download Attachment |
Free forum by Nabble | Edit this page |