gachapy.keylang
The tokenizer, parser, and interpreter for KeyLang, the language used by gachapy to save and load custom rarity to drop rate functions KeyLang is a simple calculator-based language. Each token in the language must be separated by a space. The expressions follow standard order of operations. The following are allowed operations: + : addition - : subtraction * : multiplication / : division ^ : exponent ( … ) : parentheses (for overriding order of operations), where … is any expression any float literal R : rarity, to be substituted upon interpretation time
KeyLang Grammar
Expr -> Term + Expr | Term - Expr | Term Term -> Factor * Term | Factor / Term | Factor Factor -> Base ^ Factor | Base Base -> Const | ( Expr ) Const -> <float literal> | <rarity> Rar -> <rarity>
Example: 2 * ( 1 + R ) / 5 ^ 2 where R = rarity
Author: Jacob Kerr, 2021
- class gachapy.keylang.Ast(left=None, right=None, data=None)[source]
The base class of the abstract syntax tree