3 ms·
> I still chuckle when randos make arguments like "C++ can't be parsed with an LALR parser" I'm not an expert on parsers but I don't think LALR parser can eval
by stepik777 9y ago
> I still chuckle when randos make arguments like "C++ can't be parsed with an LALR parser"
I'm not an expert on parsers but I don't think LALR parser can evaluate constexpr C++ functions which is required for parsing C++.
E.g. in the following code, expression `A<f()>::a * u` will parse either as a variable declaration (int* u) or a multiplication (5 * 5) depending on the value returned by constexpr function f:
template<bool b>
class A
{};
template<>
struct A<true>
{
typedef int a;
};
template<>
struct A<false>
{
static const int a = 5;
};
constexpr bool f() {
return true;
}
const int u = 5;
int main()
{
A<f()>::a * u;
}
- gpderetta 9y agoI think that the OP point is that it doesn't matter much.