Well, it looks like a flexible way for dealing with this data is to first rip out the 'mandatory' or 'anchored' elements, and then tokenize the rest of the line and examine it word-by-word. Thus I'm not tied to whitespace conventions at all, which is nice.

NOW I have to decide how to package the 'parser'. There are a number of things to think about, including what data should be classed and what data should just exist.

I figure there will have to be a class to represent "The Universe": a top-level container to hold discrete chunks of space, which represent a parsec of data each.

Next, the 'chunk of space' itself must be a class, as it contains zero or more bodies in space. In Traveller parlance this is called a 'hex', though it could more generally be called a 'parsec'.

Next, the bodies themselves must be classes: asteroids, moons, planets, gas giants, and stars. Some of these objects can 'contain' objects in an orbit, and some can contain objects on their surface.

At this point, it might be nice to see if CPAN has some astronometric packages available that I can use instead of writing a half-baked variety of my own.

...well, there are astro modules there, but they only look sort of generically useful -- functions and interfaces for real-life data, etc. Anyone have any suggestions?

In reply to Re: Traveller Parsing by rje
in thread Traveller Parsing by rje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.