[Tutor] Syntax Check
Chad Crabtree
flaxeater at yahoo.com
Thu Jan 27 21:20:19 CET 2005
Ok I'll explain what I've done so far. I'm using tokenize to take
the
file that imports macro; found by using stack inspection and then
tokenize it. I look at all the string tokens to see if they match
they
pattern a macro should have. Then I pass the macro string through
the
tokenizer again to expand this and to maintain the indentation needed
for the block. I did this as an exercise and I thought the 'with'
extension would be nice for my own benefit. I thought it would be
useful for all those syntax propositions in PEPs and stuff to
actually
implement them to see how they work in real life. However in it's
current state I have to use anonymous ('''****''') strings to
surround
the macro. I just thought it would be nice to just have python
import
macro run the first few things with out looking to far into the file,
at
which point macro.expand() would take over.
Now that you mention it and I'm thinking about it, it would probably
take some sort of MacroPython->Python compiler type thing. To get
the
feel I'm really looking for. I guess I was thinking it would work
like
psyco
import psyco
psyco.full()
I hope I made myself clearer.
Alan Gauld wrote:
>>I'm trying to make a macro system that's work by just doing this
>>
>>
>
>OK, But to get your acros to use a language extension to python
>(the with.... syntax) you are going to have to write your own
>language interpreter/parser. Even if that just turns the 'with'
>stuff into Python.
>
>So why is the """ marker even necessary? Your interpreter doesn't
>need it - although it might make things easier... I'm still
>confused I think.
>
>Alan G.
>
>
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
More information about the Tutor
mailing list