Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Parsing input based on grammar rules

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Parsing input based on grammar rules

    Hi guys, I'm new to the forum here, hoping to contribute as I can. I have a question though.

    I have set grammar rules, some being recursive. I am to create a basic top down parser from scratch (i.e. not using JavaCC or anything like that). I was told to use a queue to create the parse tree.

    I am kind of unsure how to start this.. If i tokenize the input, then that's not really top down right?
    I am thinking i have to recursively expand the grammar rules and constantly check if the leaves match the input string, is this correct? I have looked into recursive descent, but i'm not sure if I can use that here.

    Could anyone point me in the right direction here?

    thanks


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Parsing input based on grammar rules

    Tokenizing and parsing aren't really related. Tokenizing is just taking a string (or something similar) and figuring out what it is, like an operator, number, variable name, etc. Parsing is getting the computer to figure out what order those tokens should be used based off of your grammer.

    You can either tokenize your entire string first or you can tokenize each token as your parser looks for the next token.

    I've never personally created a top-down parser, but you can take a look at LL parsers to see an example of a top-down parser algorithm.

Similar Threads

  1. Content Based Image Retrieval
    By sanjay_jbp in forum AWT / Java Swing
    Replies: 9
    Last Post: March 1st, 2010, 08:55 PM
  2. Exception-Based Problem
    By Hax007 in forum Exceptions
    Replies: 1
    Last Post: December 10th, 2009, 03:53 AM
  3. Input file parsing to insert into DB
    By IDForums in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 30th, 2009, 02:29 AM
  4. Com based component project using Java
    By jazz2k8 in forum Java Native Interface
    Replies: 1
    Last Post: October 7th, 2008, 10:54 PM