Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] implements lowerer #159

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/lowerer/lowerer.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
#
# lowerer Compiler
# (c) Copyright 2024 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#


import std / [parseopt, strutils, os, osproc, tables, assertions, syncio]
import transformer

const
Version = "0.2"
Usage = "lowerer Compiler. Version " & Version & """

(c) 2024 Andreas Rumpf
Usage:
lowerer [options] [command]
Command:
file.nif lower NIF file to meet gear3's requirements

Options:
--version show the version
--help show this help
"""

proc writeHelp() = quit(Usage, QuitSuccess)
proc writeVersion() = quit(Version & "\n", QuitSuccess)

proc handleCmdLine*() =
var files: seq[string] = @[]
for kind, key, val in getopt():
case kind
of cmdArgument:
files.add key
of cmdLongOption, cmdShortOption:
case normalize(key)
of "help", "h": writeHelp()
of "version", "v": writeVersion()
else: writeHelp()
of cmdEnd: assert false, "cannot happen"
if files.len > 1:
quit "too many arguments given, seek --help"
elif files.len == 0:
writeHelp()
else:
transformCode files[0]

when isMainModule:
handleCmdLine()
1 change: 1 addition & 0 deletions src/lowerer/nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--path: "../lib"
Loading
Loading