lexing nested parenthesis (for a Python Unix Shell)

Dave Cinege dcinege at psychosis.com
Fri Aug 2 23:17:08 CEST 2002


On Friday 02 August 2002 16:15, Bengt Richter wrote:

Thanks for your reply. I'll go over it in detail latter but for right now:


> I suspect you can just let $name be name in the first place,
> unless you need to do something special with specially designated names,
> but we'll keep it in. 

I'm undecided on prefixing variables. Remember that a shell
is designed to access any external command and this can
dynamically change. Not prefixing the vars means I much keep
track of them entrily. During interactive use it gets more complex
as I have to keep track on vars on some level anyhow.

IE When I prefix I simple rewrite $cat to pysh_cat, and it doesn't
interfere with /bin/cat

> I don't know what ';;' is supposed to do, but

I've designated that to mean 'explict end of function (control, whatever)  
block' It's a means to solve the 'I must be indented damn it!' nature of 
python.

	for i in l: print i + i ; print i
This is OK
	for i in l: if i > 2: print i + i ; print i
This while fail. 

Now if you guessed I'm on the 'do away with indentation' side of
the religious war, you're wrong. I'm all for it. But a shell is
all about Quick and Dirty Interactive use, thus I want a mechnism
to avoid indentation. ';;' will be the indetifier. It seems logical
as ';' chains statments and function calls, thus ';;' will chain
(actually terminate) function/control blocks. So in Pysh:

	for i in l: if i > 2: print i + i ;; print i

Will do as intended and will be rewritten as:
	for i in l:
		if i > 2:
			print i + i
		print i

An even uglier example:
	for i in l: if i > 2: for x in range(0,i): \
	if x >1: print x ;; print i ;; print i + i ;; print i

Yes with Pysh truely obfuscated Python will finally be possible. : >

I actually wouldn't mind if this was added directly to Python, though
I'd hate to think people might begin relying on it for anything but 
interactive and specialized purposes. The rest of the ugly 'shell centric 
shit' doesn't belong anyplace but in my shell.
  
Dave

-- 
The time is now 22:48 (Totalitarian)  -  http://www.ccops.org/





More information about the Python-list mailing list