Re: [9fans] keyboard map for a czech keyboard
ok. I tried what I said and it really works... R 2009/3/11 Rudolf Sykora : > Hello, > > I'd like to teach my plan9 read my Czech keyboard. > But I don't know exactly what I have to change. > I wonder if it's enough to modify e.g. /sys/lib/kbmap/us, save it to > e.g. /sys/lib/kbmap/qwerty_cz and then use kbmap(1) command to switch > to it. > If so, I'd need to know more exactly what the 1st field (table number) > in the keyboards' files means, and also, perhaps, how to get the > scancode of a certain key. > > Thank you > Ruda >
[9fans] plan9 for calculations
Hello everybody, I noticed there are some thoughts about using plan9 on supercomputers. For me supercomputers are usually used to do some heavy calculations. And this leads me to a question. What software is then used for programming these calculations? (I mean e.g. linear algebra, i.e. matrix, calculations.) Where can one read about that? More, it also leads me to a (perhaps) simpler question. What is the situations with ordinary machines? Untill now I have used several libraries in linux, all of them somehow based on lapack. I used C language (c-lapack), python (numpy), and now I do some programming in Fortran (Intel MKL). From my experience I would say: writing programs in C is a nightmare (for me next to no-go again), using python with numpy is a breeze, using Fortran (95) is sort of fine. C and Fortran run faster than python, but the factor, when I played with it, surprised me to be sth. like 3x (expecting a worse result). Now I've been thinking, If I were to write sth. in plan9, what would be the way to try? Recently I heard about eigen2 library, which seems to be nice (high performance, few dependencies), but for C++... Thank you for any suggestion Ruda PS.: It could be that plan9, being more a os-research system than anything else, is simply no suitable for such a use (there are no plotting libraries, other utilities). Perhaps it's not a good idea at all to try to use plan9 like that because it would be more work than anything. Maybe using linux for such things with all its tools is just ok. If you share this idea, just say it too, please.
Re: [9fans] Using the Acme Editor
Hello after some time I crossed this matter again... /old/c/new/ doesn't scroll to the dot where the change happens in neither sam nor acme. My feeling is that it should. (Should there be any reason for different behaviour compared to the situation when the command is split as /old/ followed by c/new/; this way scrolling happens...?) Thanks Ruda 2008/10/24 Russ Cox : > It is true that the /old/c/new/ doesn't scroll, which is > unfortunate. I haven't looked into why or whether it is > reasonable to change. > > Russ
[9fans] double click selects a word
Hello all is there any good reason for a double click (in rio, sam, acme, ...) to select a word (probably) defined by sth. like /[a-zA-Z0-9_]+/ and not sth. white-space delimited instead? Double clicking e.g. on 'text.txt' only selects 'text' or 'txt', while one usually wants the whole. The same with absolute paths like '/usr/ruda/lib/profile', etc. In linux a double-click usually highlights the whole and usually this is what I want. Would changing this behaviour break anything? Thanks Ruda
Re: [9fans] double click selects a word
ok then. :) r > one man's `usually' is another man's `never'. > it's one reason i use 9term on linux. > we probably both say ``what were they thinking??'' about > contrary effects.
[9fans] window's content clearing
Hello, Imagine I have a rio window with a long history, i.e. lots of text have been entered and the scroll bar is just a tiny box. And I'd like to clear everything, so that only the last prompt remains. I know I can clear some portions with a mouse. But that is often tedious. Is there any nice way how to achieve the goal? /dev/text is readonly... Thanks ruda
Re: [9fans] double click selects a word
2009/4/7 Francisco J Ballesteros : > In omero double click does the same, and triple is more hungry. You could > try that modifying your local system That's a good idea. I'll try. thanks r
Re: [9fans] window's content clearing
2009/4/8 hugo rivera : > In acme you can do something like > Edit ,$-1d > but I don't know how to deal with a terminal outside acme. Well, this is true. In an editor you have the wings... [Btw., also reading a man page is somewhat easier in an editor for me since I can search in the text then, which can't be done in a rio window itself (thus one must search only with one's eyes).] ruda
[9fans] noweb and literal programming
Hello, I've been thinking about 'well documented programs' and come across the 'noweb' program. Do you have any experience with literal programming and, particularly, noweb? (I noticed at least rsc seems to have played with it back in the year 2000. He programmed some scripts to use the system in Plan9...) Thanks Ruda
Re: [9fans] noweb and literal programming
> Just curious... what's the relation to Cweb and Ctangle (the ones Knuth uses)? > > From what I've heard of those (even from Knuth himself) is that > they're too ugly to use very much, and fits well with Knuth's style, > which is mostly the "giant blob of code" style. As far as I can tell, cweb (ctangle, cweave) is the original Knuth's web language adjusted for the C language (the very original was written to work with pascal). These 'ful-featured' webs didn't succeed, people found it somewhat complicated. In contrast, noweb tried to be simpler, with no tight connection to the language used (any language can be used) and no tight connection to the formatter. It has less features but this can be considered an advantage. Ruda
[9fans] web server
Hello, I've been wondering (and not reading much)... If I'd like to use plan9 as a www server, is there anything ready? How difficult would it be to use rails or merb in plan9? Is it feasible? thanks ruda
Re: [9fans] web server
> >> How difficult would it be to use rails or merb in plan9? Is it feasible? > > Very difficult. No, not feasible. You would have to port Ruby. And > then possibly rails, too. Plan 9 isn't UNIX, or UNIX-like, or POSIX > (or POSIX-like). APE helps with some stuff, but not all the way. I thought I'd seen a ruby port in the contrib list... And if merb were just written (portably) in ruby, then, I thought, it wouldn't have to be that difficult... ruda
Re: [9fans] web server
2009/4/17 maht : > How difficult would it be to use rails or merb in plan9? Is it feasible? > > Not Rails or merb or anything non Plan 9 but a few of us are building an rc > shell based system that works anywhere CGI and Plan 9 / plan9port is > available. > > http://werc.cat-v.org/ Yes, I've noticed the existence of werc. I'll take a look at that, sure. However, I have just discovered 'seaside' web framework and am looking at it now. It seems to be pretty interesting. Based on smalltalk and using a different (and to me appealing) philosophy, other than MCV. Thanks ruda
Re: [9fans] web server
> Writing the core of a blog engine in three lines of rc is hard to > beat, plus you get the benefit of being able to manipulate and manage > all your data using the tools any self respecting Unix user loves. > > uriel well, I haven't thought about it deeply yet, but what I guess could be a problem with your approach is that many features would have to be somehow implemented first so that it all be useable. I mean e.g. ajax style of page content refresh, session management, perhaps POST method too. ruda
Re: [9fans] web server
2009/4/17 maht : > >> well, I haven't thought about it deeply yet, but what I guess could be >> a problem with your approach is that many features would have to be >> somehow implemented first so that it all be useable. I mean e.g. ajax >> style of page content refresh, session management, perhaps POST method >> too. >> >> ruda >> > > never say it is impossible to man busy doing it have I ? r
[9fans] missing ed's line numbering in sam -d
Hello, when using 'sam -d' to remotely edit files I really miss the option to print line numbers along with lines, like ed's e.g. '1,10n'. Is there anything like that? Why not? Thanks Ruda
[9fans] squeak (smalltalk) + seaside in plan9
Hello everyone, just a question: Playing with squeak smalltalk implementation I've wondered if there could be squeak (with all its ready environment) ever running under plan9. Has anybody thought about that? ... I've found seaside (web devel. framework) rather interesting. It's more like programming an ordinary application than any other framework I've seen so far. (nothing against webrc :) ) Thanks Ruda
[9fans] ssh v2, using a remote linux server
Hello everyone, 2 questions... 1) The linux servers around me reject ssh v1 protocol by default, only seem to accept v2. The version commonly available in plan9 seems to be v1. As long as I connect to my own machine, where I allowed v1 connection, no problem. But is there any working v2 client? I found some v2 client under contrib/john, which I compiled successfuly in plan9 (but failed in 9vx...). I can connect with this to my linux box, however, I somehow cannot connect to other (for me more important) computers. Either I see really nothing to happen, or I see 'connect 0' and that's all. Further, this ssh2 doesn't feature the '-r' option, which I use to not see 'cr's when connected. 2) More generally: I use a powerful linux machine for doing some havier calculations. I have no possibility of changing anything serious on that computer (like that it could serve ssh v1), I am just an ordinary user. So far I usually do the programming on my 'local' linux computer using p9p versions of acme & rc (sometimes the linux's gvim), run some small manageable tests on this local computer, then make a copy to the remote machine, recompile it there (fortran) using a textual ssh connection, and finally run it there. This brings along a /number of complications... It'd be nicer if I could use the remote linux machine in a way a plan9 cpu server is used. Is this possible? Thanks, Ruda
[9fans] problems with redirection in rc
Hello everyone! To get some useful information from a file I write: ; for (i in *_r) @{cd $i; echo -n $i^' '; grep total otdit | grep -v na} to get lines from the 'otdit' files in *_r subdirectories with the word 'total' on them, but no 'na' on them. This works to my liking and produces sth. like 10_rtotal: 9.4105E-01 11_rtotal: 9.3897E-01 12_rtotal: 9.3685E-01 13_rtotal: 9.3446E-01 14_rtotal: 9.3180E-01 15_rtotal: 9.2890E-01 16_rtotal: 9.2589E-01 17_rtotal: 9.2299E-01 18_rtotal: 9.1860E-01 ... 9_r total: 9.4317E-01 Ok, now I wanted to save this, so I naively appended '> res'. But then the contents of 'res' was only the last line: 9_r total: 9.4317E-01 Ok, so I thought '>> res' should be used instead. But then I got sth. like ];/home/sykora/CALC/doing/tests/9_r/-xeon49_r total: 9.4317E-01 ];/home/sykora/CALC/doing/tests/10_r/-xeon410_r total: 9.4105E-01 ];/home/sykora/CALC/doing/tests/11_r/-xeon411_r total: 9.3897E-01 ];/home/sykora/CALC/doing/tests/12_r/-xeon412_r total: 9.3685E-01 ];/home/sykora/CALC/doing/tests/13_r/-xeon413_r total: 9.3446E-01 ];/home/sykora/CALC/doing/tests/14_r/-xeon414_r total: 9.3180E-01 ];/home/sykora/CALC/doing/tests/15_r/-xeon415_r total: 9.2890E-01 ];/home/sykora/CALC/doing/tests/16_r/-xeon416_r total: 9.2589E-01 , which quite surprised me... Can you tell me why this happens? I am running p9p. Thanks Ruda
Re: [9fans] problems with redirection in rc
2009/5/5 Anthony Sorace > what's surprising is that this behavior changed based on *only* > changing the > to a >>. you're sure you didn't change placement as > well? i'd have expected your output file in the > case to match the > results for the last _r label from the output file in the >> case. well, yes. The last line of the >> output is the same as the single line got from >. I didn't write it fully in my post, sorry. ruda
Re: [9fans] problems with redirection in rc
2009/5/5 roger peppe : > {for (i in *_r) @{cd $i; echo -n $i^' '; grep total otdit | grep -v na}} > > res > with this I get the same as with for (i in *_r) @{cd $i; echo -n $i^' '; grep total otdit | grep -v na} >> res which is now reasonable, having read R. Cox' post. Thanks ruda
Re: [9fans] problems with redirection in rc
2009/5/5 Anthony Sorace : > // ];/home/sykora/CALC/doing/tests/10_r/-xeon4 10_r ... > > i think these are escape sequences generated by a defined 'cd' > function containing awd. do "fn cd" before you run this to undefine > the function and this should go away. true. thanks ruda
Re: [9fans] problems with redirection in rc
> You've got the cd implementation from label(1) loaded. > In interactive mode, it echos escape codes that are > supposed to update the label in your terminal window. > Instead it wrote them to the redirected file. > > I changed label to write to /dev/tty explicitly, which should > avoid this problem. > > Russ So if I understand right, this is/was a plan9port related feature, right? thanks ruda
[9fans] rc - no continue, next in a loop
Hello everyone, I just realized there are no 'continue' and 'next' commands in rc. Is there any way to e.g. quit the loop when one wants? Thanks Ruda
[9fans] sources down?
Hello when I try '9fs sources' I get a timeout establishing connection... (all day today) I guess it's not my problem, or is it? Thanks Ruda (why does this happen SO OFTEN?)
Re: [9fans] sources down?
>> (why does this happen SO OFTEN?) > > warning: complaining about something you get for free is > counter-productive. Unless, of course, you are also offering to help > in some way. > > ron well, maybe. Maybe not. In order I be of any help I need to know why the hell this happens, first. I know next to nothing about how the whole system of sources works, still I can help if I know how. But I do not remember anybody saying: 'hey guys, we have this and this problem that causes the sources are down every now and then.' Yet we see it happening. You may think it's a question of money (you mentioned it is for free). It's not. There are many projects out, totally for free, but reliable. When I do something it must be reliable, or it's worth criticizing. Ruda
Re: [9fans] sources down?
> While not having direct knowledge of what caused the current outage, I > can say that such outages are rarely caused by Plan 9 or the hardware > on which its running. Ok. So what caused the other outrages in the recent past? (I may give at least one other date, on which I even asked the same question to the list; according to you this situation is very rare, according to what I have lived through it happens annoyingly often.) > You see, right now, the Plan 9 machine room > (and the doom room, and much of the offices/lab space around it) are > being repurposed. There are exactly (I think exactly) two people who > turn the lights back on every time something like this happens, and > they get no accolades from the company for providing this free service > to the community -- in fact, their life would be significantly better > if they just left the lights off. So please, keep antagonizing them > so that they shut this nice free service down -- you'll make their > lives considerably more simple and they can get back to doing real > work. First, I am grateful, somebody once designed plan 9. It is a well crafted system. Second, if the system is to be hosted as it is now, it is a shame. Make statistics. I don't care who helps, as long as it doesn't work. > As ron said, verifying that sources is down on the list (or IRC or > whatever) and then sending a polite note to geoff and/or jmk to let > them know is fine (since they use this infrastructure as their primary > work environment, these problems often cause them more pain than us). I do not know who takes care of the sources. I do not know even there is somebody called geoff. Thus writing that we should appeal to him is a nonsense. Moreover, there is not that many posts here, nobody gets hurt if one writes 'sources are down' here. If it were true and it all worked as it should, you wouldn't have here anything, by the way. Writing to the list also documents that something is wrong. And that's a good thing. > Anything beyond that is ridiculous. Also as Ron said, a far more > constructive approach is mirroring (which many already do), and an > even better idea would be for someone to code up a nice little layer > that directs your sources request to the closest available server. So is there a need, suddenly? Isn't it good to discuss it here? What about saying, hey we need it. Who can do it? I guessed this mailing list IS the right place. I am a physicist. I can recognize I like the system in a way. I can't do much about it yet. It's enough for me, that I must struggle with topics like: I need python, there seem too many of them somehow, how should I install it, which one? what is necessary?, why hasn't somebody write a few lines about it?, oh I can't use ssh2, oh probably usb won't work, oh, let's forget about wireless... Encountering problems even when downloading sources is just getting to the breaking point to say: that's enough, let's just stick to something that has some problems, but works somehow (bsd, linux, whatever...; or plan9port, glendix). And that's a pity, because although one knows he would like to follow some way, he is forced to follow a different one. R
Re: [9fans] sources down?
> nobody's saying anything, so i will: a kfs system will be left in an > "allowed" state if all the mirrors fail. well, knowing little, having come late, perhaps, I do not understand... Thanks Ruda
[9fans] python reloaded
Hello, I wanted to install python. From /n/sources/contrib/bichued/python I downloaded python-2.5.1-ape.tgz python-2.5.1-sys.tgz. I untared the former in my home directory. I untared the latter in / (I got /sys/python created...) --- this I read in README.Plan9 file in python-2.5.1-ape.tgz. Also in README.Plan9 file in python-2.5.1-ape.tgz I read I should use two patches /n/sources/patch/applied/ape-ftruncate /n/sources/patch/ape-chmod-dirbit. Should I just copy the files from there (but which, actually, I see e.g. chmod.c, chmod.c.orig, chmod.c.new) to the appropriate directory (which I can read from the 'files' file), and recompile? Can the path/apply command be used locally? Also, why are there two files, python-2.5.1-ape.tgz and python-2.5.1-sys.tgz? (When a new version of python, e.g. 2.6, is wanted, what must be done?) Also, again in README.Plan9 there is a list of recommended contrib/install packages, but when I run them in the given order, there are places where a package complains about dependency, to be solved by another package which follows. Thus should it be run with contrib/install -f? Thanks Ruda
[9fans] persuade contrib/install to work
Hello, since I somehow still can't connect to the 'central sources' and want to make some progress, I tried to follow some of your recent advices. Instead of '9fs sources' I do 9fs sources.lsub.org cd /n bind sources.lsub.org/sources sources so now it seems I have the state similar to after just '9fs sources'. Now I'd like to do e.g. contrib/install fgb/xml2 but I get srv: timeout establishing connection to tcp!sources.cs.bell-labs.com!9fs so as if contrib still wants to connect to the central sources... How can I persuade contrib/install to use what I've already had under /n/sources? Thanks Ruda
Re: [9fans] new usb implementation
Thanks a lot! Ruda 2009/5/26 Devon H. O'Dell : > 2009/5/26 : >> I've just pushed out to sources a new USB implementation, courtesy of >> nemo, who debugged and repaired our old UHCI and OHCI drivers, wrote a >> new EHCI driver for USB 2, converted the user-mode drivers in /bin/usb >> and tested it all, among other things. Thank you, nemo. >> >> I've updated on sources at least /386/9*load* (though they contain no >> USB code), /386/9pc*, kernel sources, manual pages and a few scripts >> in /rc/bin. Tomorrow's CD image should incorporate all this. >> >> devusb has a new interface, so it is named #u, to distinguish it from >> the old one, #U. If usbd is compiled into /boot, /boot/boot will run >> usbd at start up, thus permitting the use of USB keyboards, mice, >> disks, etc. at boot time. > > Sweet! Thanks, guys! > >
Re: [9fans] persuade contrib/install to work
OK. So I changed the line from /dist/replica/contrib:7: fn servermount { 9fs sources } to /dist/replica/contrib:7: fn servermount { test -d /n/sources/plan9 || 9fs sources } and it seems to work as wanted... thanks to all Ruda 2009/5/27 Federico G. Benavento : >> I think it would be better for contrib to do something >> like test -d /n/sources/plan9 || 9fs sources >> > yes, it makes sense, though this change will only affect > the packages installed after the changes was applied > >> 9fs sources >> should probably mount sources, always. >> > yep > > > > -- > Federico G. Benavento > >
[9fans] limiting 'history' in a rio window
Hello, when a rio window with 'rc' running inside is used for entering commands it happens, after some time, that the amount of text is excessively high. If the text in the window could be edited (I mean not manually), then from time to time I could run some program that would leave only the last say 100 lines in the window. But it seems it can't be, and I even don't know why... What can be done, why can't the file be edited? (so far I create a new window with 'window -m' and close the old one; which isn't that nice) Thanks Ruda
[9fans] acme --- undo/redo in a win window
Hello, it is somehow unclear to me, what happens in a 'win' window when I 2-click 'Undo' or 'Redo' (I write it somewhere manually). Are some commands processed again? (I happened to delete some text from the window and thus had the idea to write 'Undo' and 2-click on it; sth. happened, but I am puzzled from it.) Thanks Ruda
Re: [9fans] acme --- undo/redo in a win window
Ok. It works so. Thanks Ruda > If as a result of those operations, new text appears > after the cursor output point, that text is sent to the > shell running in the window (or whatever is reading > from the console). > > Russ
[9fans] acme: dirty state after 1-2, 1-3 click in a tag line
Hello, I've noticed two strange things about acme: 1) when I snarf the name (or a part of it) of a file with a mouse (in the tag line) using 1-2, 1-3 mouse chord, the file is marked dirty. (I think it should not.) 2) i) when I open a win window, 'win' appears in the topmost tag line (if you open 2 such windows, there will be 2 'win's) (Why?) ii) when I Dump the state and there is a win window, after Exiting and starting 'acme -l thedumpfile' there is an extra 'win' text added to the topmost line. Could somebody comment on these, please? Is this behaviour desired for any reason? Thanks Ruda
Re: [9fans] acme: dirty state after 1-2, 1-3 click in a tag line
> Probably you have already noticed it, but if the dirty mark annoys you > can always select with 1 and use Snarf. > - yiyus || JGL . yes, I have, thanks anyway :) r
[9fans] simple question: multiple rename
Hello, I realized I cannot come up with a simple solution for the following. I want to rename all the files whose names end with _g_b to just _g, e.g. hello_g_b should be renamed to hello_g. I simply don't know an easy way. [the opposite way is simple: for(i in *_g) mv $i $i^_b ] I only think about so complicated ways like for(i in *_g_b) { s = `{sam -d <[2] /dev/null 1s/(.+)_g/\1 p EOF } mv $i $s } which describes my idea, but doesn't work, actually. (btw. how can one correct it?) Thanks Ruda
Re: [9fans] simple question: multiple rename
> sed is your friend: > > s=`{ echo $i | sed -e 's/_g_b/_g/' } > > > Martin Oh yes, that's it. Thanks Ruda
Re: [9fans] simple question: multiple rename
Hello, Still wonder, what's the right way to make the following work: This is ok: sam -d <[2] /dev/null 1s/(.+)_g/\1 p EOF but now I want it all be inside `{}, like s = `{sam -d <[2] /dev/null 1s/(.+)_g/\1 p EOF } which doesn't work. I tried several ways, but unsuccessfully. Anyway, I guess it should be easy... Thanks Ruda
Re: [9fans] simple question: multiple rename
> should be written as: > s = `{sam -d <[2] /dev/null} >... >EOF > > Hope that helps, >Martin OK, now I see. The } was at the wrong place... Thanks Martin thanks Russ, too. Ruda
[9fans] acme: send dot to the stdin of a more complicated command
Hello everyone, when I want to process a dot's contents in acme I can use the '>' syntax, e.g. have > awk '{print}' in a window, select it, and then 2-1 click on Edit in the window with my dot. That works. But what shall I do when the awk script is more complicated, in the simplest case like > awk ' {print} ' When I select it all and do the same as before, it doesn't work (probably because of the new lines?)... Thanks Ruda
Re: [9fans] acme: send dot to the stdin of a more complicated command
> Put the awk code into a file and execute '> awk -f foo' in acme. well, I hoped this would be the last way... It makes me create files I don't actually need. Is it the newlines that causes troubles? Thanks Ruda
Re: [9fans] acme: send dot to the stdin of a more complicated command
> remember, this is plan9 and everything is a file. chances are your > "script" is already available in some filesystem and you don't need to > write it out:: create a new window inside acme, type your awk script > and then issue ">awk -f /mnt/wsys/X/body" where X is the ID of your > window. well, though an inspiring idea, it doesn't sound to be much practical: 1) I usually have a special window in which I have many commands. I then select the one needed and chord it to the appropriate window (i.e. I don't use the whole contents of a window). 2) sometimes I have more such windows. The very question for me now is: why it behaves how it behaves, i.e why newlines (if it's them) are problematic. Ruda
Re: [9fans] acme: send dot to the stdin of a more complicated command
> and you want somebody do look through the code and figure it out for you? not really. I wanted to know whether 1) somebody thought about it (knowing the system has been around for some time I'd expect somebody must have had the same problem) 2) there is any good reason why it behaves so. Ruda
Re: [9fans] acme: send dot to the stdin of a more complicated command
> See http://swtch.com/~rsc/acme-Run.png for an illustration. > > Russ Thank you much! This is what I need and now I see how it can be achieved... :) Ruda
[9fans] acme: 2-1chord on Edit in a 'win window' tag doesn't work
Hello everyone, might be I am doing something wrong, but this seems to me like a bug... In some acme window I have a command, e.g simply s/f/g/, I select it with a mouse and 2-1 chord it on the Edit command in a tag line of a window in which there is win running and also some text (for us e.g. abcdefgh) is selected. Nothing happens. Only when the s/f/g/ is copied in the tag line and the whole (together with the Edit) is 2-selected, the command is executed, i.e. abcdefgh -> abcdeggh. This only happens for a win window, ordinary text window is ok as well as a directory window. Thanks for comments, Ruda
Re: [9fans] acme: 2-1chord on Edit in a 'win window' tag doesn't work
> This is a design bug in acme. > Russ Ok, I understand. Thanks for the explanation! Ruda
[9fans] synchronization of time, setting time
Hello everyone, 1) If I want to set the hardware (on-board) clock by hand, how can I? 2) If I want to synchronize the hardware time with a ntp server (once / periodically), how can I? 3) If I run the 'timesync -n [ntp server]' command, how is the frequency of synchronization determined? If I run it without any more special parameters, it seems to synchronize every minute (from the log, obtained with -l). That is, I think, unnecessarily too often. Thanks Ruda
Re: [9fans] Sam commands in acme
2009/6/26 hugo rivera : > I tested the command you suggested (,x/\/\*/.,/\*\//) and it works as > I wanted, thanks. But there's something I still don't understand and > is the meaning of that comma in there. As far as I know, the comma is > a mark that delimits the addresses that acme understands, but I do > not know how a comma is interpreted inside a regexp. I'd really > appreciate if you could clarify this matter to me. I think, the comma is not in a regexp. The 'x' command syntax is x/regexp/command and the comma is a part of the command: choose the area from the dot (included) to the '*/' Ruda
Re: [9fans] Auto Indenting in Acme
I think, if you write 'Indent on' somewhere in a window (e.g. the tag line) and execute it, indentation will be on for the given window; if you use 'Indent On' instead, it sould be set for all windows. Further, I guess off/Off should work the opposite way. The man page has it. Ruda 2009/7/3 Aaron W. Hsu : > Hello Everyone, > > In Acme SAC auto-indenting for files is enabled by default. Is there some > setting or way of changing settings that allows me to activate > auto-indenting in plan9port's Acme editor?
Re: [9fans] Auto Indenting in Acme
see also 'acme -a' > auto-indenting in plan9port's Acme editor?
[9fans] troff and ps related
Hello everyone, can anybody tell me why whatever .ps about troff/eqn I print has misplaced lines? E.g. quite generally, lines that make up tables either don't touch, or stick out somewhere... Also, should .BX something make a nice box around 'something' or not? Anywhere I look I see the top line be slightly above the side lines, it doesn't touch them. Further, is there a way to view .ps files in a graceful way? Neither proof nor page quite work for me. There is no comparison to gv in linux at all, imho. It can't zoom well, if I manage to zoom in page (often it takes infinitely long ---again compared to gv---, often it ends with not enough memory; I also quite don't understand how the zoom should work) it is not very nice, very unclear. Thanks for comments Ruda
Re: [9fans] troff and ps related
2009/7/8 Russ Cox : > On Wed, Jul 8, 2009 at 4:49 AM, Rudolf Sykora wrote: >> can anybody tell me why whatever .ps about troff/eqn I print has >> misplaced lines? >> E.g. quite generally, lines that make up tables either don't touch, or >> stick out somewhere... > > this is because tbl is using characters to draw lines. > it's not a great strategy. Does it mean that I can't do much about it? That it will probably be always like this? > >> Also, should >> .BX something >> make a nice box around 'something' or not? Anywhere I look I see the >> top line be slightly above the side lines, it doesn't touch them. > > maybe should be doesn't. there's a reason no one uses it. > even if it worked, boxes around words are pretty heavy weight. Ok. This then leads me to a question... I've been using TeX to typeset my texts. I've never quite liked it, all those backslashes. A few days ago I read the articles about eqn and was surprised that it is quite nice. That I can read my formulas when written (quite difficult in TeX) and that there are some natural rules that simplify the notation (like that spaces are the delimiters, etc; one doesn't have to bracket everything). I've understood that the language is not so powerful as TeX, but it is at the same time much simpler (source code). Further, somebody (see Heirloom tools) changed troff so that it can use all types of current fonts, can do microtypography, format whole paragraphs if wanted, can read hyphenation rules formely designed for Tex. These changes (especially fonts, hyphanation), if propagated to plan9 troff, could be of some, not negligible, value. But now (from the answers to my questions about boxes, tables) I am becoming less enthusiastic. Can anybody comment on this? Do you think that troff is really dead? Thanks Ruda
Re: [9fans] troff and ps related
2009/7/8 Russ Cox : > I assume you have a non-Plan 9 machine to play with. > It's worth trying Heirloom troff there to see if the boxes > are done better. They probably are. as far as I see, they are not better. > I need to fall back to the Plan 9 troff, because the low-level > details seem to differ between the two. so, unlike TeX, different troffs produce different outputs, right? > Honestly the box drawing has never really bothered me. > I don't draw boxes around things because it's too noisy > for my tastes anyway. it's not only boxes; it's tables, as I mentioned, as well. Thanks Ruda
[9fans] troff: references
Hello, is there anything ready for troff/eqn that could help me with 1) automatic equation numbering with possible setting a label to an equation by means of which one could forward/backward reference the equation? 2) setting a label somewhere in the text, so one can reference it and obtain e.g. a page on which the label is? Thanks Ruda
[9fans] p9p acme freezes when ctrl-f inside its mounted directory
Hello, I noticed that when running acme in plan9port and having its directories mounted say on /mnt/acme, then if I try from within a win window in the acme to auto-complete a directory name---I am in /mnt, I type 'a' and hit the 'insert' key or ctrl-f, or I am anywhere inside the acme filesystem---the program freezes (though, if I write it myself, I can cd to the acme directory). Am I doing sth wrong or it shouldn't do so? Thanks Ruda
Re: [9fans] p9p acme freezes when ctrl-f inside its mounted directory
2009/8/5 Russ Cox : > On Tue, Aug 4, 2009 at 10:33 AM, Rudolf Sykora wrote: >> I noticed that when running acme in plan9port and having its >> directories mounted say on /mnt/acme, then if I try from within a win >> window in the acme to auto-complete a directory name---I am in /mnt, I >> type 'a' and hit the 'insert' key or ctrl-f, or I am anywhere inside >> the acme filesystem---the program freezes (though, if I write it >> myself, I can cd to the acme directory). > > The problem is that acme is basically a single > operating system thread, and that operating system > thread is trying to look in /mnt/acme. To serve that > request, the kernel has posted a FUSE message to > acme to handle, which acme will get around to just as > soon as the system call in /mnt/acme finishes. > Deadlock. > > This is not a problem on Plan 9 because acme does > not put itself in its own name space. On Linux, where > there is just one big name space, more care is necessary > (and not implemented). > > Russ > > Thanks for the explanation! R
[9fans] ssh port specification
Hello everyone, I want to connect to a ssh server (v1) with the plan 9 ssh command. However, the server runs on a non-standard port (not 22). I can't figure out, how to specify the port number for the ssh command. Thanks... Ruda
Re: [9fans] ssh port specification
Thanks a lot... It works. ... I always forget that that leading tcp! is really necessary :) (even though I know why, on second thought) Ruda 2009/8/9 Lyndon Nerenberg : >> Hello everyone, >> I want to connect to a ssh server (v1) with the plan 9 ssh command. >> However, the server runs on a non-standard port (not 22). >> I can't figure out, how to specify the port number for the ssh command. > > ssh u...@net!host!port > >
Re: [9fans] Using Guide Files
Also check the Run script we discussed earlier in this forum. Could be of help... Ruda 2009/8/10 Aaron W. Hsu : > Hello, > > When using guide files, let's say I have some Edit command or the like that > I run often on certain types of files. So I have the guide file open, and I > can copy the command over to the tag line of the file I want to edit, but it > would be faster if I could just run the command in the context of some > arbitrary window. Is this possible? If not, does one normally just copy over > text to the tag line when it needs to be used? > > Aaron W. Hsu
Re: [9fans] Using Guide Files
A few words pertaining one of your points. 2009/8/10 Jason Catena : > For example, I often run "|fmt -w 72" to justify a paragraph in a text > file. With wily, I can highlight text in any window, and justify the > text from one copy of the command stored in any guide file. With > acme, I can't apply this command to highlighted text until I copy the > command to the particular window (tag or body) that needs it. I can't > even use it from a guide file in the current directory: if I sweep > some text in a window, then apply that text to a pipe command in a > guide file in the current directory, the pipe command runs against its > own line in the guide file. I can have that '|fmt -w 72' anywhere in any window, but other than where my text is. I ensure I have 'Edit' in the tag line of the text window. I highlight the text I want be formatted. I go to the window with the command, |fmt -w 72. I highlight that. I go back to the Edit in the text's window. I 2-1 chord on that Edit. And it does do, what you want. Or not? Where is the trouble? Ruda
Re: [9fans] Using Guide Files
2009/8/10 Jason Catena : > And so it does. I assumed I could only use Edit in conjunction with > sam commands, but apparently Edit (or at least its author) is smarter > than that. Well, I'd say, that |... thing still _is_ a sam command..., only delivered to the Edit command via the chord now. (Although, in acme this one (like >, <) can be used without the Edit command) > I assume Run works similarly? That is, I can put Run in a directory's > tag, highlight a filename in that directory, then highlight a command > and apply it to Run with 2-1 to run the command on the file? I don't know how well the Run script (note that it is _not_ a part of acme; it was designed by Russ Cox just a couple of months ago, thus you must really get it first in order to use it) can be used in directory listing windows. Otherwise I use it in the much same way as the Edit command. While Edit understands sam commands, Run can run any series of commands, like multiline awk script, for example. Find it in the forum. Ruda
[9fans] undelete a file
Hello everyone, I have, by mistake, deleted a file. I use fossil. I don't know much about how fossil works... Can I do something to get it back? I tried yesterday, but it says /n/dump/2009 doesn't exist. I looked in /n/dump and there is nothing. I tried '9fs dump' but even after that /n/dump/ is empty. Thanks Ruda
[9fans] ugly eqn/troff result
Hello everyone Why do I get an ugly result when trying to typeset (in file 'a') .EQ a + left ( A + B right ) .EN with eqn a | troff | dpost -f > a.ps? I am getting an equation in which the 'A+B' is significantly shifted downwards inside the (), so that the two pluses just don't line up... Thanks Ruda P.S.: what I actually wanted to typeset is 'something + ((A+B) sup -1)', but the same happens...
Re: [9fans] undelete a file
... Do I need venti to be able to use the dump feature? Thanks Ruda
Re: [9fans] undelete a file
2009/8/13 Anthony Sorace : > you need venti for dumps, but not snapshots. do "9fs snap" and then > see if there's anything in /n/snap. these are ephemeral, not archival. > > i don't believe fossil ships with these turned on by default, so > you're likely SOL, sorry. Well, after 9fs snap /n/snap is empty... ... well I haven't lost anything life-essential > > assuming my memory from my last install is correct, and it's not > installing with snapshots (and, if venti-backed, with dumps on), is > there any particular reason for that? Where can I read how to turn the snapshots on? (Actually, I once read fossil(4) and had the feeling that these simply do happen and once there is no space some of them are moved to venti or deleted if there is no venti. With this on mind I then decided not to use venti during installation. Now I see the snapshots have to be turned on...) Thanks anyway Ruda
[9fans] acme column Paste, Cut, Snarf commands
Hello, in a newbie-guide.pdf www.quanstro.net/newbie-guide.pdf I read: Column Menu: Snarf --- Copy the selected text into the snarf buffer (from anywhere in the column). For me it doesn't work like that. For me _all_ column menu Snarf (Past, Cut) commands are equivalent irrespectively of the column they are in. Any Snarf just copies text from any last used window into the snarf buffer. Am I right? Thanks Ruda
Re: [9fans] ugly eqn/troff result
One more trial... Really nobody uses 'eqn' these days?... Thanks Ruda 2009/8/13 Rudolf Sykora : > Hello everyone > > Why do I get an ugly result when trying to typeset (in file 'a') > > .EQ > a + left ( A + B right ) > .EN > > with > eqn a | troff | dpost -f > a.ps? > > I am getting an equation in which the 'A+B' is significantly shifted > downwards inside the (), so that the two pluses just don't line up... > > Thanks > Ruda > > P.S.: what I actually wanted to typeset is 'something + ((A+B) sup > -1)', but the same happens... >
Re: [9fans] ugly eqn/troff result
> i do see that the +s don't line up, but only by 1 pixel. > why do you think they should? i would think that the > centerline of the left ( right ) business should line up > with the centerline of a +. but that's an uneducated > guess. can you point to a reference that says eqn > behaves as you expect? > > - erik I don't think I can... The eqn behaviour just stuck my eyes (for me it seems to be more than a 1-pixel shift). I have used TeX for my work all my life, which just typesets it well. On the other hand I like the succint eqn notation much more... Thanks Ruda
[9fans] problems when hwaccel off or in inferno
Hello everyone, I'd like to ask whether anyone encountered problems when one turns off the hardware acceleration with cat hwaccel off > /dev/vgactl When I do it, my mouse leaves some garbage at some points, or, e.g. I can't nicely select text with the mouse---there are some pieces missing. I found similar problems first in Inferno on plan9 (with hwaccel on in underlying plan9). When I run it (wm/wm) and e.g. try to close some window, a small rectangle is sometimes left over after mouse. When I turn the acceleration off in plan9, I see such problems even in plan9 itself. Has anyone any comments on this? (I'd like to try inferno, but this is annoying.) I play with HP Omnibook XE3 (some people wanted to chuck it out),I believe there is an Intel 830M integrated graphic card. cat /dev/vgactl says I use vesa. Thanks Ruda
Re: [9fans] nice quote
>> Considering that Plan 9 has only two inherent languages, >> and its users often push for work to be done in only those, >> what is the Plan 9 perspective of languages and tools in >> relation to each other? I guess rc & C are meant. True, I feel to be pushed to these. On the other hand I really like rc. Compared to bash/sh/ksh/zsh... I like its simplicity as well as that it is the only shell in plan9. I use it in linux too (although I miss some abilities it really should have, like ability to break from a loop). With C, I confess I do not use it often. In my life I found C a good tool to program microcontrollers. But otherwise I prefer python/ruby way unless speed is important---which, either really is (computation; physics) -> I use Fortran, see below, or is not at all. Fortunately, there are some ports of python and ruby to plan9. But it was always so difficult in my eyes, that I backed out from trying to use them (do you also have a feeling that the simples installation is often in windows, even for open-source projects?). There is also limbo, but for that I guess inferno must be installed... (am I right?) > I don't know for "the Plan 9 perspective" and have no authority to talk > "for Plan 9", but since almost all interpreters or compilers are written > in C, whether completely or the bootstapping procedure (a C core that is > able to interpret a subset of the language to generate a binary for the > non optimized version of a complete compiler etc.), there are all the > tools as long as there is a C compiler for the machine. Well, maybe. But it probably can be rather difficult to get some software to work in plan9 even though it is written in C, but 'for another system'... E.g. give me python+numpy+matplotlib... > The only "lack" in C is perhaps defined full control for > arithmetic/calculus. That's probably why FORTRAN is still here and has > still its strength in this area. Here, I must agree. Though I first hated Fortran for what it carries with itself from the times of FORTRAN, for all it's inabilities to work with strings, I must truly confess that I do not know of a better language for doing calculations. There is no way to compare C to Fortran, the latter being by no question superior. E.g. (not in any order of importance) Fortran can be (and usually is) quicker (better pointers). Fortran can have optional parameters to functions. Fortran can easily define/overload operators (not so nice yet, but improving, e.g. the priority of new operators cannot be set) --- this is nice to e.g. multiply matrices like this: C = A .x. B, do inversions like this .I.A, or transpose .T.A, among others. Fortran has elemental functions. Fortran can slice arrays, like a(2:8), similarly to matlab or numpy. Some people claim it is better suited for parallelism, but I can't say much about this point It's difficult to find anything where C would be better. Fortran still has some very ugly places, but it has become really powerful. But I guess there is nobody who would plan to put Fortran in plan9.
Re: [9fans] problems when hwaccel off or in inferno
2009/9/7 SHRIZZA : >> I'd like to ask whether anyone encountered problems when one turns off >> the hardware acceleration with >> cat hwaccel off > /dev/vgactl > > Of course, you mean "echo -n hwaccel off > /dev/vgactl", right? > yes, 'echo', not 'cat', actually echo hwaccel off > /dev/vgactl
Re: [9fans] problems when hwaccel off or in inferno
So is it so that anybody using vesa should see it in plan9 when hwaccel is off or when inferno runs on plan9 regardless the state of hwaccel? (At school I use i81x and plan9 itself is ok with both on/off.) Thanks Ruda 2009/9/7 Charles Forsyth : > there's a bug in the control of the software cursor in plan 9, > probably when loadimage is used. it can leave what my children call chicken > tracks, > as it updates the cursor. it shows up in at least vnc and inferno because > they use the equivalent of > loadimage on the screen to update their displays. > >
[9fans] awk help; not plan9 matter
Hello, simple task. I want to change the 2nd field on each line of a file, but preserve the spacing of the lines. If I do awk '{$2="hell"; print}' file the field gets changed, but all the spacing of the lines is gone; i.e. any space is now just ' ' like this: 1 3 4 8 changes to 1 hell 4 8 while I need 1 hell 4 8. Any help? Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 matt : > sed 's/^([^ ]+ +)([^ ]+)/\1HELL/' Well, actually, my problem is a part of a more complicated script; I don't know in advance neither the column nor what to put there. I currently have this awk ' /TH/ {$'$pos'='$new'} {print} ' inpch where 'TH' plays a role of a guard, and $pos and $new are the field to be changed and with what, respectively. I am afraid this rules out sed. Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 matt : > awk '{a=$2; sub(a, "hell"); print}' file The trouble with this is that the same string can appear more than once (before, after the field, ...), so the simple substitution isn't enough. Ruda
Re: [9fans] awk help; not plan9 matter
Ok. Thanks again. I think I've found what I need. (on lines of 'inpch' that contain 'TH' I change the field at position $pos to be $new, preserving spacing made of 'space's and/or tabs). If anyone comes up with sth. simpler... Ruda (The script is for 'rc', btw., so that the concatanation on the 3rd line work.) 9 awk ' /TH/ {n = split($0, spaces, /[^ ]+/); $'$pos'='$new'; line = ""; for(i = 1; i < n; i++) line = line spaces[i] $(i); line = line spaces[n]; print line; next;} {print} ' inpch
[9fans] <> operator
Hello, is the <> operator a feature only of native plan 9? It doesn't seem to work for me in p9p... Is the right solution then, instead of program <> file write program < file > file_tmp mv file_tmp file ? Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 yy : > if you want to preserve white-space, you better forget about fields > and work with indexes on the string, match is your friend: > > % echo '1 3 4 8' | awk '{match($0, /[ \t]*[^ \t]+[ > \t]+/);a=RLENGTH+1;match(substr($0, a), /[ \t]/);print > substr($0,0,a-1) "hell" substr($0,RSTART+a)}' > 1 hell 4 8 Well, it's just so difficult for me to read this. :) Also, i don't see how to easily modify it to flexibly work for any (not known beforehand) column, as I need. Why do you think this is better than my final solution? > this is indeed a bit OT here, maybe next time you prefer trying in > #awk at freenode, where this kind of problems are welcomed I didn't know there is a separate channel for awk... Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 erik quanstrom : > i don't know why this can't be done with sed. if the > task is to just change the second field without messing > with whitespace, why doesn't this work As I said in my second post, neither the field (the problem with sed) nor the string to be used as a replacement (no problem) is not known in advance... Apparently nobody reads but the 1st post... :) Thanks! Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 Noah Evans : > Since you're doing character processing rather than record processing, > isn't C your best tool for the job here? > > This is what I whipped out YMMV: > > #include > #include > #include > > char *str; > int ntok; > > #define WHITESPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') > > void > chgtok(Biobuf *bin, Biobuf *bout) > { > int seentok, waswhite, c; > seentok = 1; > waswhite = 0; > > while((c = Bgetc(bin)) != Beof){ > switch(c){ > case ' ': > case '\t': > if(!waswhite){ > seentok++; > waswhite = 1; > } > break; > case '\n': > seentok = 1; > break; > default: > waswhite = 0; > if(seentok == ntok){ > Bprint(bout, str); > while((c = Bgetc(bin)) != Beof) > if(WHITESPACE(c)) > break; > Bungetc(bin); > } > break; > } > Bputc(bout, c); > } > Bflush(bout); > } > > void > main(int argc, char **argv) > { > Biobuf bin, bout; > > ARGBEGIN{ > }ARGEND; > if(argc != 2) > sysfatal("usage"); > ntok = atoi(argv[0]); > str = argv[1]; > Binit(&bin, 0, OREAD); > Binit(&bout, 1, OWRITE); > chgtok(&bin, &bout); > exits(0); > } > Thanks, terrific job. :) But awk finally works (see my post at 12:46 or so) just fine and the code is just straightforward 9 lines. The only problem was to realize how one can proceed, i.e. here to remember the individual spaces and reconstruct the line from the fields. Nonetheless, your solution is almost surely faster. Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 erik quanstrom : > fn buildre { > re = 's:^' > for(i in `{seq 1 $1}) > re = $re ^ '([^ ][ ]*)' > re = $re ^ '([^ ]):\' ^ $1 ^ $2 ^ : > } > > - erik > Yes, I now see yours and Roger Peppe's idea to build a regexps and then use it. That's true. Only as I look at your code, not sure if it can stand possible spaces at the beginning of a line, like 1 2 3 Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 roger peppe : > just change the regexp as required. Ok. I decided (although just for game now) to play a little with the idea of building the regexp. Starting from Eric's post I slowly progressed to sth. quite similar to your post :) : fn buildre { re = 's:^([ ]*)(' for(i in `{seq 1 `{hoc -e $1-1}}) re = $re ^ '[^ ]+[ ]+' re = $re ^ ')[^ ]+:\1\2' ^ $2: } This works (even takes care about leading spaces) unless I want to use it for the 1st field. Then the produced regexp (buildre 1 hell)is s:^([ ]*)()[^ ]+:\1\2hell: and sed says sed: Command garbled: s:^([ ]*)()[^ ]+:\1\2hell: Apparently it dislikes the empty group, (). Is there any reason? I tried it in linux, there with echo '1 28 3' | sed 's:^\([]*\)\(\)[^ ][^ ]*:\1\2hell:' and it works as expected... Thanks Ruda
Re: [9fans] awk help; not plan9 matter
2009/9/17 erik quanstrom : > i don't think you need an extra () for the leading > white space. just tack it on in with the leading expression. see below > the hoc is unnecessary. just start with 2. true :) > fn buildre { > re = 's:^([ ]*' > for(i in `{seq 2 $1}) > re = $re ^ '[^ ]+[ ]+' > re = $re ^ ')([^ ]+):\1' ^ $2: > } > > ; buildre 1 hell > ; whatis re > re='s:^([ ]*)([^ ]+):\1hell:' already here is a problem: 1) I am to save the leading space --- so it shouldn't be an argument to s. 2) only the 2nd () --- the word with no spaces in itself --- is to be changed ... since the spaces are to be preserved, none of them should be an argument to the s command, I think. That's why it was treated seperately by me. Anyway, what do you think about that problem with the empty group? Why linux is ok with it while plan 9 is not? Is there any reason? Is that a bug in plan9 sed? Thanks Ruda > ; buildre 2 hell > ; whatis re > re='s:^([ ]*[^ ]+[ ]+)([^ ]+):\1hell:' > > - erik > >
Re: [9fans] awk help; not plan9 matter
forget about my previous post regarding the leading space, I am tired, it was wrong... Anyway the question about () is still hot... R 2009/9/17 Rudolf Sykora : > 2009/9/17 erik quanstrom : >> i don't think you need an extra () for the leading >> white space. just tack it on in with the leading expression. > > see below > >> the hoc is unnecessary. just start with 2. > true :) > >> fn buildre { >> re = 's:^([ ]*' >> for(i in `{seq 2 $1}) >> re = $re ^ '[^ ]+[ ]+' >> re = $re ^ ')([^ ]+):\1' ^ $2: >> } >> >> ; buildre 1 hell >> ; whatis re >> re='s:^([ ]*)([^ ]+):\1hell:' > > already here is a problem: > 1) I am to save the leading space --- so it shouldn't be an argument to s. > 2) only the 2nd () --- the word with no spaces in itself --- is to be changed > ... since the spaces are to be preserved, none of them should be an > argument to the s command, I think. That's why it was treated > seperately by me. > > Anyway, what do you think about that problem with the empty group? Why > linux is ok with it while plan 9 is not? Is there any reason? Is that > a bug in plan9 sed? > > Thanks > Ruda > >> ; buildre 2 hell >> ; whatis re >> re='s:^([ ]*[^ ]+[ ]+)([^ ]+):\1hell:' >> >> - erik >> >> >
[9fans] lout contra troff/TeX
Hello, is there anyone who could say a few words about their experience with the lout formatting system and how well it compares to the troff/TeX suite. Also, does anybody use it in plan9? Thanks, Ruda
Re: [9fans] fmt(1) standard behaviour
I may not fully understand the problem, but wouldn't it be just fine if fmt output anything it can already output? I.e., filled lines are output, on encountering '\n' the (generally unfilled) line is output... (Or what is the reason that fmt waits for EOF?) R
[9fans] bison problem, not plan9 related
Hello, sorry for an off-topic thing. But I guess somebody here could help me... I have a problem with bison grammer Having %token ATOM %left '+' %left REP and a grammar: block:ATOM | REP block | block '+' block ; is ok. Having another grammer: block:ATOM | REP block | block block %prec '+' ; has 2 shift/reduce conflicts, similar to state 7 5 block: REP block . 6 | block . block ATOM shift, and go to state 3 ATOM [reduce using rule 5 (block)] $default reduce using rule 5 (block) block go to state 9 or state 9 6 block: block . block 6 | block block . ATOM shift, and go to state 3 REP shift, and go to state 4 ATOM [reduce using rule 6 (block)] $default reduce using rule 6 (block) block go to state 9 What I want is to have a parser that can read e.g. (the spaces are left out by lex, they are not in what bison sees; I only write them here for better readability) 12 Au 13 Cu 2 Ag the former grammer (REP is for repetition) is able to read 12 Au + 13 Cu + 2 Ag but I don't like those pluses, which are redundant. Also important: I have those 'block' non-terminals there, since I want to add another rule block: '[' block ']' so that I can use brackets and can parse things like 12 [ 2 Cu 3 Co] Could anyone explain to me what goes wrong? I can't figure it out... Thanks a lot Ruda PS.: the grammer is actually identical to a grammer that can evaluate expressions with +, *, and brackets, with usual operator precedence.
Re: [9fans] bison problem, not plan9 related
... anywhere where I wrote 'grammer' I meant 'grammar' ...
Re: [9fans] bison problem, not plan9 related
2009/10/21 Russ Cox : > To know how to decide, yacc needs a precedence > for the thing being shifted and the rule. You've > given precedences for each rule (REP block has > REP's precedence, and block block has +'s thanks > to the override) but not to ATOM. > > Concretely, when yacc sees REP block ATOM > it isn't sure whether that's (REP block) ATOM or > REP (block ATOM). > > Instead of > >> %token ATOM >> %left '+' >> %left REP > > you probably want > > %left '+' > %left REP > %nonassoc ATOM > > Russ Ok, thanks, this seems to have solved it. So the %nonassoc says to the parser that (REP block) ATOM is the right decision as opposed to REP (block ATOM) right? The sad point really is that I couldn't find a good explanation for what %nonassoc really means. Everybody just says that it precludes a situation where 'the same operator would be twice in a row...' which isn't quite telling, when one realizes that the parser really does not know what an 'operator' is... (both the documentation of bison (Donnelly, Stallman) and of yacc (Johnson) are just like that; I couldn't find any better) So could you please say, what %nonassoc really assures? Thanks Ruda
Re: [9fans] bison problem, not plan9 related
2009/10/21 Skip Tavakkolian <9...@9netics.com>: > i think this is what you want. untested: > > pair: REP ATOM > | REP '[' block ']' > > block: pair > | block pair Thanks. This would require there always be a REP before [ block ], which I don't want (cf. ordinary expression (1+2) ). Anyway, thanks. Ruda
Re: [9fans] bison problem, not plan9 related
> So the %nonassoc says to the parser that > (REP block) ATOM > is the right decision as opposed to > REP (block ATOM) > right? ... probably not exactly. the highest priority of ATOM is probably also important, as I think of it now... Ruda
Re: [9fans] bison problem, not plan9 related
> Is this what you are trying to do? > > $ cat b.y <<'EOF' > %token ATOM REP > %% > blocks: block | block blocks; > block: ATOM | REP block | '[' blocks ']'; > %% > EOF > $ bison b.y > $ My head is starting to spin, but I think that, possibly, yes. Seems to be the simplest way how to do it. :) Anyway, I also needed to know what R Cox explained, that was important; still wondering what that %nonassoc really means. Thanks Ruda
Re: [9fans] bison problem, not plan9 related
I must say, many thanks! Ruda 2009/10/21 Russ Cox : >> Ok, thanks, this seems to have solved it. >> So the %nonassoc says to the parser that >> (REP block) ATOM >> is the right decision as opposed to >> REP (block ATOM) >> right? > > %token declares its arguments as tokens but > does not give them any precedence level. > > %left, %right, and %nonassoc also declare their > arguments as tokens. in addition, each such line > introduces a new precedence level stronger than > the ones introduced by previous lines. > > if a shift/reduce conflict involves different precedences, > the stronger precedence always wins. > > if a shift/reduce conflict is a tie between identical precedences, > the resolution depends on which of the three lines > (%left, %right, or %nonassoc) introduced the precedence. > > precedences introduced by %left resolve the tie > by reducing; this creates left-to-right associativity (x-y-z). > > precedences introduced by %right resolve the tie > by shifting; this creates right-to-left associativity (x^y^z in hoc). > > precedences introduced by %nonassoc do not resolve > the tie. they leave it as a conflict that gets reported. > > if you're defining a precedence that is not intended > to be associative, much of the time it doesn't matter > which you pick, because your grammar is likely to > be such that ties never happen. but %nonassoc is > still the safe choice. > > in the running example, %nonassoc by itself > doesn't say which of those two is right. it just > defines a precedence for ATOM, which is used > as the precedence for shifting ATOM. > because the REP block and block block rules > have precedences too, the ambiguity can be > resolved by comparing the precedences. > which way things get resolved depends on whether > the %nonassoc line comes before or after the > other precedences, not on the meaning of %nonassoc. > > i said > >> %left '+' >> %left REP >> %nonassoc ATOM > > and that will give you REP block ATOM == REP (block ATOM) > which is probably not what you want. to tweak it, > just move the %nonassoc line above the two %left lines. > > russ > >
[9fans] hoc's behaviour, unary operators
Hello why 1+-2 is ok for the 'hoc' command, while both 1--2 1-+2 produce a syntax error? (If spaces are added as in 1- -2 1- +2, hoc is fine with the former but still rejects the latter...) Thanks Ruda
Re: [9fans] hoc's behaviour, unary operators
PS.: While 'bc' is not any better in this, 'maxima' gets it wright. (Both in linux.)
Re: [9fans] hoc's behaviour, unary operators
2009/10/30 Jorden Mauro : > Look under the production for expr in /sys/src/cmd/hoc/hoc.y > > Looks like the unary plus problem would be a one-line fix. The -- with no > space > may be harder to fix. Thanks, I will. Nonetheless, the problem, as I am thinking about it now, could possibly (also) be connected to ++ and -- operators, as in a++, a-- where 'a' is some variable. Although the meaning for e.g. a--b is still only one, i.e. a - (-b), (a-- b wouldn't make sense) it probably can't (can it?) be parsed simply with yacc... Ruda
Re: [9fans] hoc's behaviour, unary operators
2009/10/30 Martin Neubauer : > * Rudolf Sykora (rudolf.syk...@gmail.com) wrote: >> (a-- b wouldn't make sense) it probably can't (can it?) be parsed >> simply with yacc... > I don't see why it would be impossible. Just introduce a binary -- > operator (cf. -1 vs. 1-2). Whether it's worth it... Yes, probably you're right that it can be done. At least partially. First, '+-' and '-+' situation should be handled (unary '+' introduced). Then: The yylex() function in hoc.y returns an 'INC' token for '++' and a 'DEC' for '--'. So if one adds a binary INC and DEC, changes the priority appropriately, it could work... BUT there are more complicated cases: Python handles correctly e.g. 2-7, 2+-+-7, 2+++-7,... C-compiler that I use in my linux, gcc, is ok for a+-b and a-+b, also for a+-+-b, but not for a++b or a--b or any alike. >From these more complicated examples like 27, I am getting an impression that it'd be better to not produce tokens like INC & DEC in the (which must then be decomposed into effectively unary operators), but to only have '+' and '-' tokens and work with them somehow... Ok. I wrote this because I was suprised that something I had expected just doesn't work in the way. I don't think I am capable of actually changing the lexer & parser of hoc, but if I try and succeed, I'll tell you. Thanks Ruda
Re: [9fans] hoc's behaviour, unary operators
2009/10/30 erik quanstrom : >> Python handles correctly e.g. 2-7, 2+-+-7, 2+++-7,... >> C-compiler that I use in my linux, gcc, is ok for a+-b and a-+b, also >> for a+-+-b, but not for a++b or a--b or any alike. > > you're confusing tokens and productions. the c tokenizer > has the following rules > -- -> DEC > ++ -> INC > + -> PLUS > - -> MINUS > > therefore the string "a++b" can't be valid, since the tokens > the parser sees are "a" INC "b". that's not kosher c. way > back when in primoridal c, there were no seperate tokens > for INC and DEC, they were productions in the parser and > goofiness like you describe was allowed. Well, for exactly this reason I said I wouldn't produce INC & DEC tokens in the lexer. a++b would then be translated by the parser to a + (+b), since this would be the only sensible meaning (a INC b doesn't work). The same would be for any NUMBERS. These can't be ++ or --; there the + & - would only be unary +,- operators. This would give sence to anything like 2++7, 2--+7, where only numbers appear. I formerly thought that INC & DEC could be somehow elegantly reconciled even with operations on variables (like a++b above). But a+++b (where we would have to decide), and more importantly --b shows it can't be done. This took me some time to realize. Thus for NUMBERS the goal of reading complicated things could be achieved. For variables not, unless INC and DEC disappear (they are not in python or maxima). Now, the question is whether it's worth changing the behaviour for number expressions... This is the analysis for which I was looking. That's the reason I started this thread. It's only after I know the details that I decide what to do. > also, this is a very long discussion for a one-line fix. There are much longer much less fruitful (for me) threads all around. And neither you explained, just submitted a patch. Thanks for it, but first I needed to know WHY it is that I can't read expressions that are ok elsewhere. Thanks Ruda