jingo_lib/
lib.rs

1//! **You may be searching for [the repository](https://github.com/scOwez/jingo),
2//! you are currently in the backend code for Jingo.**
3//! 
4//! ---
5//! 
6//! The central library for Jingo, containing the core of the compiler.
7//!
8//! This library is designed to be used downstream for the official CLI or any
9//! future language servers/other tooling utilising the compiler without wanting
10//! the added bulk of CLI dependencies.
11//!
12//! ## Usage
13//!
14//! Add to your `Cargo.toml`:
15//!
16//! ```toml
17//! [dependencies]
18//! jingo-lib = "0.1"
19//! ```
20//!
21//! ## Developer Notes
22//!
23//! - All frontend (e.g. lexing, parsing, ast) are contained in the [frontend]
24//! module and all backend parts (e.g. codegen) are contained in [backend]
25//! if you need to interact with a specific part of the compiler.
26
27pub mod backend;
28pub mod error;
29pub mod frontend;
30
31use error::*;
32use std::path::PathBuf;
33
34/// Compiles code to the best of the compilers (current) ability, e.g. lexing.
35pub fn compile(code: &str, _output: Option<PathBuf>) -> Result<(), JingoError> {
36    let tokens = frontend::lexer::scan_code(code)?;
37
38    for token in tokens {
39        println!("{} ({:?})", token, token.token_type);
40    }
41
42    Ok(())
43}