Parse cpp_member_variable and cpp_bitfield
This commit is contained in:
parent
51bdbca81d
commit
c87b296d4e
8 changed files with 238 additions and 18 deletions
|
|
@ -8,6 +8,18 @@
|
|||
|
||||
using namespace cppast;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string get_expression_str(detail::token_stream& stream)
|
||||
{
|
||||
// just concat everything
|
||||
std::string expr;
|
||||
while (!stream.done())
|
||||
expr += stream.get().c_str();
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_expression> detail::parse_expression(const detail::parse_context& context,
|
||||
const CXCursor& cur)
|
||||
{
|
||||
|
|
@ -17,12 +29,8 @@ std::unique_ptr<cpp_expression> detail::parse_expression(const detail::parse_con
|
|||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||
detail::token_stream stream(tokenizer, cur);
|
||||
|
||||
// just concat everything
|
||||
std::string expr;
|
||||
while (!stream.done())
|
||||
expr += stream.get().c_str();
|
||||
|
||||
auto type = parse_type(context, clang_getCursorType(cur));
|
||||
auto expr = get_expression_str(stream);
|
||||
|
||||
if (kind == CXCursor_CharacterLiteral || kind == CXCursor_CompoundLiteralExpr
|
||||
|| kind == CXCursor_FloatingLiteral || kind == CXCursor_ImaginaryLiteral
|
||||
|
|
@ -32,3 +40,13 @@ std::unique_ptr<cpp_expression> detail::parse_expression(const detail::parse_con
|
|||
else
|
||||
return cpp_unexposed_expression::build(std::move(type), std::move(expr));
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_expression> detail::parse_raw_expression(const parse_context& context,
|
||||
token_stream& stream,
|
||||
const CXType& type)
|
||||
{
|
||||
if (stream.done())
|
||||
return nullptr;
|
||||
auto expr = get_expression_str(stream);
|
||||
return cpp_unexposed_expression::build(parse_type(context, type), std::move(expr));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue