Spicy
ctor.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <string>
6 #include <utility>
7 
8 #include <hilti/ast/expressions/ctor.h>
9 
10 #include <spicy/compiler/detail/codegen/production.h>
11 
13 
16 public:
17  Ctor(const std::string& symbol, spicy::Ctor ctor, const Location& l = location::None)
18  : ProductionBase(symbol, l), _ctor(std::move(ctor)) {}
19 
20  spicy::Ctor ctor() const { return _ctor; };
21  Expression expression() const { return hilti::expression::Ctor(_ctor); }
22  std::optional<spicy::Type> type() const { return _ctor.type(); }
23  bool nullable() const { return false; }
24  bool eodOk() const { return nullable(); }
25  bool atomic() const { return true; }
26  bool supportsSynchronize() const { return hasSize() && maySynchronize(); }
27  int64_t tokenID() const { return production::tokenID(hilti::util::fmt("%s|%s", _ctor, _ctor.type())); }
28  std::string render() const { return hilti::util::fmt("%s (%s)", _ctor, _ctor.type()); }
29 
30 public:
31  spicy::Ctor _ctor;
32 };
33 
34 } // namespace spicy::detail::codegen::production
const std::string & symbol() const
Definition: production.h:196
bool maySynchronize() const
Definition: production.h:188
bool hasSize() const
Definition: production.h:185
Definition: production.h:170
Definition: grammar.h:15
Definition: production.h:25
std::string fmt(const char *fmt, const Args &... args)
Definition: util.h:80
Definition: location.h:17
Definition: ctor.h:14
ProductionBase(std::string symbol, Location l=location::None)
Definition: production.h:181