IDL tokenization
This commit is contained in:
parent
7426bf479f
commit
1855307cd9
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,7 @@ pub struct Protocol {
|
|||
pub decorators: Vec<Decorator>,
|
||||
}
|
||||
|
||||
pub struct Field {
|
||||
pub name: String,
|
||||
pub ptype: ProtocolTypes,
|
||||
}
|
||||
|
||||
pub struct Structure {
|
||||
pub fields: Vec<Field>,
|
||||
pub struct IDLEnum {
|
||||
pub name: String,
|
||||
pub accepted_values: Vec<(String, u64)>,
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
@visibility(public)
|
||||
protocol abc {
|
||||
|
||||
|
||||
}
|
24
sysdata/idl/log/src/protocol.aidl
Normal file
24
sysdata/idl/log/src/protocol.aidl
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue