473,769 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parser suggestion


Hi!
I'm needing a parser to retrieve some information from source code --
including parts of code -- from Fortran, to use in a project with a
documentation system.

Any recommendations on a Python app or parser that I could use for that?
Thanks,
--
Jorge Godoy <go***@ieee.org >

Sep 29 '05 #1
11 1837
In article <87************ @ieee.org>, Jorge Godoy <go***@ieee.org >
wrote:
I'm needing a parser to retrieve some information from source code --
including parts of code -- from Fortran, to use in a project with a
documentation system.

Any recommendations on a Python app or parser that I could use for that?


There seems to be a great diversity of parsing tools available for
Python programmers. Here are a few suggestions to get you started:

PLY (Python Lex/Yacc)
http://www.dabeaz.com/ply/

PyParsing
http://pyparsing.sourceforge.net/

SPARK (Scanning Parsing And Rewriting Kit)
http://pages.cpsc.ucalgary.ca/~aycock/spark/

You might also find the following an interesting read, if this sort of
thing interests you:
http://www.python.org/sigs/parser-si...-standard.html

Cheers,
-M

--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA
Sep 29 '05 #2
"Michael J. Fromberger" <Mi************ ******@Clothing .Dartmouth.EDU> writes:
There seems to be a great diversity of parsing tools available for
Python programmers. Here are a few suggestions to get you started:
From Google I found almost all of those. But do you have any suggestion on
which one would be better to parse Fortran code? Or more productive to use
for this task?
PLY (Python Lex/Yacc)
http://www.dabeaz.com/ply/
This is new to me :-)
PyParsing
http://pyparsing.sourceforge.net/
From what I was seeing, this seems to be a good one to try...
SPARK (Scanning Parsing And Rewriting Kit)
http://pages.cpsc.ucalgary.ca/~aycock/spark/
It looks like it stopped being developed circa 2002... From 2002 to now
Python had a lot of improvements and I'd rather use a maintained tool for this
project. At least one that keeps up with Python's development...

You might also find the following an interesting read, if this sort of
thing interests you:
http://www.python.org/sigs/parser-si...-standard.html


I will. But this is basically for "one project only". Other structures are
usually simpler than a programming language and can be retrieved with
different approaches.
Thank you very much for your suggestions.
Be seeing you,
--
Jorge Godoy <go***@ieee.org >
Sep 29 '05 #3
Jorge Godoy wrote:
From Google I found almost all of those. But do you have any suggestion on
which one would be better to parse Fortran code? Or more productive to use
for this task?
[snip]
PyParsing
http://pyparsing.sourceforge.net/


Well, I've never had to parse Fortan code, but I've had a lot of success
writing a variety of recursive grammars in PyParsing. I'd highly
recommend at least trying it out.

STeVe
Sep 29 '05 #4
Jorge Godoy wrote:
Hi!
I'm needing a parser to retrieve some information from source code --
including parts of code -- from Fortran, to use in a project with a
documentation system.


http://svn.scipy.org/svn/scipy_core/...rackfortran.py

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Sep 29 '05 #5
[Jorge Godoy]
SPARK (Scanning Parsing And Rewriting Kit)
http://pages.cpsc.ucalgary.ca/~aycock/spark/
It looks like it stopped being developed circa 2002... From 2002 to
now Python had a lot of improvements and I'd rather use a maintained
tool for this project. At least one that keeps up with Python's
development...


While this way of thinking is in the fashion, and often happens to be
right, it does not really apply in the SPARK case.

SPARK works fine and well, and is probably the most elegant and pythonic
of the series. If it it does not really need to be further developed,
and does not have much to gain from recent Python releases, I do not see
why it should be released once in a while merely to entertain the crowd.

--
François Pinard http://pinard.progiciels-bpi.ca
Sep 29 '05 #6
My recommendation for a project like this would be SimpleParse

<http://simpleparse.sou rceforge.net>

Some examples are here

<http://simpleparse.sou rceforge.net/simpleparse_gra mmars.html>

and

<http://www-128.ibm.com/developerworks/linux/library/l-simple.html>

/Jean Brouwers

Sep 29 '05 #7
Steven Bethard <st************ @gmail.com> writes:
Jorge Godoy wrote:
From Google I found almost all of those. But do you have any suggestion on
which one would be better to parse Fortran code? Or more productive to use
for this task?

[snip]
PyParsing
http://pyparsing.sourceforge.net/


Well, I've never had to parse Fortan code, but I've had a lot of success
writing a variety of recursive grammars in PyParsing. I'd highly recommend at
least trying it out.

STeVe


I've downloaded it. The interesting thing is that there are some examples
that parses things more complex than "2+3*8" :-)

--
Jorge Godoy <go***@ieee.org >
Sep 29 '05 #8
François Pinard <pi****@iro.umo ntreal.ca> writes:
[Jorge Godoy]
SPARK (Scanning Parsing And Rewriting Kit)
http://pages.cpsc.ucalgary.ca/~aycock/spark/

It looks like it stopped being developed circa 2002... From 2002 to
now Python had a lot of improvements and I'd rather use a maintained
tool for this project. At least one that keeps up with Python's
development...


While this way of thinking is in the fashion, and often happens to be
right, it does not really apply in the SPARK case.

SPARK works fine and well, and is probably the most elegant and pythonic
of the series. If it it does not really need to be further developed,
and does not have much to gain from recent Python releases, I do not see
why it should be released once in a while merely to entertain the crowd.


I don't consider it entertainment. Just code maintenance.

How can I be sure that if I find a bug I'll be able to discuss it with the
developer if it's 3 years since the last release of his code?

You're someone I admire and with whom I've worked before -- with documentation
--, so I consider your opinion a lot and will give SPARK a look based on your
recommendation.

But, I still think that 3 years without any new implementation, design change
or maintenance release is a huge ammount of time; specially in our area where
technology evolves really fast and new concepts are always popping up.
Thanks a lot for your opinion and for trying to open my eyes, François.

--
Jorge Godoy <go***@ieee.org >
Sep 29 '05 #9
On 29 Sep 2005 17:20:54 -0300, Jorge Godoy <go***@ieee.org > declaimed
the following in comp.lang.pytho n:

I'm needing a parser to retrieve some information from source code --
including parts of code -- from Fortran, to use in a project with a
documentation system.
FORTRAN has one of the most complex parsers around -- since (unless
recent standards have changed it) the language is not space delimited...
The following are IDENTICAL syntactically:

do 10 i = 1, 20, 3
do10i = 1,2 0,3

while the following is NOT a do loop

do 10 i = 1.2 03

And the only way to tell them apart is to parse up to the , or . --
and backtrack if you made the wrong choice (that is, if you assume "do
10 i =" started an assignment to "do10i", and found a "," you have to
backtrack and reparse as a loop).

And then consider (fixed pitch please):
C234567890
do
x 1
x0 =
x1
x.
C nonsense
x20
x 3

-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Sep 30 '05 #10

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

Similar topics

4
4262
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML) and puts values in a number of arrays and then puts the contents of the array in a HTML table. I'd like to keep the array structure. I've checked out all sorts of different javascript parsers but have not met with a great deal of success with any...
1
2702
by: Helge Ruistuen | last post by:
Hello, I'm using SAX parser to read a string of numbers defined as XML list type. Occasionally the 'characters' method is called twice, which means I need a buffer to read the entire string. My problem is that whenever "the split" (or second reading) occurs at a white space, I need to manually add a white space (avoid two number becoming one), while for the case that the parser start a second reading within a number, adding a white space...
16
6318
by: Mike | last post by:
Does anyone know of a minimal/mini/tiny/small xml parser in c? I'm looking for something small that accepts a stream or string, builds a c structure, and then returns an opaque pointer to that structure. There should then be a function to search that structure given the pointer, tag, and an optional attribute. I'm looking initially at only text data, no numbers, though eventuall there will be some binary data (CDATA?). Thanks.
2
2262
by: Alex | last post by:
Hello all, As I don't have any experience with XML parsers, I'm looking for your advice in this group. In the project I'm involved with, we are dealing with parsing of XML messages that are coming from server. The parser that we are currently using is not able to: - parse non-ASCII Unicode text - parse unary XML elements - parse the text block between XML elemnts
6
7383
by: Herby | last post by:
Hi, Im interested in Reverse Engineering C++ source code into a form more comprehensible than the source itself. I want to write a basic one myself, obviously i need to write a parser for the source code. Although this has some overlap with say a compiler it would also seem significantly different too.
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
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 we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.