johnf wrote:
On Monday 22 December 2008 09:15:13 am bob gailer wrote:
johnf wrote:
I've been in the programming business for over 20 years and I have never
had a need for a parser.  But recently I have need to convert code from
one language to a my new language python.
Pray tell: what is the other language, and why do you want to convert
programs?

I assume you want to convert so you can then modify / extend the old
programs. If you just plan to run them in Python "as is" I see no value
in converting!

It is hard to map programs in other languages to Python because Python
is so different. A direct translation would not take advantage of
python's uniqueness.

What a better way to learn the new
language python than a new project.  I decided it might be time to learn
a little something about parsers too.  However, I soon discovered that I
was walking into the world of compiler writers and theories of computer
scientist.  I paid for and downloaded a paper from O'Reilly books on what
I thought was going to be on 'pyparser'.  But that turned out to be
mostly theory.  And nothing about the use of pyparser.

So I ask you guys is there a link to a practical tutorial that provides
hands on information on the use of a python parser.  I'd like to see
something that demo's converting a real language to python.  When I
google parsers I have found a few simple code examples of parsing a
float.  Not really much help (I could have done that using Regex) when
you want to parse 'if,then' statements that can be recursive.
FWIW I have written a parser for parts of the CMS Pipelines language. I
provide a form of BNF for the syntax, generate parsers from that, run a
"program" through that, which generates lists or dictionaries. I have no
need to create a program from that.

The Pipelines language is very simple, so I am not dealing with control
structures, just sequences of words and symbols.

Well I'm attempting to convert VFP and MsSQL (stored procedures and triggers) to Python and Postgres (functions and triggers). Actually, python is very close to VFP and I would convert very well. MsSQL is another question.

I started writing a VFP - Python converter a few years ago. I will see if I have it around.

It has been suggested that I just read one line at a time and convert. I could do that but I did want to expand my understanding by using a parser. And the one line at a time does not lend it self to control structures. Even if I do a get the convert to work there would still be a need for hand coding. But it would provide a good start.

So far no links to tutorials?


--
Bob Gailer
Chapel Hill NC 919-636-4239

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to