Boost logo

Boost :

From: Nico Massi (desertswat_at_[hidden])
Date: 2004-07-19 15:45:15


Ok here is a slightly simplified version of MyGrammar ( MySkipGrammer is
simply space_p | comment_p( ';' ) ).
But it also generates the same error. The first run works as expected and
the second run seems to still hold old references.

class MyGrammar : public boost::spirit::grammar<MyGrammar>
{
public:

        std::vector<Group>& vGroups;
        std::vector<std::string>& vLibraries;

        MyGrammar( std::vector<std::string>& rvLibraries, std::vector<Group>&
rvGroups ) : vGroups(rvGroups), vLibraries(rvLibraries) { }

        template <typename ScannerT>
        struct definition
        {
                // rule deklarations here

                Group kCurrentGroup;
                std::vector<Group> vTmpGroups;
                std::list<Group> vFullGroups;
                std::vector<std::string vLibs;

                definition( const MyGrammar& rkSelf )
                {
                        startRule = (*group)[ copy_a( rkSelf.vGroups, vFullGroups )
][ copy_a( rkSelf.vLibraries, vLibs ) ];

                        group =
                                groupID[ assign_a( kCurrentGroup.id, id ) ]
>> ch_p( '{' )
>> groupDefinition
>> *( eps_p(as_lower_d[str_p("group")])[ push_back_a( vTmpGroups,
kCurrentGroup ) ]
>> group[ my_assign_a( kCurrentGroup, vTmpGroups )
][ pop_back_a( vTmpGroups ) ]
                                        )
>> ch_p( '}' )[ push_front_a( vFullGroups, kCurrentGroup ) ];
        
                        groupID =
                                as_lower_d[ str_p( "group" ) ]
>> confix_p( '(', uid[ assign_uid( id ) ], ')' );

                        groupDefinition =
                                name[ assign_a( kCurrentGroup.name, strName ) ]
>> description[ assign_a( kCurrentGroup.description, desc ) ];

                        name =
                                as_lower_d[ str_p( "name" ) ]
>> ch_p( '=' )
>> identifier[ assign_a( strName ) ];

                        description =
                                as_lower_d[ str_p( "description" ) ]
>> ch_p( '=' )
>> confix_p( '"', (*anychar_p)[ assign_a( desc ) ], '"' );

                        library =
                                as_lower_d[ str_p( "library" ) ]
>> ch_p( '=' )
>> identifier[ assign_a( lib ) ][ push_back_unique_a( vLibs ) ];

                        identifier =
                                lexeme_d
                                [* ( range_p( 'a', 'z' )
                                        | range_p( 'A', 'Z' )
                                        | ch_p('_')
                                        )
                                ];

                        uid =
                                lexeme_d
                                [ repeat_p(8)[ range_p( 'A', 'F') | range_p( '0', '9' ) ]
>> ch_p( '-' )
>> repeat_p(4)[ range_p( 'A', 'F') | range_p( '0', '9' ) ]
>> ch_p( '-' )
>> repeat_p(4)[ range_p( 'a', 'f') | range_p( '0', '9' ) ]
>> ch_p( '-' )
>> repeat_p(4)[ range_p( 'A', 'F') | range_p( '0', '9' ) ]
>> ch_p( '-' )
>> repeat_p(12)[ range_p( 'A', 'F') | range_p( '0', '9' )]
                                ];
                }
                const rule<ScannerT>& start() const { return startRule; }
        }
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk