antlr3
antlr3 copied to clipboard
ANTLR3 C++ Target HPUX error
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
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).
Try it with this branch: https://github.com/ibre5041/antlr3 (the tool and runtime). I think I fixed it several months ago.