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

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

#20 in #tokenize

Download history 63/week @ 2024-09-26 39/week @ 2024-10-03

499 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

~245–700KB
~16K SLoC