Project: KCL (Provisioning / Automation & Configuration)
File: 5.source_code.md

The `kcl-lang/kcl` repository consists of a single large cargo workspace. The repository consists of three main directories: `kclvm` contains the source code for the KCL core. It consists of many crates that together make up the compiler. `compiler_base` contains a set of basic libraries for compilers, which are dependent on `kcl` `scripts` contains the source code and image build scripts. `test` contains the compiler grammar integration tests. `kclvm` contains the source code for the KCL core. It consists of many crates that together make up the compiler. `api` contains over ten important APIs of KCL, including parsing code, running code, toolchain APIs, etc. It is the interface layer of KCL Rust core and other multi language SDKs of KCL, such as kcl-go, kcl-py, and kcl-java. `ast` contains the core Abstract Syntax Tree (AST), tree walker and token definitions. `ast_pretty` contains the tools and utilities to format and print the AST in a human-readable way. `cmd` houses the command-line interface tools, enabling the users to interact with the compiler via the command-line such as `kclvm_cli` binary. `compiler` contains the main compilation logic, responsible for converting the high-level KCL code into an intermediate representation before it is executed further. `config` holds configuration-related code, including parsing command-line arguments, handling configuration files, and managing compiler settings. `error` includes definitions and handlers for error messages, diagnostics, and compiler warnings to assist with debugging and user feedback. `evaluator` is where the logic for evaluating expressions and executing KCL code resides. This often involves the runtime environment and can include the computation of values and handling of user-defined functions. `lexer` is responsible for breaking down the raw KCL source into a stream of tokens (lexical analysis), which are then fed to the parser. `loader` handles the loading and management of KCL modules, including discovering, parsing, and assembling modules from different sources into the compiler workflow. `macros` contains macro definitions and utilities for code generation and automating repetitive coding patterns within the compiler source code itself. `parser` takes the stream of tokens from the lexer and constructs the AST, which represents the syntactic structure of the KCL code. `query` manages code queries and information retrieval, such as finding or replacing the definition of a variable, within the KCL programs. `runner` provides the functionality to execute compiled KCL programs directly, managing the setup and invocation of the KCL runtime environment. `runtime` includes the runtime support necessary for executing KCL, such as memory management, value representation, and built-in functions. `sema` or `semantic analysis` contains the code for type checking, validation, and other analyses to ensure that the KCL programs follow predefined semantic rules. `spec` houses the code related to the specification of the KCL language, which may include language versioning, feature definitions, syntax rules and API definitions. `tools` contains additional utilities supporting the compiler, such as code formatters, linters, language server and development scripts for assisting in compiler maintenance and enhancement. `utils` includes a collection of helper functions and common routines that are used across various parts of the project. `version` holds the code responsible for managing the versioning of the KCL compiler, including setting, updating, and displaying version information.