solgpc

Crates.iosolgpc
lib.rssolgpc
version0.1.0
created_at2026-01-10 22:53:08.675471+00
updated_at2026-01-10 22:53:08.675471+00
descriptionAn elegantly fast GPC parser.
homepage
repository
max_upload_size
id2034857
size76,816
Kiwiko (zKiwiko)

documentation

README

Overview

solgpc is an extremely fast parser for the GPC Scripting Language. solgpc leverages Logos for its Lexing, and a hand crafted, built from scratch parser for its power, and is intented to be used for LSP development with its highly detailed and easy to traverse AST.

Usage

Installation

cargo add solgpc

Implementation Example

use solgpc::lexer::Lexer;
use solgpc::parser::Parser;

fn main() {
    let source = "int var = 0; main { if(var) set_rgb(255, 255, 255); }";

    let mut lexer = Lexer::new(&source);
    let tokens = lexer.collect();

    let errors = parser.errors();
    if !errors.is_empty() {
        println!("Parser errors: {:?}", errors);
        println!("Full diagnostics: {:#?}", &parser.diagnostics);
    }

    println!("AST: {:#?}", &parser.ast);
}
Expected Output
[
    Statement(
        VarDecl {
            is_const: false,
            var_type: Int,
            name: "var",
            dimensions: [],
            initializer: Some(
                Literal(
                    Number(
                        0,
                    ),
                ),
            ),
        },
    ),
    Statement(
        Main(
            Block(
                [
                    Statement(
                        If {
                            condition: Identifier(
                                "var",
                            ),
                            then_branch: Statement(
                                Expression(
                                    FunctionCall {
                                        callee: Identifier(
                                            "set_rgb",
                                        ),
                                        arguments: [
                                            Literal(
                                                Number(
                                                    255,
                                                ),
                                            ),
                                            Literal(
                                                Number(
                                                    255,
                                                ),
                                            ),
                                            Literal(
                                                Number(
                                                    255,
                                                ),
                                            ),
                                        ],
                                    },
                                ),
                            ),
                            else_branch: None,
                        },
                    ),
                ],
            ),
        ),
    ),
]
Commit count: 0

cargo fmt