forked from Orchid/orchid
Custom lexers can now terminate operators
New constraint: custom lexer output is dropped whenever it is used to terminate an operator nested inside another custom lexer, because the recursive call has to return exactly one lexeme
This commit is contained in:
@@ -6,4 +6,18 @@ macro_rules! tl_cache {
|
||||
}
|
||||
V.with(|v| v.clone())
|
||||
}};
|
||||
(async $ty:ty : $expr:expr) => {{
|
||||
type CellType = std::cell::OnceCell<$ty>;
|
||||
thread_local! {
|
||||
static V: CellType = std::cell::OnceCell::default();
|
||||
}
|
||||
match V.with(|cell: &CellType| cell.get().cloned()) {
|
||||
Some(val) => val as $ty,
|
||||
None => {
|
||||
let val = $expr;
|
||||
let _ = V.with(|cell: &CellType| cell.set(val.clone()));
|
||||
val as $ty
|
||||
},
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user