• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

parsing stream data into an object tree

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I'm trying to figure out an elegant solution to parsing stream data into an object tree. What I want to do is probably very similar to the way a DocumentBuilder builds a DOM tree from an xml stream. Can someone recommend a design pattern or code snipplet out there somewhere which might provide some guidance? I'd look at the implementation of some of the java xml parsers out there but most of the code bases are pretty large and I don't have the time right now.
Thanks in advance

Jason
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This depends a lot on the nature of the syntax being parsed. If it is simple enough that a basic recursive-descent parser can be used, then you can write a basic "optimistic" parser quite easily. The more complex your syntax becomes (particularly in the area of requiring lookahead to determine meaning), the harder it is to write a correct parser.

For a fairly simple recursive-descent example, take a look at the JSON parser I wrote recently.
 
Jason Nesbitt
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perfect. Thanks Frank!
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic