antlr3 icon indicating copy to clipboard operation
antlr3 copied to clipboard

ANTLR3 C++ Target HPUX error

Open Gariben opened this issue 9 years ago • 2 comments

If you try to build the C++ Target in HPUX, somehow the pair <ANTLR_MARKER, TokenType> in the TokensType::iterator has a different value than the reference... the ANTLR_MARKER becomes const-qualified, and therefore you can't dereference the pair, breaking any instances with TokensType::iterators being dereferenced.

I don't know why this is happening, but I was able to get it to build by const qualifying the UnOrderedMapType and OrderedMapType in antlr3memory.h:

template<class KeyType, class ValueType>
class UnOrderedMapType : public std::map< KeyType, ValueType, std::less<KeyType>, 
                                    AllocatorType<std::pair<const KeyType, ValueType> > >
{
};

template<class KeyType, class ValueType>
class OrderedMapType : public std::map< KeyType, ValueType, std::less<KeyType>, 
                                    AllocatorType<std::pair<const KeyType, ValueType> > >
{
};

Here's a bit more thorough discussion: https://groups.google.com/forum/#!topic/antlr-discussion/3OU9s4mfXgk

Gariben avatar Jan 06 '16 16:01 Gariben

I'm seeing a related issue in even the very simple demo grammar distributed with the Cpp runtime, when building on OSX with a modern clang.

TParser.cpp:294:17: error: assigning to 'ImplTraits::CommonTokenType *' (aka 'antlr3::CommonToken<antlr3::Traits<User::TLexer, User::TParser, UserTraits, antlr3::Empty> > *') from incompatible type 'const CommonTokenType *' (aka 'const antlr3::CommonToken<antlr3::Traits<User::TLexer, User::TParser, UserTraits, antlr3::Empty> > *')
            ID1 =  this->matchToken(ID, &FOLLOW_ID_in_method96);

This was using ANTLR 3.5.2, which while purportedly non supported by the Cpp target is distributed with it, and I can't seem to track down an earlier release to test with. I may have to abandon ANTLR entirely given the very sorry state of C/C++ support (I just backported my grammar from v4 since the claim was that v3 had just fine support).

elfprince13 avatar Jan 13 '16 17:01 elfprince13

Try it with this branch: https://github.com/ibre5041/antlr3 (the tool and runtime). I think I fixed it several months ago.

ibre5041 avatar Jan 17 '16 09:01 ibre5041