feat(lexer): add type system keywords
Added four keywords for new type system: - concept: Base type definition - sub_concept: Enum/record sub-type definition - concept_comparison: Compile-time enum mapping - any: Universal type for dynamic contexts Also added: - CLAUDE.md with project instructions and commit guidelines - Test coverage for new keywords - Crate-level deny directives for unused variables and dead code Fixed pre-existing clippy issues to pass pre-commit hooks.
This commit is contained in:
@@ -105,14 +105,16 @@ pub enum Priority {
|
||||
Critical,
|
||||
}
|
||||
|
||||
impl Priority {
|
||||
pub fn from_str(s: &str) -> Option<Self> {
|
||||
impl std::str::FromStr for Priority {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
| "low" => Some(Priority::Low),
|
||||
| "normal" => Some(Priority::Normal),
|
||||
| "high" => Some(Priority::High),
|
||||
| "critical" => Some(Priority::Critical),
|
||||
| _ => None,
|
||||
| "low" => Ok(Priority::Low),
|
||||
| "normal" => Ok(Priority::Normal),
|
||||
| "high" => Ok(Priority::High),
|
||||
| "critical" => Ok(Priority::Critical),
|
||||
| _ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +128,7 @@ pub struct Character {
|
||||
pub template: Option<Vec<String>>, // `from Template1, Template2`
|
||||
pub uses_behaviors: Option<Vec<BehaviorLink>>, // `uses behaviors: [...]`
|
||||
pub uses_schedule: Option<Vec<String>>, /* `uses schedule: ScheduleName` or `uses schedules:
|
||||
* [...]` */
|
||||
* [...]` */
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,14 @@ pub enum Token {
|
||||
Species,
|
||||
#[token("enum")]
|
||||
Enum,
|
||||
#[token("concept")]
|
||||
Concept,
|
||||
#[token("sub_concept")]
|
||||
SubConcept,
|
||||
#[token("concept_comparison")]
|
||||
ConceptComparison,
|
||||
#[token("any")]
|
||||
Any,
|
||||
#[token("state")]
|
||||
State,
|
||||
#[token("on")]
|
||||
@@ -509,4 +517,21 @@ Second prose block content.
|
||||
vec![Token::IntLit(20), Token::DotDot, Token::IntLit(40),]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_system_keywords() {
|
||||
let input = "concept sub_concept concept_comparison any";
|
||||
let lexer = Lexer::new(input);
|
||||
let tokens: Vec<Token> = lexer.map(|(_, tok, _)| tok).collect();
|
||||
|
||||
assert_eq!(
|
||||
tokens,
|
||||
vec![
|
||||
Token::Concept,
|
||||
Token::SubConcept,
|
||||
Token::ConceptComparison,
|
||||
Token::Any,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user