Hi,
Is there any port of Squeak's url classes? If not, I already filed it out from Squeak, but how do I import it into Dolphin? O:-) Thanks |
Fernando
> > Is there any port of Squeak's url classes? Nobody has answered yet, so probably not. >If not, I already > filed it out from Squeak, but how do I import it into Dolphin? O:-) Basically, four stages: a. Transform the filed out .st files so Dolphin can accept them - this is pretty easy. b. File in the transformed files - and probably get a shower of complaints in the Transcript about syntax errors. c. Modify the filed in code to remove the errors - this can be tedious, and represents most of the work. d. Test and verify that the methods work in Dolphin as in Squeak. For stage a., the main change needed is to translate the Squeak assignment operator (which appears as a left arrow in Squeak listings, but is an underscore when listed in Dolphin) into the Smalltalk standard := There may also be a problem with line terminator conventions - I have done this, but I can't remember whether Dolphin will accept the Squeak convention. This stage can be done manually with the editing facilities of the Dolphin workspace, or it only needs a trivial bit of code in a workspace to read in a file, make the changes and output the transformed code. Stage b. can be done in any of the Dolphin system tools - the Class Browser is probably the obvious one. Stage c. is the real fun. There are a few differences between Squeak and Dolphin syntax which turn up frequently. The one I found most often is with the #ifNotNil: message. In Squeak, the argument to this is a zero-argument block, while for Dolphin the block has to have one argument. It does not matter what argument you insert here, since by definition the code in the block does not refer to it. There is also a Squeak array-constructor using braces {}, which does not occur in Dolphin; usually this can become Array with: with: . . . . . Some of these differences could no doubt be removed in the editing in stage a. One issue you may come up against is how much of the Squeak system you want to import. I have not looked at all the Url classes, but if they refer to other parts of the Network categories you will have to decide whether to import those also or to replace the references with references to the Dolphin equivalent, where it exists. These projects can spread! Good luck Peter Kenny |
Peter, Fernando
> There > may also be a problem with line terminator conventions - I have done > this, but I can't remember whether Dolphin will accept the Squeak > convention. It's as well to convert the .st (or whatever) files to Window's line-ending conventions before loading them into Dolphin. I don't know what Squeak uses either, but it if's the Unix convention, then what happens is that Dolphin parses and compiles the code just fine, and it all looks OK in the browsers. It's only when you do something that depends on the IP maps (generated by the compiler to help the debugger) that you hit problems. Then you will find that the debugger doesn't display the currently executing expression correctly, and other tools (such as Ian's profiler) are also adversely affected. -- chris |
Fernando
"Chris Uppal" <[hidden email]> wrote... > Peter, Fernando > > > There > > may also be a problem with line terminator conventions - I have done > > this, but I can't remember whether Dolphin will accept the Squeak > > convention. > > It's as well to convert the .st (or whatever) files to Window's line-ending > conventions before loading them into Dolphin. I don't know what Squeak uses Chris is quite right. I have looked back at the code I used to feed Squeak file-outs into Dolphin. In fact the Squeak convention is to use carriage return alone as the line terminator (though looking at my code it seems as though I found some cr-lf combinations as well). The following code fragment, executed in a workspace, is what I used to convert the Squeak Html-Parser code for Dolphin; just change the file name in the first line for your case. The converted file has the name of the input file with an added 1 at the end. All left-arrow assignments are changed to := and any occurrences of cr not followed by lf have the lf inserted. fileName := 'c:\Documents and Settings\Peter\My Documents\Squeak\Html-Parser'. str := FileStream read: fileName,'.st'. out := FileStream open: fileName,'1.st' mode: #create. [str atEnd] whileFalse: [ch := str next. ch = $_ ifTrue: [out nextPutAll: ':='] ifFalse: [out nextPut: ch. (ch = 13 asCharacter ) ifTrue: [str peekFor: 10 asCharacter. out nextPut: 10 asCharacter]]]. str close. out close. It may not be elegant, but I have tested it and it works. Hope this helps. Peter Kenny |
On Wed, 25 May 2005 00:59:51 +0100, "Peter Kenny"
<[hidden email]> wrote: > >Chris is quite right. I have looked back at the code I used to feed Squeak >file-outs into Dolphin. In fact the Squeak convention is to use carriage >return alone as the line terminator (though looking at my code it seems as >though I found some cr-lf combinations as well). The following code >fragment, executed in a workspace, is what I used to convert the Squeak >Html-Parser code for Dolphin; just change the file name in the first line >for your case. The converted file has the name of the input file with an >added 1 at the end. All left-arrow assignments are changed to := and any >occurrences of cr not followed by lf have the lf inserted. [snip] > >It may not be elegant, but I have tested it and it works. Hope this helps. I just wrote a python script to do the conversion, and it seems to work fine: ---------- # -*- coding: latin1 -*- """ Wed May 25, 2005 14:06 Converts Squeak fileouts to a format Dolphin can understand: - Convert linefeeds from unix to windows - Convert _ into := - Convert the #ifNotNil: message (niladic in Squeak and monadic in Dolphin) """ from __future__ import nested_scopes import sys, re, os.path, string def usage(): print "Usage\n\tunSqueak file_name" print __doc__ def convert(): def lineFeeds(inp): lines = inp.splitlines() inp = string.join(lines, '\r\n') return inp def assignment(inp): p = re.compile('_', re.IGNORECASE) inp = p.sub(':=', inp) return inp def ifNotNil(inp): p = re.compile(r'(ifNotNil:\s*\[)') inp = p.sub(r'\g<1> :dummy | ', inp) return inp txt = open(sys.argv[1]).read() txt = lineFeeds(assignment(ifNotNil(txt))) path = os.path.splitext(sys.argv[1]) of = open(path[0] + '_dolphin' + path[1],'wb') of.write(txt) of.close() print 'File %s successfuly converted'%(path[0] + '_dolphin' + path[1]) # 'main' if __name__ == "__main__": if len(sys.argv) < 2 or len(sys.argv) > 2: usage() else: convert() ----------------------- Maybe I should have written it in St... |
"Fernando Rodriguez" wrote ...
> I just wrote a python script to do the conversion, and it seems to > work fine: [snip] > Maybe I should have written it in St... Fernando Two quick points: a. My code does not modify the #ifNotNil: syntax; if it did, I would have to use something more complicated than the simple character-by-character processing, and no doubt this would look messier than your regex approach. b. The comment in your script implies that the Squeak line terminator uses the Unix convention, but this AFAIK is not so. Unix uses lf only as line terminator, while Squeak uses cr only. If your python script works OK it can clearly cope with the Squeak convention, while for example Dolphin SequencedStream>>nextLine would not. Peter |
Free forum by Nabble | Edit this page |