11 Replies - 4894 Views - Last Post: 03 March 2012 - 02:36 PM Rate Topic: -----

#1 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Recursive Descent Parser

Posted 02 March 2012 - 05:39 PM

Hey guys, so I'm working on an assignment for school and we are to create a Recursive Descent Parser program. It will take a string and then generate all the substrings of it. I was wondering if someone could help out a bit. I'm having a tough time wrapping my head around the algorithm to get started. Any help would be awesome. I've been googling it and still trying to understand it
Is This A Good Question/Topic? 0
  • +

Replies To: Recursive Descent Parser

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Recursive Descent Parser

Posted 02 March 2012 - 05:59 PM

So ? What do you have produce as code so far ?
And which problem(s) do you have with it ?
Was This Post Helpful? 0
  • +
  • -

#3 blackcompe   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1159
  • View blog
  • Posts: 2,547
  • Joined: 05-May 05

Re: Recursive Descent Parser

Posted 02 March 2012 - 07:53 PM

Quote

I'm having a tough time wrapping my head around the algorithm to get started. Any help would be awesome. I've been googling it and still trying to understand it


That's because a recursive descent parser doesn't do that. If you want to know about them, check out the section on top-down parsing in my parsing tutorial. RD parsers build abstract representations of the syntactical structure of a string for some language.

Quote

It will take a string and then generate all the substrings of it.


If I have the word "fooba" I might generate all sub strings as follows:

f
fo
foo
foob
fooba

o
oo
oob
ooba

o
ob
oba

b
ba


See the pattern? Use a set, and all duplicates will be removed.

This post has been edited by blackcompe: 02 March 2012 - 07:54 PM

Was This Post Helpful? 0
  • +
  • -

#4 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Re: Recursive Descent Parser

Posted 02 March 2012 - 10:40 PM

View Postblackcompe, on 02 March 2012 - 07:53 PM, said:

Quote

I'm having a tough time wrapping my head around the algorithm to get started. Any help would be awesome. I've been googling it and still trying to understand it


That's because a recursive descent parser doesn't do that. If you want to know about them, check out the section on top-down parsing in my parsing tutorial. RD parsers build abstract representations of the syntactical structure of a string for some language.

Quote

It will take a string and then generate all the substrings of it.


If I have the word "fooba" I might generate all sub strings as follows:

f
fo
foo
foob
fooba

o
oo
oob
ooba

o
ob
oba

b
ba


See the pattern? Use a set, and all duplicates will be removed.



so if that isn't the function of a RDP then what is my teacher trying to get us to do? because all the stuff that I have been reading on a RDP says some weird stuff that i'm just not understanding
Was This Post Helpful? 0
  • +
  • -

#5 blackcompe   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1159
  • View blog
  • Posts: 2,547
  • Joined: 05-May 05

Re: Recursive Descent Parser

Posted 03 March 2012 - 07:08 AM

Quote

so if that isn't the function of a RDP then what is my teacher trying to get us to do?


How would I know? Does the assignment have a public URL?

Quote

because all the stuff that I have been reading on a RDP says some weird stuff that i'm just not understanding


What's this weird stuff you're referring too. It's as simple as looking up RD Parsing on Wikipedia. As you can see, it has nothing to do with generating sub-strings and to my knowledge it can't be used to do so.
Was This Post Helpful? 0
  • +
  • -

#6 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Re: Recursive Descent Parser

Posted 03 March 2012 - 08:59 AM

this is the assignment pdf just copied everything in

[code]
CSCD211 – Programming Principles II 11/3/2011
Assignment – Recursive Descent Parser 50 points See Blackboard for due date
Implement a class called SubstringGenerator that uses recursion to generate all substrings of a given String. For example, the substrings of the string "Sluggo" are the 22 strings:
Sluggo
Slugg
Slug
Slu
Sl
S
luggo
lugg
lug
lu
l
uggo
ugg
ug
u
ggo
gg
g
go
g
o
""
You are not allowed to use any loops to build the substrings -- at least in your final product. You may, however, find it productive to solve the problem using loops first, and then translate to recursive code.
Implement a class called SubstringTester that is used to interact with the user and allow for testing of the SubstringGenerator class. This class should
 Get a string from the user
 Generate the substrings of the string
CSCD211 – Programming Principles II 11/3/2011
 Display the substrings
 Repeat the above three things until the user chooses to quit
Javadoc
Additionally, this assignment requires that you ‘Javadoc’ your source code. That is, your source code must conform to the Javadoc documentation standards. See ‘Course Documents’ for Javadoc examples.
To Turn In
Turn in all source code in a single zip file. Name your zip file as usual. Submit to Blackboard.
Note
You should not have a great deal of code for this assignment -- think about it -- its recursion :-)
[\code]
Was This Post Helpful? 0
  • +
  • -

#7 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: Recursive Descent Parser

Posted 03 March 2012 - 09:05 AM

If I'd had to guess the assignment is under the heading "recursive descent parser" because it prepares you for the topic of recursive descent parsing by getting you familiar with recursion. I don't see anything in the actual text of the assignment that suggests you're actually supposed to implement a recursive descent parser.

If I were you, I'd simply ignore the heading and just solve the assignment normally (using recursion).
Was This Post Helpful? 0
  • +
  • -

#8 blackcompe   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1159
  • View blog
  • Posts: 2,547
  • Joined: 05-May 05

Re: Recursive Descent Parser

Posted 03 March 2012 - 09:08 AM

Yes, it's just asking you to use recursion to solve the problem. Nothing to do with RDP. You should tell your professor to change that -- it's quite misleading.
Was This Post Helpful? 0
  • +
  • -

#9 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Re: Recursive Descent Parser

Posted 03 March 2012 - 09:09 AM

i will suggest that thanks guys! if i have any issues solving it i will definitely come back here for some help :D
Was This Post Helpful? 0
  • +
  • -

#10 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Re: Recursive Descent Parser

Posted 03 March 2012 - 11:27 AM

where in the world is the edit button!
Was This Post Helpful? 0
  • +
  • -

#11 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: Recursive Descent Parser

Posted 03 March 2012 - 12:21 PM

You won't have access to the edit button until you have a certain amount of posts. Its to prevent new members from removing their code when they have got their answers.
Was This Post Helpful? 1
  • +
  • -

#12 kevorski   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 29-January 12

Re: Recursive Descent Parser

Posted 03 March 2012 - 02:36 PM

makes sense, thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1