toki: pona

This commit is contained in:
2025-02-19 04:04:40 -06:00
parent 3b14186b70
commit 3cb85c7f42
4 changed files with 188 additions and 103 deletions

View File

@@ -107,35 +107,35 @@ impl Display for TokenKind {
TokenKind::Literal => "literal".fmt(f),
TokenKind::Identifier => "identifier".fmt(f),
TokenKind::As => "as".fmt(f),
TokenKind::Break => "break".fmt(f),
TokenKind::Cl => "cl".fmt(f),
TokenKind::Const => "const".fmt(f),
TokenKind::Continue => "continue".fmt(f),
TokenKind::Else => "else".fmt(f),
TokenKind::Enum => "enum".fmt(f),
TokenKind::False => "false".fmt(f),
TokenKind::Fn => "fn".fmt(f),
TokenKind::For => "for".fmt(f),
TokenKind::If => "if".fmt(f),
TokenKind::Impl => "impl".fmt(f),
TokenKind::In => "in".fmt(f),
TokenKind::Let => "let".fmt(f),
TokenKind::Loop => "loop".fmt(f),
TokenKind::Match => "match".fmt(f),
TokenKind::Mod => "mod".fmt(f),
TokenKind::Mut => "mut".fmt(f),
TokenKind::Pub => "pub".fmt(f),
TokenKind::Return => "return".fmt(f),
TokenKind::SelfKw => "self".fmt(f),
TokenKind::SelfTy => "Self".fmt(f),
TokenKind::Static => "static".fmt(f),
TokenKind::Struct => "struct".fmt(f),
TokenKind::Super => "super".fmt(f),
TokenKind::True => "true".fmt(f),
TokenKind::Type => "type".fmt(f),
TokenKind::Use => "use".fmt(f),
TokenKind::While => "while".fmt(f),
TokenKind::As => "sama".fmt(f),
TokenKind::Break => "pana".fmt(f),
TokenKind::Cl => "la".fmt(f),
TokenKind::Const => "kiwen".fmt(f),
TokenKind::Continue => "tawa".fmt(f),
TokenKind::Else => "taso".fmt(f),
TokenKind::Enum => "kulupu".fmt(f),
TokenKind::False => "ike".fmt(f),
TokenKind::Fn => "nasin".fmt(f),
TokenKind::For => "ale".fmt(f),
TokenKind::If => "tan".fmt(f),
TokenKind::Impl => "insa".fmt(f),
TokenKind::In => "lon".fmt(f),
TokenKind::Let => "poki".fmt(f),
TokenKind::Loop => "awen".fmt(f),
TokenKind::Match => "seme".fmt(f),
TokenKind::Mod => "selo".fmt(f),
TokenKind::Mut => "ante".fmt(f),
TokenKind::Pub => "lukin".fmt(f),
TokenKind::Return => "pini".fmt(f),
TokenKind::SelfKw => "mi".fmt(f),
TokenKind::SelfTy => "Mi".fmt(f),
TokenKind::Static => "mute".fmt(f),
TokenKind::Struct => "lipu".fmt(f),
TokenKind::Super => "mama".fmt(f),
TokenKind::True => "pona".fmt(f),
TokenKind::Type => "ijo".fmt(f),
TokenKind::Use => "jo".fmt(f),
TokenKind::While => "lawa".fmt(f),
TokenKind::LCurly => "{".fmt(f),
TokenKind::RCurly => "}".fmt(f),
@@ -200,35 +200,35 @@ impl FromStr for TokenKind {
/// Parses a string s to return a Keyword
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"as" => Self::As,
"break" => Self::Break,
"cl" => Self::Cl,
"const" => Self::Const,
"continue" => Self::Continue,
"else" => Self::Else,
"enum" => Self::Enum,
"false" => Self::False,
"fn" => Self::Fn,
"for" => Self::For,
"if" => Self::If,
"impl" => Self::Impl,
"in" => Self::In,
"let" => Self::Let,
"loop" => Self::Loop,
"match" => Self::Match,
"mod" => Self::Mod,
"mut" => Self::Mut,
"pub" => Self::Pub,
"return" => Self::Return,
"self" => Self::SelfKw,
"Self" => Self::SelfTy,
"static" => Self::Static,
"struct" => Self::Struct,
"super" => Self::Super,
"true" => Self::True,
"type" => Self::Type,
"use" => Self::Use,
"while" => Self::While,
"as" | "sama" => Self::As,
"break" | "pana" => Self::Break,
"cl" | "la" => Self::Cl,
"const" | "kiwen" => Self::Const,
"continue" | "tawa" => Self::Continue,
"else" | "taso" => Self::Else,
"enum" | "kulupu" => Self::Enum,
"false" | "ike" => Self::False,
"fn" | "nasin" => Self::Fn,
"for" | "ale" => Self::For,
"if" | "tan" => Self::If,
"impl" | "insa" => Self::Impl,
"in" | "lon" => Self::In,
"let" | "poki" => Self::Let,
"loop" | "awen" => Self::Loop,
"match" | "seme" => Self::Match,
"mod" | "selo" => Self::Mod,
"mut" | "ante" => Self::Mut,
"pub" | "lukin" => Self::Pub,
"return" | "pini" => Self::Return,
"self" | "mi" => Self::SelfKw,
"Self" | "Mi" => Self::SelfTy,
"static" | "mute" => Self::Static,
"struct" | "lipu" => Self::Struct,
"super" | "mama" => Self::Super,
"true" | "pona" => Self::True,
"type" | "ijo" => Self::Type,
"use" | "jo" => Self::Use,
"while" | "lawa" => Self::While,
_ => Err(())?,
})
}