Module semver_parser::lexer [−][src]
Lexer for semver ranges.
Breaks a string of input into an iterator of tokens that can be used with a parser.
This should be used with the parser
module.
Examples
Example without errors:
use semver_parser::lexer::{Lexer, Token}; let mut l = Lexer::new("foo 123 *"); assert_eq!(Some(Ok(Token::AlphaNumeric("foo"))), l.next()); assert_eq!(Some(Ok(Token::Whitespace(3, 4))), l.next()); assert_eq!(Some(Ok(Token::Numeric(123))), l.next()); assert_eq!(Some(Ok(Token::Whitespace(7, 8))), l.next()); assert_eq!(Some(Ok(Token::Star)), l.next()); assert_eq!(None, l.next());
Example with error:
use semver_parser::lexer::{Lexer, Token, Error}; let mut l = Lexer::new("foo / *"); assert_eq!(Some(Ok(Token::AlphaNumeric("foo"))), l.next()); assert_eq!(Some(Ok(Token::Whitespace(3, 4))), l.next()); assert_eq!(Some(Err(Error::UnexpectedChar('/'))), l.next());
Structs
Lexer | Lexer for semver tokens belonging to a range. |
Enums
Error | |
Token | Semver tokens. |