0.0
No release in over 3 years
Allows Kumi schemas to be written as plain text with syntax validation and editor integration.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
~> 1.21
~> 0.22

Runtime

~> 0.0.7
~> 2.0
~> 2.6
 Project Readme

Kumi::Parser

Text parser for Kumi schemas. Direct tokenizer → AST construction with ~4ms parse time.

Installation

gem 'kumi-parser'

Usage

require 'kumi/parser'

schema = <<~KUMI
  schema do
    input do
      float :income
      string :status
    end
    
    trait :adult, input.age >= 18
    value :tax, fn(:calculate_tax, input.income)
  end
KUMI

# Parse to AST
ast = Kumi::Parser::TextParser.parse(schema)

# Validate
Kumi::Parser::TextParser.valid?(schema) # => true

API

  • parse(text) → AST
  • valid?(text) → Boolean
  • validate(text) → Array of error hashes

Syntax

schema do
  input do
    <type> :<name>[, domain: <spec>]
  end
  
  trait :<name>, <expression>
  
  value :<name>, <expression>
  value :<name> do
    on <condition>, <result>
    base <result>
  end
end

Function calls: fn(:name, arg1, arg2, ...)
Operators: + - * / % > < >= <= == != & |
References: input.field, value_name, array[index]

Architecture

  • smart_tokenizer.rb - Context-aware tokenization with embedded metadata
  • direct_ast_parser.rb - Recursive descent parser, direct AST construction
  • token_metadata.rb - Token types, precedence, and semantic hints

See docs/ for technical details.

License

MIT