sample-code: update for new WIP syntax (it's more persnickety)

This commit is contained in:
2025-10-19 19:27:09 -04:00
parent 6b24980fc7
commit b54826cdd5
7 changed files with 46 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
//! Implements format string evaluation in weak Conlang
/// Formats a string
#[rustfmt::skip]
fn f(__fmt: &str) -> &str {
let __out = "";
let __expr = "";
@@ -10,13 +10,13 @@ fn f(__fmt: &str) -> &str {
for __c in chars(__fmt) {
match __c {
'{' => {
__depth += 1
__depth += 1;
if __depth <= 1 {
continue
}
},
'}' => {
__depth -= 1
__depth -= 1;
if __depth <= 0 {
__out = fmt(__out, __label, eval(__expr));
(__expr, __label) = ("", "");
@@ -24,11 +24,11 @@ fn f(__fmt: &str) -> &str {
}
},
':' => if __depth == 1 && __label.len() == 0 {
__label = __expr + __c
__label = __expr + __c;
continue
},
'=' => if __depth == 1 && __label.len() == 0 {
__label = __expr + __c
__label = __expr + __c;
continue
},
_ => {}