Download rust/crates/hyperkitty-parser/src/tokens.rs from Snapkitty/hyperkitty-constraint-dsl: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-parser/src/tokens.rs
- Command line
-
hf download hf://Snapkitty/hyperkitty-constraint-dsl/rust/crates/hyperkitty-parser/src/tokens.rs
-
curl -L -o tokens.rs https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-parser/src/tokens.rs
1.19 kB
| //! Token types for constraint DSL | |
| pub enum Token { | |
| // Keywords | |
| Require, | |
| Balance, | |
| Invariant, | |
| Entropy, | |
| Proof, | |
| Runtime, | |
| Identity, | |
| Phase, | |
| Otherwise, | |
| Reject, | |
| // Identifiers and literals | |
| Identifier(String), | |
| Number(i64), | |
| String(String), | |
| // Operators | |
| LessThanEq, | |
| Equals, | |
| LeftParen, | |
| RightParen, | |
| LeftBrace, | |
| RightBrace, | |
| Semicolon, | |
| Comma, | |
| // Special | |
| Eof, | |
| } | |
| impl Token { | |
| pub fn is_keyword(&self) -> bool { | |
| matches!( | |
| self, | |
| Token::Require | |
| | Token::Balance | |
| | Token::Invariant | |
| | Token::Entropy | |
| | Token::Proof | |
| | Token::Runtime | |
| | Token::Identity | |
| | Token::Phase | |
| | Token::Otherwise | |
| | Token::Reject | |
| ) | |
| } | |
| } | |
| mod tests { | |
| use super::*; | |
| fn token_classification() { | |
| assert!(Token::Require.is_keyword()); | |
| assert!(!Token::Identifier("test".to_string()).is_keyword()); | |
| } | |
| } | |