1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! **You may be searching for [the repository](https://github.com/scOwez/jingo),
//! you are currently in the backend code for Jingo.**
//! 
//! ---
//! 
//! The central library for Jingo, containing the core of the compiler.
//!
//! This library is designed to be used downstream for the official CLI or any
//! future language servers/other tooling utilising the compiler without wanting
//! the added bulk of CLI dependencies.
//!
//! ## Usage
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! jingo-lib = "0.1"
//! ```
//!
//! ## Developer Notes
//!
//! - All frontend (e.g. lexing, parsing, ast) are contained in the [frontend]
//! module and all backend parts (e.g. codegen) are contained in [backend]
//! if you need to interact with a specific part of the compiler.

pub mod backend;
pub mod error;
pub mod frontend;

use error::*;
use std::path::PathBuf;

/// Compiles code to the best of the compilers (current) ability, e.g. lexing.
pub fn compile(code: &str, _output: Option<PathBuf>) -> Result<(), JingoError> {
    let tokens = frontend::lexer::scan_code(code)?;

    for token in tokens {
        println!("{} ({:?})", token, token.token_type);
    }

    Ok(())
}