heraclitus_compiler/lib.rs
1#![warn(missing_docs)]
2
3//! # Heraclitus - the compiler frontend
4//! 
5//! With heraclitus you can create your language by skipping the cumbersome lexing step
6//! and using convenience parsing methods that can get you started on your language much quicker.
7//! 
8//! The main construct that you need is the `Compiler`. The compiler will tokenize your code and assemble it
9//! in a way that you can use to create AST by implementing predefined trait that helps you parse your code.
10//! 
11//! It's pretty simple. In order to get started you need 3 steps:
12//! 1. Create lexing rules
13//! 2. Create your ast nodes and let them implement trait provided by this package
14//! 3. Create compiler and tie all the components together
15//! 
16//! Voilá!
17//! Now you got yourself a ready to analyze / interpret / validate / compile AST.
18//! 
19//! Ready to get started?
20//! # Example
21//! ```
22//! use heraclitus_compiler::prelude::*;
23//! # let rules = Rules::new(vec![], vec![], reg![]);
24//! Compiler::new("HerbScript", rules);
25//! ```
26//! It is recommended to use included prelude to import just the things we will actually need.
27//! 
28//! The `Compiler` requires lexer rules in order to exist.
29//! 
30//! ```
31//! # use heraclitus_compiler::prelude::*;
32//! # fn compiler() -> Result<(), LexerError> {
33//! # let rules = Rules::new(vec![], vec![], reg![]);
34//! let cc = Compiler::new("HerbScript", rules);
35//! let tokens = cc.tokenize()?;
36//! # Ok(())
37//! # }
38//! ```
39
40pub mod compiling_rules;
41pub mod compiling;
42
43pub mod prelude {
44    //! Use all the necessary modules
45    //! 
46    //! This package loads all the most necessary modules into the global scope.
47    //! # Example
48    //! ```
49    //! use heraclitus_compiler::prelude::*;
50    //! ```
51    pub use crate::*;
52    pub use crate::compiling_rules::*;
53    pub use crate::compiling::*;
54    pub use crate::compiling::patterns::*;
55    pub use crate::compiling::failing::position_info::{PositionInfo, Position};
56    pub use crate::compiling::failing::message::{Message, MessageType};
57    pub use crate::compiling::failing::failure::Failure;
58}