Spicy
enclosure.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 #include <vector>
8 
9 #include <spicy/ast/types/unit.h>
10 #include <spicy/compiler/detail/codegen/production.h>
11 
13 
20 public:
21  Enclosure(const std::string& symbol, Production child, const Location& l = location::None)
22  : ProductionBase(symbol, l), _child(std::move(child)) {}
23 
24  const Production& child() const { return _child; }
25 
26  // Production API
27  std::vector<std::vector<Production>> rhss() const { return {{_child}}; };
28  std::optional<spicy::Type> type() const { return _child.type(); }
29  bool nullable() const { return production::nullable(rhss()); }
30  bool eodOk() const { return nullable(); }
31  bool atomic() const { return false; }
32  std::string render() const { return _child.symbol(); }
33 
34 
35  Production _child;
36 };
37 
38 } // namespace spicy::detail::codegen::production
Definition: production.h:24
Definition: production.h:120
const std::string & symbol() const
Definition: production.h:191
Definition: production.h:170
Definition: grammar.h:15
Definition: location.h:18
ProductionBase(std::string symbol, Location l=location::None)
Definition: production.h:181