473,581 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can recursive descent parser handle Python grammar?

I'm a compiler newbie and was curious if Python's language/grammar
can be handled by a recursive descent parser.

Well?

Chris

Sep 28 '06 #1
4 1945
se******@spawar .navy.mil wrote:
I'm a compiler newbie and was curious if Python's language/grammar
can be handled by a recursive descent parser.
I believe a recursive descent parser can handle any grammar; it just
depends on how pure you want it to be.

--
Ben Sizer

Sep 29 '06 #2

Ben Sizer wrote:
se******@spawar .navy.mil wrote:
I'm a compiler newbie and was curious if Python's language/grammar
can be handled by a recursive descent parser.

I believe a recursive descent parser can handle any grammar; it just
depends on how pure you want it to be.

--
Ben Sizer
Thanks! What do you mean by 'pure'?

Chris

Sep 29 '06 #3
On 2006-09-28, se******@spawar .navy.mil <se******@spawa r.navy.milwrote :
I'm a compiler newbie and was curious if Python's language/grammar
can be handled by a recursive descent parser.
IIUC the python grammer is LL(1) and the development team is commited
to keeping it LL(1).

LL(1) languages can be handled by a recursive descent parser.

--
Antoon Pardon
Sep 29 '06 #4
se******@spawar .navy.mil wrote:
Ben Sizer wrote:
se******@spawar .navy.mil wrote:
I'm a compiler newbie and was curious if Python's language/grammar
can be handled by a recursive descent parser.
I believe a recursive descent parser can handle any grammar; it just
depends on how pure you want it to be.

--
Ben Sizer

Thanks! What do you mean by 'pure'?
By 'pure' I mean entirely recursive and not iterative. Implementation
becomes easier if you're not writing a purely recursive parsing
program, and it makes it more practical to implement an arbitrary
amount of 'read-ahead'.

--
Ben Sizer

Oct 2 '06 #5

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

Similar topics

4
1912
by: Magnus Lie Hetland | last post by:
Hi! I've been looking at ways of dealing with nested structures in regexps (becuase I figured that would be faster than the Python parsing code I've currently got) and came across a few interesting things... First there is this, mentioning the (?<DEPTH>) and (?<-DEPTH>) constructs of the .NET regexp matcher: ...
1
5275
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o Modules/python.c gcc -pthread -c...
0
1487
by: Phlip | last post by:
C++ newsgroupies: I wrote a parser to solve math expressions like "3.0 ^(4 - 5)", or "3 / 8". Below my sig is recursiveDescentParser.cpp, the test suite that drove the implementation of the expression solver found in recursiveDescentParser.h, in a parallel post. Test-Driven Development works by accumulating assertions. Before the very...
6
1893
by: Phlip | last post by:
C++ newsgroupies: I wrote a parser to solve math expressions like "3.0 ^(4 - 5)", or "3 / 8". It's bad luck to name an interface after its implementation. This file could have been "expressionSolver.h". But naturally, if I set out to implement recursive descent parsing, that tainted my filename selection. Below my sig is...
6
2421
by: Jon Shemitz | last post by:
I just wrote my second method that reads an XML stream with XmlReader and spits out a instance of an object that represents the XML stream. In effect, this was a simple recursive descent parser that uses the XmlReader as a tokenizer. Realizing this naturally led to the question: Are there any tools which would let me supply a description of...
4
2803
by: siddharthkhare | last post by:
Hi All, I need to parse certain text from a paragraph (like 20 lines). I know the exact tags that I am looking for. my approach is to define a xml (config) file that defines what tag I am looking for and corresponding regular expression to search for the pattern. Xml file will also have a way to say what should be the pervious tag
9
3317
by: seberino | last post by:
I'm a compiler newbie and curious if Python grammar is able to be parsed by a recursive descent parser or if it requires a more powerful algorithm. Chris
18
4703
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: from pyparsing import * grammar = OneOrMore(Word(alphas)) + Literal('end') grammar.parseString('First Second Third end')
1
1103
by: Robert | last post by:
especially if the grammar is non-standard.
0
7792
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...
0
8149
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. ...
0
8304
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...
1
5674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5364
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...
0
3805
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...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1138
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.