lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing, and parsimony [Was: [lmi] overview of C++ expression template l


From: Greg Chicares
Subject: Parsing, and parsimony [Was: [lmi] overview of C++ expression template libraries]
Date: Tue, 06 Sep 2005 14:15:30 +0000
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

On 2005-9-6 13:47 UTC, Greg Chicares wrote:
> 
>    using boost::spirit as a parser (so we'd have RPN) and boost::phoenix
>    instead of boost::lambda (because the same author wrote spirit and
>    phoenix).

In 'input_sequence.?pp' we have a hand-coded recursive-descent parser.
It's a lot like Stroustrup's example in TC++PL3, which in turn is a lot
like the example in the Red Dragon Book. It's 1526 lines of code to
maintain, or 3222 if you count '*seq*.?pp'.

I gag when people ask for enhancements to this "little language"; but
it does need enhancements, and this all ties in with another project
we've discussed, the "pop-up input-sequence editor".

The grammar is expressed in comments quoted below. They're not exactly
BNF, but they're a starting point for reimplementing this using spirit.
Do you think that would be easier to maintain?

If it's a good idea to use spirit here, then it may be a good idea to
use spirit and phoenix elsewhere, as described above: we'd depend on
fewer libraries.

  // GRAMMAR interval-begin: one of [ (
  // GRAMMAR interval-end: one of ] )

  // GRAMMAR duration-constant: one of inforce retirement maturity
  // TODO ?? 'inforce' not yet implemented

  // GRAMMAR duration-scalar: integer
  // GRAMMAR duration-scalar: @ integer
  // GRAMMAR duration-scalar: # integer
  // GRAMMAR duration-scalar: duration-constant
  // TODO ?? calendar year not yet implemented

  // GRAMMAR duration: duration-scalar
  // GRAMMAR duration: interval-begin duration-scalar , duration-scalar 
interval-end

  // GRAMMAR value: floating-point-number
  // GRAMMAR value: value-constant

  // GRAMMAR span: value
  // GRAMMAR span: value , duration

  // GRAMMAR sequence: span
  // GRAMMAR sequence: span ; span
  // GRAMMAR sequence: series ;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]