mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 08:10:10 +01:00
This change creates an unpleasant amount of boilerplate where `Declaration` is declared, in exchange for being able to—very pleasantly—treat it as a simple value that composes with other values everywhere it is used. Applying this technique broadly will pay off in code comprehensibility; once it has been done for all things being new'd, pointers disappear and references are only needed as an idiomatic approximation of inout. The unpleasant code grows only when new polymorphic operations are added, and then only a bit, and is an idiom whose details can readily be ignored once in place. The pleasant code pervades the codebase. Too bad we don't have existential types in C++ ;-)
30 lines
854 B
C++
30 lines
854 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// Helpers should be added here when logic in syntax.ypp is more than a single
|
|
// statement. The intent is to minimize the amount of C++ in the .ypp file, to
|
|
// improve ease of maintenance.
|
|
|
|
#ifndef EXECUTABLE_SEMANTICS_EXEC_H_
|
|
#define EXECUTABLE_SEMANTICS_EXEC_H_
|
|
|
|
#include <list>
|
|
|
|
#include "executable_semantics/ast/declaration.h"
|
|
|
|
namespace Carbon {
|
|
|
|
// Initialized by main(), and used when printing errors.
|
|
extern char* input_filename;
|
|
|
|
// Prints errors.
|
|
void PrintSyntaxError(char* error, int line_num);
|
|
|
|
// Runs the top-level declaration list.
|
|
void ExecProgram(std::list<Declaration>* fs);
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // EXECUTABLE_SEMANTICS_EXEC_H_
|