473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

parse tree help

Hi Guys,
I am trying to build a Parse Tree with the following grammar. I have
implemented my insertions using a standard binary tree inserting
algorithm. With the psuedocode below, can you guys provide any helpful
feedback to placing insert statements into building nodes of the tree.
Any suggestions on how to build the tree will be appreciated.
I hope to build the tree to look like that
5+4

Goal
|
|
|
Expr
|
|
Term
|
Factor
|
|
+
/ \
5 4

eprime()
/*Expr' -+ Term Expr' */
/* Expr' -- Term Expr'*/

if(word = t or word = -) then
word <-NextWord()
if(Term()=false)
then return false;
else return Eprime();
/*Expr' -Empty Set */
return true;
Term()
/*Term -Factor Term'*/
if(factor()=false)
then return false
else return Tprime()
Tprime ()
/* Term' -x factor Term' */
/*Term' -/ factor Term'*/
if (word = x or word = / )
Word=NextWord()
if(factor () = false)
then return false;
then return TPrime();
/*Term' -Empty Set */
return True;
Factor()
/*Factor -(Expr) */
if(word = '(' ) then
word<-Nextword();
if(Expr()-false)
then return false
else if (word != ')') then
return false;
/*Factor ->Num*/
/*Factor->ident*/

else if(word!= Num and word != ident) then
report syntax error
return false;

word <- Nextword()
return true;

Main()
/* goal-Expr */
Word <-Nextword()
if(expr() and word=eof)
then proceed to the next step
else return false

Expr()
/*Expr -Term Expr' */
if(Term ()= false)
then return false
else return Eprime()
Mar 30 '08 #1
1 2657
uche wrote:

Please don't multi-post on Usenet.

comp.programming is possibly the best group for this question.

--
Ian Collins.
Mar 30 '08 #2

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

Similar topics

0
by: Chad Whitacre | last post by:
Hey all, I've been playing around with the parser module, and based on the documentation I would expect all symbols in a parse tree to be part of the grammar. For example, I find this line in...
1
by: Neil Zanella | last post by:
Hello, When I save the following file with the .xhtml or .xml extension I get the XML parse tree and the following message instead of the actual document. This XML file does not appear to...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
0
by: asahin | last post by:
hi all; i need ability to change a page's looking at run-time by changing aspx page or construct control tree via reading a previously defined template. is there any way to parse an aspx...
4
by: TwinT | last post by:
Hi. I've got a small problem with parse trees... first off, I don't exactly know what it is. I'm a newbie, in a way, but I've been bravely trying to learn my way through all the confusion out in...
2
by: marc.wyburn | last post by:
I'm playing with XML and elementtree and am missing something but I'm not sure what...? I've create an XML file with Elementtree with a root of backup.xml. Attached to the root is a dirob and the...
0
by: reachurajay | last post by:
Hi all, I want to create a parse tree to tag the reference part separately. The reference part contains first name, last name, book title, edition number, book volume number, book page number,...
3
by: Bint | last post by:
Hi, I'm trying to parse an xml file into an array tree. From the PHP site in the comments, I got this code. But it doesn't work for me. It's saying that the passed variable is not an array or...
0
by: snc85 | last post by:
Hi! can anyone help me to parse some string into tree... I have Q function, this is something like "if else" for example: Q<VSecCode=0?B0+B2:B1>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.