From 7c6ed88f6926459f1cdcff866544d6522aaca899 Mon Sep 17 00:00:00 2001 From: PucklaJ Date: Sat, 12 Oct 2024 18:10:48 +0900 Subject: [PATCH] Provide reserved keywords based on language --- c/codegen/to.odin | 9 +++++++++ runic.odin | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/c/codegen/to.odin b/c/codegen/to.odin index dfc91fc..c6b7842 100644 --- a/c/codegen/to.odin +++ b/c/codegen/to.odin @@ -198,6 +198,15 @@ generate_bindings :: proc( return nil } +C_RESERVED :: []string{ + "int", + "switch", + "static", + "volatile", + "extern", + // TODO: Add more C reserved keywords +} + write_variable :: proc( wd: io.Writer, rn: runic.To, diff --git a/runic.odin b/runic.odin index c9cdc80..08c8d46 100644 --- a/runic.odin +++ b/runic.odin @@ -242,9 +242,19 @@ main :: proc() { switch to in rune.to { case runic.To: - // TODO: get reserved kewords for different languages + reserved_keywords: []string = --- + switch strings.to_lower(to.language, context.temp_allocator) { + case "c": + reserved_keywords = ccdg.C_RESERVED + case "odin": + reserved_keywords = odincdg.ODIN_RESERVED + case: + fmt.eprintfln("To Language \"{}\" is not supported", to.language) + os.exit(1) + } + for &rs in runestones { - runic.to_preprocess_runestone(&rs, to, odincdg.ODIN_RESERVED) + runic.to_preprocess_runestone(&rs, to, reserved_keywords) } fmt.eprintln("Crossing the runes ...")