En Sun, 22 Jul 2007 10:36:59 -0300, <[EMAIL PROTECTED]>  
escribió:

>> Since the application is transforming
>> its input, it could transform braces into indentation. Of course  
>> *Python*
>> doesn't use braces, but the question was how to write "pseudo-Python"
>> without using indentation to indicate grouping.
>>
> This previously is exactly what I need can you help me somehow about
> this
> code
> indentation, on any way you know.Plese help I will really appreciate
> this!!!!!!!!!!!!!!

If you are using the tokenize module as suggested some time ago, try to  
analyze the token sequence you get using { } (or perhaps begin/end pairs  
in your own language, that are easier to distinguish from a dictionary  
display) and the sequence you get from the "real" python code. Then write  
a script to transform one into another:

 from tokenize import generate_tokens
 from token import tok_name
 from cStringIO import StringIO

def analyze(source):
     g = generate_tokens(StringIO(source).readline)
     for toknum, tokval, _, _, _  in g:
         print tok_name[toknum], repr(tokval)

I think you basically will have to ignore INDENT, DEDENT, and replace  
NAME+"begin" with INDENT, NAME+"end" with DEDENT.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to