### Install and Build Civet LSP Packages Source: https://github.com/danielxmoore/civet/blob/main/lsp/README.md Installs all dependencies and builds the server and monaco packages from the repository root. ```bash pnpm install pnpm -C lsp/server build pnpm -C lsp/monaco build ``` -------------------------------- ### Install Dependencies Source: https://github.com/danielxmoore/civet/blob/main/integration/eslint/README.md Install the Civet ESLint plugin, Civet, ESLint, and optionally typescript-eslint. This command is for development or project setup. ```sh npm install -D eslint-plugin-civet @danielxmoore/civet eslint @eslint/js typescript-eslint ``` -------------------------------- ### Install Dependencies and Build Civet Source: https://github.com/danielxmoore/civet/blob/main/CONTRIBUTING.md Standard commands to install project dependencies and build the Civet compiler. Ensure you have pnpm installed. ```sh pnpm install pnpm build ``` -------------------------------- ### Start Local Development Server Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Starts a local development server for previewing your Astro site during development. Accessible at localhost:3000. ```bash npm run dev ``` -------------------------------- ### Install Dependencies and Generate Parser Source: https://github.com/danielxmoore/civet/blob/main/lsp/tree-sitter/README.md Navigate to the tree-sitter directory, install dependencies using pnpm, and then run the generate script to create the parser. ```bash cd lsp/tree-sitter pnpm install pnpm run generate ``` -------------------------------- ### Install and Run Civet CLI Source: https://github.com/danielxmoore/civet/blob/main/README.md Commands for installing Civet globally, running its REPL, transpiling code, and executing Civet scripts. ```bash npm install -g @danielx/civet civet civet -c civet < source.civet > output.ts civet source.civet ...args... node --import @danielx/civet/register source.civet npm install -g typescript civet --typecheck ``` -------------------------------- ### Configure Neovim for Civet LSP Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/integrations.md Set up Neovim to recognize Civet files and start the Civet language server. Ensure the path to the server is correct for your installation. ```lua vim.filetype.add({ extension = { civet = "civet" } }) vim.api.nvim_create_autocmd("FileType", { pattern = "civet", callback = function(args) vim.lsp.start({ name = "civet_lsp", cmd = { "node", "/path/to/civet/lsp/server/dist/node.js", "--stdio" }, root_dir = vim.fs.root(args.file, { "tsconfig.json", "package.json", ".git" }) or vim.fn.getcwd(), }) end, }) ``` -------------------------------- ### Run Development Server Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/nextjs/README.md Commands to start the Next.js development server. ```bash npm run dev # or pnpm dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Installs all the necessary dependencies for your Astro project. ```bash npm install ``` -------------------------------- ### Install Dependencies Source: https://github.com/danielxmoore/civet/blob/main/lsp/vscode/CONTRIBUTING.md Installs project dependencies using pnpm from the repository root. ```bash pnpm install ``` -------------------------------- ### Install Civet Language Server for Zed Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/integrations.md Install the Civet language server globally using npm. This is required for Zed's LSP integration. ```bash npm install -g @danielx/civet-language-server ``` -------------------------------- ### Install Civet Globally Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Install Civet globally for command-line usage, enabling the 'civet' command. ```sh npm i -g @danielx/civet ``` -------------------------------- ### Example Hera Transpiler Plugin for Civet Source: https://github.com/danielxmoore/civet/blob/main/lsp/vscode/README.md This JavaScript example demonstrates how to create a custom transpiler plugin for Civet using Hera. It specifies the file extension, target output, and the compilation logic. ```javascript import Hera from "@danielx/hera" const { compile: heraCompile } = Hera export default { transpilers: [{ extension: ".hera", target: ".cjs", compile: function (path, source) { const code = heraCompile(source, { filename: path, }) return { code } } }], } ``` -------------------------------- ### Static Block Initialization in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Illustrates the use of a static block for asynchronous initialization or setup within a class. ```civet class Civet @ try this.colors = getCivetColors() ``` -------------------------------- ### Compile Civet files with Gulp Source: https://github.com/danielxmoore/civet/blob/main/integration/gulp/README.md This snippet shows the basic setup for compiling .civet files to JavaScript using gulp-civet. Ensure you have gulp-civet and Civet installed. ```javascript const civet = require('gulp-civet'); gulp.task('civet', () => { gulp.src('./src/*.civet') .pipe(civet({ extension: '.js', js: true, }) .pipe(gulp.dest('./dist')); }); ``` -------------------------------- ### Install Civet Tree-sitter Grammar in Neovim Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/integrations.md After registering the Civet tree-sitter grammar, install it using the Neovim tree-sitter plugin command. ```vim :TSInstall civet ``` -------------------------------- ### JSON Configuration for Parse Options Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of a JSON configuration file specifying parse options for Civet. ```json { "parseOptions": { "objectIs": true, "implicitReturns": false, "tab": 2 } } ``` -------------------------------- ### JSON Configuration with tsConfig Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of a JSON configuration file including tsConfig for compiler options. ```json { "tsConfig": { "compilerOptions": { "target": "es2020", "strict": true }, "include": ["src"], "exclude": ["dist"] } } ``` -------------------------------- ### Civet Plugin Configuration Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of configuring the Civet unplugin with parse options. ```javascript civetPlugin({ parseOptions: { objectIs: true, implicitReturns: false, tab: 2, }, }) ``` -------------------------------- ### Getters and Setters in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Provides examples of defining getter and setter methods for class properties. ```civet class C get x @coords?.x ?? 0 set x(newX) @moveTo newX, @coords.y ``` -------------------------------- ### JSON Configuration for Array Options Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of a JSON configuration file specifying array-based parse options like globals and operators. ```json { "parseOptions": { "globals": ["React", "JSX"], "operators": ["min", "max"] } } ``` -------------------------------- ### Civet Compile API Configuration Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of using the Civet compile API with parse options. ```javascript import {compile} from "@danielx/civet" const code = await compile(civetCode, { parseOptions: { objectIs: true, implicitReturns: false, tab: 2, }, }) ``` -------------------------------- ### Get Help with Astro CLI Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Displays help information for using the Astro CLI and its various commands. ```bash npm run astro -- --help ``` -------------------------------- ### CoffeeHereCommentStart Syntax Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/public/railroad.html Defines the syntax for the start of a 'here-comment' in CoffeeScript. ```regex /###(?!#)/ ``` -------------------------------- ### Build Civet project with esbuild Source: https://github.com/danielxmoore/civet/blob/main/README.md Integrate the Civet esbuild plugin to build your Civet project. This example shows how to import esbuild and the Civet plugin, and configure the build process. ```javascript import esbuild from 'esbuild' import civetPlugin from '@danielx/civet/esbuild' esbuild.build({ ..., plugins: [ civetPlugin({ ts: 'preserve' }) ] }).catch(() => process.exit(1)) ``` -------------------------------- ### Rule with Reference Body Source: https://github.com/danielxmoore/civet/blob/main/lsp/tree-sitter-hera/test/corpus/tokens.txt Defines a rule 'Start' that references another rule 'Greeting' and shows its parsed structure. ```Hera Start Greeting ``` ```Hera (program (newline) (identifier) (newline) (identifier) (newline)) ``` -------------------------------- ### JSON Configuration for Operator Object Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Example of a JSON configuration file specifying operator behavior using an object. ```json { "parseOptions": { "operators": { "dot": "looser (*)", "mult": "arguments tighter (+)", "normal": "" } } } ``` -------------------------------- ### Civet CLI Configuration Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Examples of using the Civet CLI to specify directives, config files, or disable config files. ```bash # Specify a directive civet --civet "objectIs -implicit-returns tab=2" ... # Specify a config file civet --config custom-config.civet ... # Disable config files civet --no-config ... ``` -------------------------------- ### Class Extension in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Basic example of class inheritance using the 'extends' keyword. ```civet class Civet < Animal ``` -------------------------------- ### Custom Civet LSP Provider Client Implementation Source: https://github.com/danielxmoore/civet/blob/main/lsp/monaco/README.md This example shows how to manually implement the client adapter for `registerCivetLspProviders` when you have an existing JSON-RPC client. This provides explicit control over each LSP request. ```typescript const uri = model.uri.toString() registerCivetLspProviders(monaco, { uri, model, client: { semanticTokensFull: () => jsonRpc.sendRequest('textDocument/semanticTokens/full', { textDocument: { uri }, }), hover: (position) => jsonRpc.sendRequest('textDocument/hover', { textDocument: { uri }, position, }), definition: (position) => jsonRpc.sendRequest('textDocument/definition', { textDocument: { uri }, position, }), completion: (params) => jsonRpc.sendRequest('textDocument/completion', { textDocument: { uri }, ...params, }), completionResolve: (item) => jsonRpc.sendRequest('completionItem/resolve', item), }, }) ``` -------------------------------- ### Verify Civet Setup in Helix Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/integrations.md Check the Civet integration with Helix to ensure that syntax highlighting and LSP features are working correctly. ```shell hx --health civet ``` -------------------------------- ### Dynamic Import without Parentheses Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Shows how dynamic imports can be used without parentheses when not at the start of a statement. ```civet {x} = await import url ``` -------------------------------- ### Standard JavaScript/TypeScript Operators Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Provides examples of common arithmetic, assignment, and type-checking operators. ```civet center := min + length / 2 name := user?.name ?? defaultName typeof x === "string" && x += "!" result! as string | number ``` -------------------------------- ### Implicit Element Syntax Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Shows how to define elements implicitly using shorthand for IDs or classes. Requires '#' or '.' at the start. ```civet <.foo>Civet ``` ```civet "civet defaultElement=span" <.foo>Civet ``` -------------------------------- ### Civet Config Module API Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Examples of using the Civet config module to find and load configuration files. ```javascript import { findInDir, findConfig, loadConfig } from "@danielx/civet/config" // Look for standard name for config file in specified directory const path1 = await findInDir(process.cwd()) // Look for standard name for config file in specified directory or ancestors const path2 = await findConfig(process.cwd()) // Load config file from specified path const config = await loadConfig(path) // Pass config to compile const code = await compile(civetCode, config) ``` -------------------------------- ### Build and Publish Civet Packages Source: https://github.com/danielxmoore/civet/blob/main/CONTRIBUTING.md The build workflow triggers the publish workflow, which installs dependencies, builds the project, and conditionally publishes packages based on version checks. ```sh pnpm install --frozen-lockfile && pnpm build ``` ```sh bash build/autorelease.sh . lsp/server lsp/monaco ``` -------------------------------- ### Run Civet REPL Interactively Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Use this command to start an interactive command-line REPL for transpiling Civet code. ```sh npx @danielx/civet -c ``` -------------------------------- ### Configure Civet with Directives Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/config.md Use a "civet" directive at the top of a file to specify configurations. This example disables implicit returns and sets tab width to 2 spaces. ```javascript "civet objectIs -implicit-returns tab=2" ``` -------------------------------- ### Mixin Application in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Example of applying a mixin function to a base class using the 'with' keyword. ```civet function Movable(C) class extends C move(@x, @y) class Civet extends Animal with Movable @() @move 0, 0 ``` -------------------------------- ### Install Civet as a Dev Dependency Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Add the Civet package as a development dependency to your project using npm. ```sh npm i -D @danielx/civet ``` -------------------------------- ### Integrate Civet with esbuild Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Configure esbuild to use the Civet plugin for transpiling Civet files. This example shows basic integration and comments on available options for the plugin. ```js import esbuild from 'esbuild' import civetPlugin from '@danielx/civet/esbuild' esbuild.build({ // ... // sourcemap: true, // build and link sourcemap files plugins: [ civetPlugin({ // Options and their defaults: // emitDeclaration: false, // generate .d.ts files? // declarationExtension: '.civet.d.ts', // extension for .d.ts files // implicitExtension: true, // import "./x" checks for x.civet // outputExtension: '.tsx', // appended to .civet internally // ts: 'civet', // TS -> JS transpilation mode // typecheck: false, // check types via tsc // cache: true, // cache compilation results based on mtime, useful for watch // config: null, // Civet config filename; null to skip // parseOptions: { // directives to apply globally // comptime: false, // evaluate comptime blocks // }, }) ] }).catch(() => process.exit(1)) ``` -------------------------------- ### Using Control Flow in Pipelines Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Illustrates how to incorporate `await`, `throw`, `yield`, `yield*`, or `return` directly within a pipeline. ```civet fetch url |> await |> .json() |> await |> return ``` -------------------------------- ### Simple Usage with ESLint and JavaScript (CJS) Source: https://github.com/danielxmoore/civet/blob/main/integration/eslint/README.md Configure ESLint to lint Civet files as JavaScript using CJS. This setup enables ESLint's recommended rules. ```js module.exports = [ ...require("eslint-plugin-civet").configs.recommended ] ``` -------------------------------- ### Build Civet Language Server from Source Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/integrations.md Build the Civet language server from its source code repository. This is necessary if you are using a local copy of the Civet repository. ```bash cd lsp/server && pnpm build ``` -------------------------------- ### TypeScript Configuration for Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Example tsconfig.json for enabling TypeScript type checking with Civet, including specific compiler and ts-node options. ```json { "compilerOptions": { "strict": true, "jsx": "preserve", "lib": ["es2021"], "moduleResolution": "bundler", "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "esModuleInterop": true }, "ts-node": { "transpileOnly": true, "compilerOptions": { "module": "nodenext" } } } ``` -------------------------------- ### Simple Usage with ESLint and JavaScript (ESM) Source: https://github.com/danielxmoore/civet/blob/main/integration/eslint/README.md Configure ESLint to lint Civet files as JavaScript using ESM. This setup enables ESLint's recommended rules. ```js import civetPlugin from "eslint-plugin-civet" export default [ ...civetPlugin.configs.recommended ] ``` -------------------------------- ### Building Functions with '&' Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Shows how to construct functions using the '&' prefix for use within pipelines, allowing for inline function definitions. ```civet & |> .toString |> console.log ``` ```civet &: number |> (+ 1) |> (* 2) |> Math.round ``` -------------------------------- ### CoffeeScript Range Literals Source: https://github.com/danielxmoore/civet/blob/main/notes/Comparison-to-CoffeeScript.md Illustrates range literals `[start...end]` and `[start..end]` in CoffeeScript for creating sequences, supported in Civet. ```coffeescript [0...10] ``` ```coffeescript [a..b] ``` ```coffeescript [x - 2 .. x + 2] ``` -------------------------------- ### Generate tree-sitter-hera Parser Source: https://github.com/danielxmoore/civet/blob/main/lsp/tree-sitter-hera/README.md Commands to install dependencies and generate the parser for the tree-sitter-hera grammar. The generated parser file is committed alongside the grammar definition. ```bash cd lsp/tree-sitter-hera pnpm install pnpm run generate ``` -------------------------------- ### Create Astro Project Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Use this command to create a new Astro project with the minimal template. ```bash npm create astro@latest -- --template minimal ``` -------------------------------- ### Display Civet CLI Help Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/getting-started.md Show all available command-line options for the Civet transpiler. ```sh civet --help ``` -------------------------------- ### Implicit Return Examples in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/comparison.md Demonstrates Civet's implicit return feature for functions. The last statement's value is returned unless a semicolon, void return type, or explicit return is used. ```typescript function more(x) { x+1 } ``` ```typescript function hello() { console.log("Hello world!") } ``` ```typescript function hello() { console.log("Hello world!"); } ``` ```typescript function hello(): void { console.log("Hello world!") } ``` ```typescript function hello() { console.log("Hello world!") return } ``` -------------------------------- ### Multi Assignment Operators Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Shows examples of incrementing, decrementing, and multiplying with late assignment. ```civet (count[key] ?= 0)++ (count[key] ?= 0) += 1 ++count *= 2 ``` -------------------------------- ### Class Implementation in Civet Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Demonstrates implementing interfaces or multiple base classes using '<:' syntax. ```civet class Civet < Animal <: Named class Civet <: Animal, Named ``` -------------------------------- ### CoffeeMultiLineComment Syntax Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/public/railroad.html Defines the syntax for multi-line comments in CoffeeScript style, including 'here-comment' start. ```regex CoffeeHereCommentStart ! CoffeeHereCommentStart \*/ . CoffeeHereCommentStart ``` -------------------------------- ### Build Production Site Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Builds your Astro project for production, outputting the static site to the ./dist/ directory. ```bash npm run build ``` -------------------------------- ### Add In-Repo Civet LSP Binary to PATH Source: https://github.com/danielxmoore/civet/blob/main/lsp/sublime/README.md Adds the in-repo Civet language server binary to the system's PATH for use with Sublime Text. ```bash # ~/.bashrc / ~/.zshrc export PATH="/path/to/Civet/lsp/server/bin:$PATH" ``` -------------------------------- ### Preview Production Build Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Locally previews the production build of your Astro site before deploying it. ```bash npm run preview ``` -------------------------------- ### Await All with For Loop Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Demonstrates `await.all` used with a for loop to fetch multiple URLs concurrently. ```civet await.all for url of urls fetch url ``` -------------------------------- ### Delayed Type Assertion Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Demonstrates type assertions that can start on later lines, chained with dot notation. ```civet "Hello, world!" .split /\s+/ as [string, string] ``` -------------------------------- ### Astro Project Structure Overview Source: https://github.com/danielxmoore/civet/blob/main/integration/unplugin-examples/astro/README.md Illustrates the basic directory and file structure of an Astro project, including public assets, source files, and the package.json. ```bash / ├── public/ ├── src/ │ └── pages/ │ └── index.astro └── package.json ``` -------------------------------- ### Return Value Preparation with `return.=` Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Prepares the return value of a function using `return.=` to avoid implicit returns and accumulate a sum. ```civet function sum(list: number[]) return .= 0 for item of list return += item ``` -------------------------------- ### Loop expressions listing iterated items Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Examples of loop expressions that simply list the items being iterated over. ```civet array := for item of iterable coordinates := for {x, y} of objects keys := for key in object ``` -------------------------------- ### Placeholder for Function Shorthand Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/cheatsheet.md The `&` symbol acts as a placeholder in function shorthand syntax, for example `&[x]+1`. ```civet &[x]+1 ``` -------------------------------- ### Build and Test Civet Language Server (Repository Development) Source: https://github.com/danielxmoore/civet/blob/main/lsp/server/README.md Builds and tests the Civet Language Server within a repository development context using pnpm. These commands are for developers working on the server's source code. ```bash pnpm -C lsp/server build pnpm -C lsp/server test ``` -------------------------------- ### Configure In-Repo Civet LSP on Windows Source: https://github.com/danielxmoore/civet/blob/main/lsp/sublime/README.md Configures Sublime Text to use the in-repo Civet LSP binary on Windows by explicitly pointing to the Node.js executable. ```json "command": ["node", "C:\\path\\to\\Civet\\lsp\\server\\bin\\civet-lsp.js", "--stdio"] ``` -------------------------------- ### Function Shorthand Comparison (& vs .) Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Illustrates the difference in lifting behavior between '&' and '.' placeholders. '.' requires a function call and lifts beyond it, while '&' does not. ```civet f a, & f a, . ``` -------------------------------- ### Import Declarations as Expressions Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Demonstrates using import declarations as expressions, serving as a shorthand for awaiting and destructuring a dynamic import. ```civet urlPath := import { fileURLToPath, pathToFileURL } from url url := import * from url Foo := import default from Foo ``` -------------------------------- ### Run Tests Source: https://github.com/danielxmoore/civet/blob/main/lsp/tree-sitter/README.md Execute the test suite for the tree-sitter parser using pnpm. ```bash pnpm test ``` -------------------------------- ### Heregex Body Syntax Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/public/railroad.html Defines the body of a Heregex, starting with an exclamation mark, followed by triple slashes and Heregex parts. ```civet [HeregexBody](#HeregexBody "HeregexBody") ::= '!' [TripleSlash](#TripleSlash "TripleSlash") [HeregexPart](#HeregexPart "HeregexPart")* ``` -------------------------------- ### Attach to Node Process (VSCode) Source: https://github.com/danielxmoore/civet/blob/main/CONTRIBUTING.md Instructions for attaching the VSCode debugger to a running Node.js process started with the inspect flag. ```sh pnpm test --inspect ``` -------------------------------- ### Class Syntax with Attributes Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md Demonstrates defining HTML elements with classes using dot notation. Supports dynamic class names via expressions. ```civet
# show uncovered regions for files matching
# add --branches for per-arm hit counts
pnpm coverage:merge # re-merge existing temp data without re-running tests
# (fast iteration when editing exclude patterns)
```
--------------------------------
### Symbol Definition with Compiler Directive
Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md
Shows how to set well-known symbols using a compiler directive for specific environments.
```civet
"civet symbols=magic"
magicSymbol := :magic
iteratorSymbol := :iterator
```
--------------------------------
### Example of Current Comment Behavior in Hera AST
Source: https://github.com/danielxmoore/civet/blob/main/notes/hera-ast-comments.md
Illustrates how leading comments are currently absorbed into whitespace or preceding statement nodes in the Hera AST, rather than being directly associated with the rule they precede.
```plaintext
# doc for Greeting <- in Statement[0].EOS (first rule: leading)
Greeting
"hi"
# doc for Name <- swallowed by Greeting's trailing whitespace,
Name NOT Name's Statement
"world"
```
--------------------------------
### Conditional Return and Resource Cleanup
Source: https://github.com/danielxmoore/civet/blob/main/civet.dev/reference.md
Demonstrates conditional return and explicit return of a value, along with resource cleanup.
```civet
function search