diff options
author | Adrian Thurston <thurston@colm.net> | 2020-10-13 08:41:06 -0700 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2020-10-13 08:41:06 -0700 |
commit | 86bb5882a70224a29650ccfa1e46c9b023c2a3ef (patch) | |
tree | 1579305852f20bd2b0ff2b2551a1e1f1610c0ffd | |
parent | 8b70e1a81402e4e5aeb9a77e1dc35dd0eadbb86b (diff) | |
download | colm-86bb5882a70224a29650ccfa1e46c9b023c2a3ef.tar.gz |
cgil: rust, catch and emit loop labels with 'l: while ... syntax
-rw-r--r-- | cgil/rlhc-rust.lm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cgil/rlhc-rust.lm b/cgil/rlhc-rust.lm index 85163502..03f8b688 100644 --- a/cgil/rlhc-rust.lm +++ b/cgil/rlhc-rust.lm @@ -29,7 +29,7 @@ namespace rust_out token string / '"' ( [^"\\] | '\\' any ) * '"' | - "'" ( [^'\\] | '\\' any ) * "'" + "'" ( [^'\\] | '\\' any ) "'" / ignore @@ -399,10 +399,22 @@ namespace rust_gen "} } } - case ['while' '(' WhileExpr: expr ')' WhileStmt: stmt] { + case [`continue CL: ident `;] { send Parser - "while ( [expr(WhileExpr)] ) - " [stmt(WhileStmt)] + "continue '[CL]; + } + case [`break BL: ident `;] { + send Parser + "break '[BL]; + } + case [BL: break_label? 'while' '(' WhileExpr: expr ')' '{' StmtList: stmt* '}' ] { + if match BL [bl: break_label] + send Parser "'[bl.ident]: " + + send Parser + "while ( [expr(WhileExpr)] ) { + " [stmt_list(StmtList)] + "} } case [`switch `( SwitchExpr: expr `) `{ StmtList: stmt* `}] { send Parser |