java parser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nilotus
    New Member
    • Oct 2013
    • 2

    java parser

    Hello everybody :)
    I've got a question. I want to know how can I write a parser
    "There is a table(dimension : 3 in 4 in 5 meters) in the room"
    in a way that the output would be this:
    Type: table
    Numbers: 1
    Size: 60 M^3
    Position: Room

    I tried substring and split method, but I didn't get the result that I wanted. Could you please help me with this? :( What are the useful methods with which I can write this code?
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Use regular expression.

    But the better way: define an EBNF-like grammar and then use some ready-made method that converts them into a tree of tokens.
    Look in Wikipedia, "Recursive descent parser" for an example.

    Comment

    • Nilotus
      New Member
      • Oct 2013
      • 2

      #3
      Thank you So much :) I read the wikipedia page. It might be a good idea but I want a simpler and shorter way. again thanks :)

      Comment

      Working...