const_expr (std::move (const_expr)), locus (locus)
{}
+ ConstantItem (std::string ident, Visibility vis, std::unique_ptr<Type> type,
+ std::vector<Attribute> outer_attrs, location_t locus)
+ : VisItem (std::move (vis), std::move (outer_attrs)),
+ identifier (std::move (ident)), type (std::move (type)),
+ const_expr (nullptr), locus (locus)
+ {}
+
ConstantItem (ConstantItem const &other)
: VisItem (other), identifier (other.identifier), locus (other.locus)
{
// parse constant type (required)
std::unique_ptr<AST::Type> type = parse_type ();
+ // A const with no given expression value
+ if (lexer.peek_token ()->get_id () == SEMICOLON)
+ {
+ lexer.skip_token ();
+ return std::unique_ptr<AST::ConstantItem> (
+ new AST::ConstantItem (std::move (ident), std::move (vis),
+ std::move (type), std::move (outer_attrs),
+ locus));
+ }
+
if (!skip_token (EQUAL))
{
skip_after_semicolon ();