INNER CODE UNIT · Python

wren_to_c_string

OverShifted/OverEngine · utils/wren_to_c_string.py:22

def wren_to_c_string(input_path, wren_source_lines, module):
  wren_source = ""
  for line in wren_source_lines:
    line = line.replace("\\", "\\\\")
    line = line.replace('"', "\\\"")
    line = line.replace("\n", "\\n\"")
    if wren_source: wren_source += "\n"
    wren_source += '"' + line

  return PREAMBLE.format(input_path, module, wren_source)


def main():
  parser = argparse.ArgumentParser(
      description="Convert a Wren library to a C string literal.")
  parser.add_argument("output", help="The output file to write")
  parser.add_argument("input", help="The source .wren file")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…