473,503 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing an interpreter for language similar to python!!

Hello all,

I am new to python and working on a project that involves designing a
new language. The grammar of the language is very much inspired from
python as in is supports nearly all the statements and expressions
that are supported by python. Since my project is in initial stage, so
I think it would be appropriate if I clarify the following questions:

1. Would it make sense if I parse the whole program from scratch and
then construct the valid python strings back so that they can be
executed using ''exec'' and ''eval'' commands?
2. Recently, I came across PLY (Python-Lex-Yacc) module that can be
used to implement interpreters. It seems quite friendly to work with.
Is there any implementation of python interpreter using ply? Any such
reference would be extermely helpful for me to continue.

Any kind of suggestions/ comments would be highly appreciated.

Thanks,
Luvish Satija

Feb 28 '07 #1
5 1827
"luvsat" <lu*****@gmail.comwrote:

Hello all,

I am new to python and working on a project that involves designing a
new language. The grammar of the language is very much inspired from
python as in is supports nearly all the statements and expressions
that are supported by python.
8<-----------------------------

This post begs the following questions:

- Why make a new language, when
- It is going to be an inferior subset of Python -
- What can the motivation be to do this instead of contributing to the python
effort?

Dont forget about GNU Bison, if you persist...

- Hendrik


Mar 1 '07 #2
Hendrik van Rooyen wrote:
- It is going to be an inferior subset of Python -
From what the OP said, it isn't necessarily a subset of
Python, just something whose surface syntax is similar.
The semantics could be quite different.

However, if the semantics *are* to be similar as well,
it makes a lot of sense to consider whether Python itself
could be used.

--
Greg
Mar 1 '07 #3
I am new to python and working on a project that involves designing a
new language. The grammar of the language is very much inspired from
python as in is supports nearly all the statements and expressions
that are supported by python. Since my project is in initial stage, so
I think it would be appropriate if I clarify the following questions:

1. Would it make sense if I parse the whole program from scratch and
then construct the valid python strings back so that they can be
executed using ''exec'' and ''eval'' commands?
2. Recently, I came across PLY (Python-Lex-Yacc) module that can be
used to implement interpreters. It seems quite friendly to work with.
Is there any implementation of python interpreter using ply? Any such
reference would be extermely helpful for me to continue.

Any kind of suggestions/ comments would be highly appreciated.

You might want to look at the pypy project:

http://codespeak.net/pypy/dist/pypy/doc/news.html

A javascript interpreter has already been written using pypy:

http://codespeak.net/svn/user/santag...preter_sop.txt
Mar 2 '07 #4
On 28 Feb, 18:38, "luvsat" <luv....@gmail.comwrote:
>
I am new to python and working on a project that involves designing a
new language. The grammar of the language is very much inspired from
python as in is supports nearly all the statements and expressions
that are supported by python. Since my project is in initial stage, so
I think it would be appropriate if I clarify the following questions:
Sounds interesting!
1. Would it make sense if I parse the whole program from scratch and
then construct the valid python strings back so that they can be
executed using ''exec'' and ''eval'' commands?
I wouldn't bother parsing the program from scratch - there's a module
called "compiler" in the standard library which will give you an
abstract syntax tree for virtually all of the syntax supported by the
version of Python you're using. Despite complaints about the API, it's
quite easy to work with and will save you from dealing with the
tedious details of actually parsing the source code. If you want to
produce the source code from the AST, some people have written visitor
classes which will probably do what you want.

Paul

Mar 2 '07 #5
Jim
On Mar 1, 1:16 am, "Hendrik van Rooyen" <m...@microcorp.co.zawrote:
This post begs the following questions:

- Why make a new language, when
- It is going to be an inferior subset of Python -
- What can the motivation be to do this instead of contributing to the python
effort?
Perhaps the OP only wants to learn something about compilers or
parsing, or something like that?

Jim

Mar 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1606
by: Gabriele Farina | last post by:
I guys I planned to create a new programming language to use to develop web applications for my company. I'd like to develop it using Python, but I don't know if python is fast enaught. ...
13
1735
by: Alejandro Lombardo | last post by:
Dear sirs: I need to create a programming language. Can this be done with the latest version of python? Is python the best computer programming language development tool in the entire universe? If...
4
4309
by: Daniel Cloutier | last post by:
Hi, is it possible to edit or write Word-files out of a Python-Program? thx in advance daniel
29
2101
by: Steven Bethard | last post by:
Fuzzyman wrote: > Cameron Laird wrote: > > >>This is a serious issue. >> >>It's also one that brings Tcl, mentioned several >>times in this thread, back into focus. Tcl presents >>the...
4
1846
by: WX | last post by:
I love Python, and the unicode support is wonderful. The character set I am using is the Hindi/Devanagari character set at unicode range U+901.) I have TWO newbie questions: (#1) If I paste...
8
1770
by: Aziz McTang | last post by:
Hi Group, I am not an experienced programmer at all. I've learned html and css well enough to hand-write simple websites. I'm now looking to move to the next step. Initially, I'd like to do 3...
19
1649
by: Vincent Delporte | last post by:
Hello I'm thinking of using Python to build the prototype for a business web appplication. The development and test machine is XP, while ultimate deployment will be on a shared Unix web host. ...
2
1179
by: psychofish25 | last post by:
It's been about 2 hours since I started writing code for a programming language I made in python called XSSIV (excessive). Anyway the code can be found at psychofish25.freewebspace.com/xssiv.py ...
3
1870
by: R. Bernstein | last post by:
The next release of pydb will have the ability to go into ipython from inside the debugger. Sort of like how in ruby-debug you can go into irb :-) For ipython, this can be done pretty simply;...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.