llvm/mlir/examples/toy/Ch3/include/toy/AST.h

//===- AST.h - Node definition for the Toy AST ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements the AST for the Toy language. It is optimized for
// simplicity, not efficiency. The AST forms a tree structure where each node
// references its children using std::unique_ptr<>.
//
//===----------------------------------------------------------------------===//

#ifndef TOY_AST_H
#define TOY_AST_H

#include "toy/Lexer.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include <utility>
#include <vector>
#include <optional>

namespace toy {

/// A variable type with shape information.
struct VarType {};

/// Base class for all expression nodes.
class ExprAST {};

/// A block-list of expressions.
ExprASTList;

/// Expression class for numeric literals like "1.0".
class NumberExprAST : public ExprAST {};

/// Expression class for a literal value.
class LiteralExprAST : public ExprAST {};

/// Expression class for referencing a variable, like "a".
class VariableExprAST : public ExprAST {};

/// Expression class for defining a variable.
class VarDeclExprAST : public ExprAST {};

/// Expression class for a return operator.
class ReturnExprAST : public ExprAST {};

/// Expression class for a binary operator.
class BinaryExprAST : public ExprAST {};

/// Expression class for function calls.
class CallExprAST : public ExprAST {};

/// Expression class for builtin print calls.
class PrintExprAST : public ExprAST {};

/// This class represents the "prototype" for a function, which captures its
/// name, and its argument names (thus implicitly the number of arguments the
/// function takes).
class PrototypeAST {};

/// This class represents a function definition itself.
class FunctionAST {};

/// This class represents a list of functions to be processed together
class ModuleAST {};

void dump(ModuleAST &);

} // namespace toy

#endif // TOY_AST_H