Spicy
variable.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 <spicy/compiler/detail/codegen/production.h>
9 
11 
19 public:
20  Variable(const std::string& symbol, spicy::Type type, const Location& l = location::None)
21  : ProductionBase(symbol, l), _type(std::move(type)) {}
22 
23  spicy::Type type() const { return _type; }
24  bool nullable() const { return false; }
25  bool eodOk() const { return nullable(); }
26  bool atomic() const { return true; }
27  bool supportsSynchronize() const { return hasSize() && maySynchronize(); }
28  std::string render() const { return hilti::util::fmt("%s", _type); }
29 
30 private:
31  spicy::Type _type;
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:23
Definition: type.h:159
std::string fmt(const char *fmt, const Args &... args)
Definition: util.h:80
Definition: location.h:17
ProductionBase(std::string symbol, Location l=location::None)
Definition: production.h:181