#programming-language #compiler #ast-node #parser #logging #heraclitus


Compiler frontend for developing great programming languages

21 stable releases

1.5.8 Dec 22, 2022
1.5.6 Dec 11, 2022
1.5.4 Oct 19, 2022
1.5.2 Sep 28, 2022
0.1.0 Jul 20, 2022

#81 in Programming languages

Download history 1/week @ 2024-02-20 8/week @ 2024-02-27 5/week @ 2024-03-12 25/week @ 2024-03-26 38/week @ 2024-04-02

63 downloads per month

MIT license



Crate API

Heraclitus is an open source compiler frontend written in rust. It's going to be used as a basis for programming languages such as Amber and Flame.

Heraclitus - the compiler frontend

With heraclitus you can create your language by skipping the cumbersome lexing step and using convenience parsing methods that can get you started on your language much quicker.

The main construct that you need is the Compiler. The compiler will tokenize your code and assemble it in a way that you can use to create AST by implementing predefined trait that helps you parse your code.

It's pretty simple. In order to get started you need 3 steps:

  1. Create lexing rules
  2. Create your ast nodes and let them implement trait provided by this package
  3. Create compiler and tie all the components together

Voilรก! ๐ŸŽ‰

Now you got yourself a ready to analyze / interpret / validate / compile AST.

Ready to get started?


use heraclitus::prelude::*;
Compiler::new("HerbScript", rules);

It is recommended to use included prelude to import just the things we will actually need.

The Compiler requires lexer rules in order to exist.

let cc = Compiler::new("HerbScript", rules);
let tokens = cc.tokenize()?;

Change log ๐Ÿš€

Version 1.5.8


  • Escaping regions is now properly handled

Version 1.5.7


  • Major fix that caused the lexer to lead to an undefined behavior with defining a region that has a beginning rule longer than one character.

Version 1.5.6


  • Compiler now does not rely strongly on provided source code. It can now open files from path if provided. This can improve drastically performance of the compiler when working with imports.

Version 1.5.5


  • Show elapsed time in parser debug mode

Version 1.5.4


  • Offset now supports negative values

Version 1.5.3


  • Token now derives Default trait

Version 1.5.2


  • Message now does not consumes itself when it's being displayed
  • Removed warn* and info* macros as we don't see any reason to use them at this point

Version 1.5.1


  • Added error_at, warn_at, info_at macros

Version 1.5.0


  • Breaking change: All new Failing API
  • Syntax Result now returns Failing enum
  • Errors are now encouraged to be propagated back to the root of the AST.
  • Added context macro to support better developer experience

Version 1.4.0


  • Tracebacks


  • Terminal colors (support for non-truecolor consoles)
  • Logger now prints errors to STDERR

Version 1.3.1


  • Multiline regions wouldn't parse

Version 1.3.0


  • Added support for UTF symbols

Version 1.2.6


  • Critical bug with non-tokenizable regions being tokenized

Version 1.2.5


  • Changed Logger API that improves adding code snippets
  • Logger::new_err is now called Logger::new_err_at_position
  • Logger::new_warn is now called Logger::new_warn_at_position
  • Logger::new_info is now called Logger::new_info_at_position

Version 1.2.4


  • Bad token highlighting in Logger when showing a code snippet

Version 1.2.2


  • Major bug with a tokenised interpolation being parsed in a wrong way.
  • Intensively used code is now inlined at compile time

Version 0.2.1


  • ErrorDetails::from_token_option(...) can now be used to create errors at location of given token

Version 0.2.0


  • Added compounds
  • Logger can now display messages not related to code
  • New method for retrieving current token
  • New debug functionality


  • Changed string reference of all function parameters to impl AsRef<str>


~56K SLoC