shulker 0.1.0

A programming language designed for the DiamondFire Minecraft server.
use chumsky::{primitive::{one_of, end, none_of}, Parser, prelude::Simple, regex::regex};

use crate::codegen::{item_data::ItemData, misc::VariableScope};

pub mod datatypes;
pub mod parse;

fn ident_to_var(input: &str) -> ItemData {
    let mut words = input.split('.');
    if let Some(scope) = words.next() {
        match scope {
            "local" => ItemData::Variable {
                scope: VariableScope::Local,
                name: words.next().unwrap_or("_NULL").to_string(),
            },
            "save" => ItemData::Variable {
                scope: VariableScope::Saved,
                name: words.next().unwrap_or("_NULL").to_string(),
            },
            _ => ItemData::Variable {
                scope: VariableScope::Unsaved,
                name: words.next().unwrap_or("_NULL").to_string(),
            },
        }
    } else {
        ItemData::Variable {
            scope: VariableScope::Unsaved,
            name: words.next().unwrap_or("_NULL").to_string(),
        }
    }
}

pub fn ident() -> impl Parser<'static, char, String, Simple<'static, char>> {
    regex(r"[a-zA-Z_%][a-zA-Z_%0-9\(\)]")
}