diff --git a/dev/src/idl/mod.rs b/dev/src/idl/mod.rs index a4299ae..438ac88 100644 --- a/dev/src/idl/mod.rs +++ b/dev/src/idl/mod.rs @@ -17,18 +17,47 @@ enum Token { #[token("}")] RBrace, - #[regex("[a-zA-Z]+", |lex|{lex.slice().to_string()})] + #[token("(")] + LParen, + + #[token(")")] + RParen, + + #[token(":")] + Colon, + #[token(";")] + SemiColon, + + #[token(",")] + Comma, + + #[token("=")] + Equal, + + #[token("->")] + RArrow, + + #[regex("[a-zA-Z_]+", |lex|{lex.slice().to_string()})] Text(String), - #[regex(r#"@[a-zA-Z]+\(?[a-zA-Z]+\)?"#, |lex|{lex.slice().to_string()})] + #[regex("[1234567890]+")] + Number, + + #[regex(r"@[a-zA-Z_]+", |lex|{lex.slice().to_string()})] Decorator(String), + + #[regex(r#"@[a-zA-Z_]+\([a-zA-Z]+\)"#, |lex|{lex.slice().to_string()})] + DecoratorOption(String), } pub fn build_idl(name: String) { let contents = open_protocol(name); let lex = Token::lexer(&contents); for x in lex { - println!("{:?}", x.unwrap()); + match x { + Ok(token) => println!("{:?}", token), + Err(err) => println!("{:?}", err), + } } } diff --git a/dev/src/idl/protocol.rs b/dev/src/idl/protocol.rs index 191e504..1d0fa14 100644 --- a/dev/src/idl/protocol.rs +++ b/dev/src/idl/protocol.rs @@ -12,11 +12,7 @@ pub struct Protocol { pub decorators: Vec, } -pub struct Field { - pub name: String, - pub ptype: ProtocolTypes, -} - -pub struct Structure { - pub fields: Vec, +pub struct IDLEnum { + pub name: String, + pub accepted_values: Vec<(String, u64)>, } diff --git a/sysdata/idl/abc/src/protocol.aidl b/sysdata/idl/abc/src/protocol.aidl deleted file mode 100644 index 8bff36d..0000000 --- a/sysdata/idl/abc/src/protocol.aidl +++ /dev/null @@ -1,6 +0,0 @@ - -@visibility(public) -protocol abc { - - -} \ No newline at end of file diff --git a/sysdata/idl/abc/README.md b/sysdata/idl/log/README.md similarity index 100% rename from sysdata/idl/abc/README.md rename to sysdata/idl/log/README.md diff --git a/sysdata/idl/log/src/protocol.aidl b/sysdata/idl/log/src/protocol.aidl new file mode 100644 index 0000000..ec37b5b --- /dev/null +++ b/sysdata/idl/log/src/protocol.aidl @@ -0,0 +1,24 @@ +@auto_increment +enum LogLevel { + Error = 0, + Warn, + Info, + Debug, + Trace, +} + +@auto_increment +enum LogResult { + Err = 0, + Ok, +} + +struct Log { + log_level: LogLevel, +} + +@visibility(public) +protocol Log { + fn log(Log) -> LogResult; + fn flush() -> LogResult; +} \ No newline at end of file