[−][src]Module gobble::common
Generally useful base parsers Str,Int,Uint,Esc,Float
use gobble::*; use common::*; assert_eq!(Bool.parse_s("true").unwrap(),true); assert_eq!(Bool.parse_s("false").unwrap(),false); assert_eq!(Quoted.parse_s(r#""hello\t\"world\"""#),Ok("hello\t\"world\"".to_string())); assert_eq!(Ident.parse_s("me34A_ dothing").unwrap(),"me34A_"); assert_eq!(Int.parse_s("32").unwrap(),32); //floats assert_eq!(Float.parse_s("32.").unwrap(),32.); assert_eq!(Float.parse_s("-23.4").unwrap(),-23.4); assert_eq!(Float.parse_s("-23.4e2").unwrap(),-2340.); assert_eq!(Float.parse_s("123.4e-2").unwrap(),1.234);
Structs
Bool | the words 'true' or 'false' |
Esc | Escapes a '' and converts '\n' '\t' '\r' |
Exponent | 'e' followed by a uint, allowed on floats |
Float | floating point numbers eg '134.4e6' |
Ident | A letter followed by numbers and letters or '_' |
Int | Returns a parsed isize |
Quoted | A string surrounded in Quotes |
UInt | a usize |
Functions
common_esc | Deprecated |
common_ident | Deprecated |
common_uint | Deprecated |