Merge pull request #44 from keitahaga/compiler
c2nim, c2pas: fix '--out' option
This commit is contained in:
commit
8f0a5c7bec
2 changed files with 13 additions and 13 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, os, times, parseopt, llstream, ast, renderer, options, msgs,
|
strutils, os, times, parseopt, llstream, ast, renderer, options, msgs,
|
||||||
clex, cparse
|
clex, cparse
|
||||||
|
|
||||||
|
|
@ -17,16 +17,16 @@ const
|
||||||
c2nim - C to Nimrod source converter
|
c2nim - C to Nimrod source converter
|
||||||
(c) 2011 Andreas Rumpf
|
(c) 2011 Andreas Rumpf
|
||||||
Usage: c2nim [options] inputfile [options]
|
Usage: c2nim [options] inputfile [options]
|
||||||
Options:
|
Options:
|
||||||
-o, --out:FILE set output filename
|
-o, --out:FILE set output filename
|
||||||
--dynlib:SYMBOL import from dynlib: SYMBOL will be used for the import
|
--dynlib:SYMBOL import from dynlib: SYMBOL will be used for the import
|
||||||
--header:HEADER_FILE import from a HEADER_FILE (discouraged!)
|
--header:HEADER_FILE import from a HEADER_FILE (discouraged!)
|
||||||
--cdecl annotate procs with ``{.cdecl.}``
|
--cdecl annotate procs with ``{.cdecl.}``
|
||||||
--stdcall annotate procs with ``{.stdcall.}``
|
--stdcall annotate procs with ``{.stdcall.}``
|
||||||
--ref convert typ* to ref typ (default: ptr typ)
|
--ref convert typ* to ref typ (default: ptr typ)
|
||||||
--prefix:PREFIX strip prefix for the generated Nimrod identifiers
|
--prefix:PREFIX strip prefix for the generated Nimrod identifiers
|
||||||
(multiple --prefix options are supported)
|
(multiple --prefix options are supported)
|
||||||
--suffix:SUFFIX strip suffix for the generated Nimrod identifiers
|
--suffix:SUFFIX strip suffix for the generated Nimrod identifiers
|
||||||
(multiple --suffix options are supported)
|
(multiple --suffix options are supported)
|
||||||
--skipinclude do not convert ``#include`` to ``import``
|
--skipinclude do not convert ``#include`` to ``import``
|
||||||
--typeprefixes generate ``T`` and ``P`` type prefixes
|
--typeprefixes generate ``T`` and ``P`` type prefixes
|
||||||
|
|
@ -35,7 +35,7 @@ Options:
|
||||||
-h, --help show this help
|
-h, --help show this help
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc main(infile, outfile: string, options: PParserOptions) =
|
proc main(infile, outfile: string, options: PParserOptions) =
|
||||||
var start = getTime()
|
var start = getTime()
|
||||||
var stream = LLStreamOpen(infile, fmRead)
|
var stream = LLStreamOpen(infile, fmRead)
|
||||||
if stream == nil: rawMessage(errCannotOpenFile, infile)
|
if stream == nil: rawMessage(errCannotOpenFile, infile)
|
||||||
|
|
@ -61,10 +61,10 @@ for kind, key, val in getopt():
|
||||||
of "version", "v":
|
of "version", "v":
|
||||||
stdout.write(Version & "\n")
|
stdout.write(Version & "\n")
|
||||||
quit(0)
|
quit(0)
|
||||||
of "o", "out": outfile = key
|
of "o", "out": outfile = val
|
||||||
else:
|
else:
|
||||||
if not parserOptions.setOption(key, val):
|
if not parserOptions.setOption(key, val):
|
||||||
stdout.write("[Error] unknown option: " & key)
|
stdout.writeln("[Error] unknown option: " & key)
|
||||||
of cmdEnd: assert(false)
|
of cmdEnd: assert(false)
|
||||||
if infile.len == 0:
|
if infile.len == 0:
|
||||||
# no filename has been given, so we show the help:
|
# no filename has been given, so we show the help:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, os, parseopt, llstream, ast, renderer, options, msgs,
|
strutils, os, parseopt, llstream, ast, renderer, options, msgs,
|
||||||
paslex, pasparse
|
paslex, pasparse
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ const
|
||||||
pas2nim - Pascal to Nimrod source converter
|
pas2nim - Pascal to Nimrod source converter
|
||||||
(c) 2010 Andreas Rumpf
|
(c) 2010 Andreas Rumpf
|
||||||
Usage: pas2nim [options] inputfile [options]
|
Usage: pas2nim [options] inputfile [options]
|
||||||
Options:
|
Options:
|
||||||
-o, --out:FILE set output filename
|
-o, --out:FILE set output filename
|
||||||
--ref convert ^typ to ref typ (default: ptr typ)
|
--ref convert ^typ to ref typ (default: ptr typ)
|
||||||
--boot use special translation rules for the Nimrod compiler
|
--boot use special translation rules for the Nimrod compiler
|
||||||
|
|
@ -25,7 +25,7 @@ Options:
|
||||||
-h, --help show this help
|
-h, --help show this help
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc main(infile, outfile: string, flags: set[TParserFlag]) =
|
proc main(infile, outfile: string, flags: set[TParserFlag]) =
|
||||||
var stream = LLStreamOpen(infile, fmRead)
|
var stream = LLStreamOpen(infile, fmRead)
|
||||||
if stream == nil: rawMessage(errCannotOpenFile, infile)
|
if stream == nil: rawMessage(errCannotOpenFile, infile)
|
||||||
var p: TParser
|
var p: TParser
|
||||||
|
|
@ -49,10 +49,10 @@ for kind, key, val in getopt():
|
||||||
of "version", "v":
|
of "version", "v":
|
||||||
stdout.write(Version & "\n")
|
stdout.write(Version & "\n")
|
||||||
quit(0)
|
quit(0)
|
||||||
of "o", "out": outfile = key
|
of "o", "out": outfile = val
|
||||||
of "ref": incl(flags, pfRefs)
|
of "ref": incl(flags, pfRefs)
|
||||||
of "boot": flags = flags + {pfRefs, pfMoreReplacements, pfImportBlackList}
|
of "boot": flags = flags + {pfRefs, pfMoreReplacements, pfImportBlackList}
|
||||||
else: stdout.write("[Error] unknown option: " & key)
|
else: stdout.writeln("[Error] unknown option: " & key)
|
||||||
of cmdEnd: assert(false)
|
of cmdEnd: assert(false)
|
||||||
if infile.len == 0:
|
if infile.len == 0:
|
||||||
# no filename has been given, so we show the help:
|
# no filename has been given, so we show the help:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue