chromium/third_party/openscreen/src/tools/cddl/sema.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TOOLS_CDDL_SEMA_H_
#define TOOLS_CDDL_SEMA_H_

#include <cstdint>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "tools/cddl/parse.h"

struct CddlGroup;

// Represents a type defined in CDDL.
struct CddlType {};

// Override for << operator to simplify logging.
// NOTE: If a new enum value is added without modifying this operator, it will
// lead to a compilation failure because an enum class is used.
inline std::ostream& operator<<(std::ostream& os,
                                const CddlType::Which& which) {}

// Represets a group defined in CDDL.
// TODO(btolsch): group choices
struct CddlGroup {};

// Override for << operator to simplify logging.
// NOTE: If a new enum value is added without modifying this operator, it will
// lead to a compilation failure because an enum class is used.
inline std::ostream& operator<<(std::ostream& os,
                                const CddlGroup::Entry::Which& which) {}

// Represents all CDDL definitions.
struct CddlSymbolTable {};

// Represents a C++ Type, as translated from CDDL.
struct CppType {};

// Override for << operator to simplify logging.
// NOTE: If a new enum value is added without modifying this operator, it will
// lead to a compilation failure because an enum class is used.
inline std::ostream& operator<<(std::ostream& os, const CppType::Which& which) {}

struct CppSymbolTable {};

std::pair<bool, CddlSymbolTable> BuildSymbolTable(const AstNode& rules);
std::pair<bool, CppSymbolTable> BuildCppTypes(
    const CddlSymbolTable& cddl_table);
bool ValidateCppTypes(const CppSymbolTable& cpp_symbols);
void DumpType(CddlType* type, int indent_level = 0);
void DumpGroup(CddlGroup* group, int indent_level = 0);
void DumpSymbolTable(CddlSymbolTable* table);

#endif  // TOOLS_CDDL_SEMA_H_