Boost logo

Boost Users :

Subject: [Boost-users] [spirit] parsing keyword or identifier
From: Brian Budge (brian.budge_at_[hidden])
Date: 2011-05-02 20:52:11


HI all -

I have what I think is a simple problem: I'm trying to parse IES
files, and there is a line that can have three options:

TILT=NONE
-or-
TILT=INCLUDE
-or-
TILT=<filename>

The way I'm trying to parse this line is:

   // in the case of TILT=INCLUDE or TILT=<filename>
    int lampToLuminaireGeom;
    int numPairsWithMulFactors = 0;

   std::string tiltFileName;

    BOOST_AUTO(keywordSym, (qi::lit("NONE") | qi::lit("INCLUDE")));
    BOOST_AUTO(fileName, *char_ - keywordSym);

    BOOST_AUTO(initial, ( "TILT" >> char_('=') >>
                          ( "NONE" |
                            ( "INCLUDE" >>
                              int_[ref(lampToLuminaireGeom) = _1] >>
                              int_[ref(numPairsWithMulFactors) = _1] ) |
                            fileName[ref(tiltFileName)] ) ) );

    if(!phrase_parse(first, last, initial, space)) {
        return IES_INVALID;
    }

The code works with NONE or INCLUDE, but not with files. As far as I
know, there are no real restrictions on the filenames. At this point,
the code posted above can't even get simple file names, but really I
think what is required is that I grab anything non-whitespace after
the '=' until it reaches an EOL.

Can anyone provide some insight about what I may be doing wrong?

Thanks,
  Brian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net