aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-19 16:22:29 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-19 16:22:29 -0400
commite0a386fa8f884610ed1005462740d5db57d4ad3e (patch)
treecbd29d73d5381d776c1bea18adb0164968194cc3
parentf3b8529e01f66f4743d26a62237706a09a2f1f71 (diff)
Replace "begin"/"end" with "do_begin"/"do_end"
-rw-r--r--examples/pthreads/pthreads.tm12
-rw-r--r--parse.c8
2 files changed, 10 insertions, 10 deletions
diff --git a/examples/pthreads/pthreads.tm b/examples/pthreads/pthreads.tm
index 13d94e40..b4671d4c 100644
--- a/examples/pthreads/pthreads.tm
+++ b/examples/pthreads/pthreads.tm
@@ -58,14 +58,14 @@ struct IntQueue(_queue:@[Int], _mutex:@pthread_mutex_t, _cond:@pthread_cond_t):
return IntQueue(@initial, pthread_mutex_t.new(), pthread_cond_t.new())
func give(q:IntQueue, n:Int):
- begin: q._mutex:lock()
- end: q._mutex:unlock()
+ do_begin: q._mutex:lock()
+ do_end: q._mutex:unlock()
do: q._queue:insert(n)
q._cond:signal()
func take(q:IntQueue -> Int):
- begin: q._mutex:lock()
- end: q._mutex:unlock()
+ do_begin: q._mutex:lock()
+ do_end: q._mutex:unlock()
do:
repeat:
if n := q._queue:pop(1):
@@ -79,8 +79,8 @@ func main():
say_mutex := pthread_mutex_t.new()
announce := func(speaker:Text, text:Text):
- begin: say_mutex:lock()
- end: say_mutex:unlock()
+ do_begin: say_mutex:lock()
+ do_end: say_mutex:unlock()
do: say("$\033[2m[$speaker]$\033[m $text")
worker := pthread_t.new(func():
diff --git a/parse.c b/parse.c
index 5110e98e..93876cfd 100644
--- a/parse.c
+++ b/parse.c
@@ -53,7 +53,7 @@ int op_tightness[] = {
static const char *keywords[] = {
"yes", "xor", "while", "when", "use", "unless", "struct", "stop", "skip", "return",
"or", "not", "none", "no", "mutexed", "mod1", "mod", "pass", "lang", "inline", "in", "if", "holding",
- "func", "for", "extern", "enum", "end", "else", "do", "deserialize", "defer", "begin", "and",
+ "func", "for", "extern", "enum", "do_end", "else", "do", "deserialize", "defer", "do_begin", "and",
"_min_", "_max_", NULL,
};
@@ -1172,16 +1172,16 @@ PARSER(parse_for) {
}
PARSER(parse_do) {
- // [begin: [<indent>] block] [end: [<indent>] block] do: [<indent>] body
+ // [do_begin: [<indent>] block] [do_end: [<indent>] block] do: [<indent>] body
const char *start = pos;
int64_t starting_indent = get_indent(ctx, pos);
ast_t *begin = NULL, *end = NULL;
- if (match_word(&pos, "begin"))
+ if (match_word(&pos, "do_begin"))
begin = optional(ctx, &pos, parse_block);
const char *tmp = pos;
whitespace(&tmp);
- if (get_indent(ctx, tmp) == starting_indent && match_word(&tmp, "end")) {
+ if (get_indent(ctx, tmp) == starting_indent && match_word(&tmp, "do_end")) {
pos = tmp;
end = optional(ctx, &pos, parse_block);
}