Re: How is Python designed?

Discussion in 'Python' started by Limin Fu, Dec 4, 2004.

  1. Limin Fu

    Limin Fu Guest

    > If you want cutting-edge, mind twisting stuff, look
    > into
    > Psyco extension (Armin Rigo, 1.3 just announced
    > here)
    > Stackless extension (Christian Tismer)
    > PyPy (new interpreter written in Python, several
    > people, has EU funding)


    That would be interesting. However I am designing and
    implementing another interpreter. The techniques I'm
    using seems to be different from most of current
    interpreters (I hope so, I'm not very sure, that why I
    come to ask questions about interpretation
    techniques). The programming language is C++.

    The basic idea of this technique is to create a class
    to represent each type of script phrase(that's the
    term I used in the program, it's just a piece of code
    for particular task such assignment,logical/loop
    control,function call, whatever). In the phase of
    compiling, phrase instances of such classed are made,
    and in the execution phase, starting from the first,
    each phrase instance is executed and jump to the next
    phrase instance for subsequential execution,
    like a finite state automa I would say. Currently the
    interpretation efficiency is comparable to most
    popular interpreters.

    For more information, please have a look at:
    http://yuan-language.sourceforge.net/

    Honest saying, it has just come out for a few monthes,
    it's not well tested and there is much things to be
    improved. So don't be surprised if some bugs come out
    when you run it. In this case, please let me known.
    Cheers,

    Limin



    __________________________________
    Do you Yahoo!?
    Yahoo! Mail - Easier than ever with enhanced search. Learn more.
    http://info.mail.yahoo.com/mail_250
     
    Limin Fu, Dec 4, 2004
    #1
    1. Advertising

  2. Hi,

    > The basic idea of this technique is to create a class
    > to represent each type of script phrase(that's the
    > term I used in the program, it's just a piece of code
    > for particular task such assignment,logical/loop
    > control,function call, whatever). In the phase of
    > compiling, phrase instances of such classed are made,
    > and in the execution phase, starting from the first,
    > each phrase instance is executed and jump to the next
    > phrase instance for subsequential execution,
    > like a finite state automa I would say. Currently the
    > interpretation efficiency is comparable to most
    > popular interpreters.


    I'd say that's pretty much standard interpreter technique - an expression
    like this:

    foo = a + b * c

    is translated and reduced to an abstract-syntax-tree something like this:

    Assignment("foo", BinaryOp("+", Get("a"), BinaryOp("*", Get("b"),
    Get("c"))))

    Then on Assignment one can invoke eval(), and get the result. Assignment
    will invoke eval on its children, which in turn will do that for their
    operands, until something can be computed. The result is returned.

    By using an emulated stack or register-machine, you can flatten that to
    something like this:

    push Get("c")
    push Get("b")
    push BinaryOp("*")
    push Get("a")
    push BinaryOp("+")
    pop Assignment("foo")

    This is of course very makeshift - but you'll get the idea.

    This doesn't mean I want to discourage you - on the contraire. Developing
    your own language is highly educating, and I personally love it when I
    "invent" something and then later find out that people much cleverer than
    me did so before - it shows that I went down the same paths of thought :)

    --
    Regards,

    Diez B. Roggisch
     
    Diez B. Roggisch, Dec 4, 2004
    #2
    1. Advertising

  3. Limin Fu

    Robert Guest

    Sorry for my interrupting the discussion : ). I am a graduate student
    in a chinese university, and i am very interested in the Yuan
    language. I'd like to join in the development of Yuan and do some work
    for this language. BTW, i like this word, "Yuan" : )

    I have 3 or 4 years experience in C++, and i have strong programming
    skills about C++(at least in my opinion :) ) . I am interested in the
    compiling technology and virtual machine technology. And i am reading
    the <Virtual Machine Design and Implementation in C/C++> written by
    Bill Blunden now. I had the thought of starting an open source project
    which contains a virtual machine and a scripting language a few days
    ago, just like a very simple python. Well, i know it is very difficult,
    but it is my dream : ). Luckly i found "Yuan" here. So it is my
    pleasure if i can become a member of "Yuan" :)

    Waiting for your reply. :)

    Best regards.


    Ru Chen
     
    Robert, Dec 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Limin Fu

    How is Python designed?

    Limin Fu, Dec 2, 2004, in forum: Python
    Replies:
    2
    Views:
    290
    Terry Reedy
    Dec 3, 2004
  2. Limin Fu

    Re: How is Python designed?

    Limin Fu, Dec 3, 2004, in forum: Python
    Replies:
    2
    Views:
    311
    Arthur Rambo
    Dec 3, 2004
  3. Limin Fu

    Re: How is Python designed?

    Limin Fu, Dec 6, 2004, in forum: Python
    Replies:
    2
    Views:
    337
    LutherRevisited
    Dec 8, 2004
  4. Limin Fu

    Re: How is Python designed?

    Limin Fu, Dec 8, 2004, in forum: Python
    Replies:
    2
    Views:
    277
    Diez B. Roggisch
    Dec 8, 2004
  5. Chris Angelico
    Replies:
    109
    Views:
    715
    Mark Lawrence
    Oct 26, 2013
Loading...

Share This Page