Skip to content

Latest commit

 

History

History
80 lines (53 loc) · 2.54 KB

README.md

File metadata and controls

80 lines (53 loc) · 2.54 KB

Linefeed

A language specifically tailored for writing clean solutions for Advent of Code.

Warning

It is currently in a very early, exploratory stage.

Why the name?

The idea of creating Linefeed was born when I did Advent of Code 2024, where I wanted a language specifically tailored for writing clean solutions for Advent of Code:

  1. It's a reference to having to read and print lines of text, each separated by a line feed.
  2. It's a nod to the Christmassy origin of Advent of Code. The common acronym for line feed is LF, which sounds like elf.

Examples

To demonstrate the syntax and features of Linefeed, solutions for Advent of Code 2020 have been implemented in Linefeed. They can be found in tests/linefeed/advent_of_code_2020.

I've also included a syntax-highlighted sample snippet in the bottom of this README.

Language Server

Linefeed includes an LSP server that provides semantic token highlighting.

Installation

From the root of the repository:

cargo install --path linefeed-lsp

Configuration

Example configuration for Neovim (using astrolsp):

linefeed_lsp = {
  cmd = { "linefeed-lsp" },
  filetypes = { "linefeed" },
  root_dir = require("lspconfig.util").root_pattern "*.lf",
  on_attach = function(client, bufnr)
    -- Enable semantic token highlighting if server supports it
    if client.server_capabilities.semanticTokensProvider then
      vim.lsp.semantic_tokens.start(bufnr, client.id)
    end
  end,
}

Planned features

See #1 for a tracking issue.

Profiling

Linefeed includes a built-in VM profiler to analyze runtime performance. Enable it by compiling with the profile-vm feature:

cargo run --bin linefeed --features profile-vm -- your_program.lf

This prints a summary to stderr showing:

  • Instruction frequency and timing
  • Source code hotspots
  • Function call statistics

To export full (non-truncated) profiler data to a file, set the LINEFEED_PROFILE_OUTPUT environment variable:

LINEFEED_PROFILE_OUTPUT=profile.txt cargo run --bin linefeed --features profile-vm -- your_program.lf

Sample snippet

For completeness sake, here's a sample Linefeed snippet with syntax highlight (from the language server):

image