#specification #minecraft #parser #literals #base #identifier #tokenize

specmc-base

A library with common code for parsing Minecraft specification

8 releases

0.1.11 Jun 12, 2024
0.1.10 Jun 9, 2024

#249 in Games

Download history 367/week @ 2024-06-03 276/week @ 2024-06-10 34/week @ 2024-06-17

677 downloads per month
Used in specmc-protocol

MIT license

10KB
215 lines

SpecMC Base

A library with common code for parsing Minecraft specification.

Examples

use specmc_base::{
    parse::{Identifier, Literal, Parse},
    tokenize::tokenize,
};

let mut tokens: Vec<String> = tokenize("true 42 123.0 \"string\" cool_identifier");
tokens.reverse();

let lit_bool: Literal = Literal::parse(&mut tokens).unwrap();
let lit_int: Literal = Literal::parse(&mut tokens).unwrap();
let lit_float: Literal = Literal::parse(&mut tokens).unwrap();
let lit_str: Literal = Literal::parse(&mut tokens).unwrap();
let ident: Identifier = Identifier::parse(&mut tokens).unwrap();

println!("{lit_bool:?} {lit_int:?} {lit_float:?} {lit_str:?} {ident:?}");

lib.rs:

A library with common code for parsing Minecraft specification.

Dependencies

~315–780KB
~18K SLoC