Skip to content

Commit

Permalink
Provide reserved keywords based on language
Browse files Browse the repository at this point in the history
  • Loading branch information
PucklaJ committed Oct 12, 2024
1 parent 225785d commit 7c6ed88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions c/codegen/to.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 12 additions & 2 deletions runic.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...")
Expand Down

0 comments on commit 7c6ed88

Please sign in to comment.