atomic is now a keyword

This commit is contained in:
Andreas Rumpf
2010-01-21 19:05:14 +01:00
parent b50133b50f
commit 0ea4b71eec
8 changed files with 77 additions and 39 deletions

31
tools/cmerge.nim Executable file
View File

@@ -0,0 +1,31 @@
# Simple tool to merge C projects into a single C file
import os, strtabs, pegs
proc process(dir, infile: string, outfile: TFile, processed: PStringTable) =
if processed.hasKey(infile): return
processed[infile] = "True"
echo "adding: ", infile
for line in lines(dir / infile):
if line =~ peg"""s <- ig '#include' ig '"' {[^"]+} '"' ig
comment <- '/*' !'*/'* '*/' / '//' .*
ig <- (comment / \s+)* """:
# follow the include file:
process(dir, matches[0], outfile, processed)
else:
writeln(outfile, line)
proc main(dir, outfile: string) =
var o: TFile
if open(o, outfile, fmWrite):
var processed = newStringTable([outfile, "True"])
for infile in walkfiles(dir / "*.c"):
process(dir, extractFilename(infile), o, processed)
close(o)
else:
quit("Cannot open for writing: " & outfile)
if ParamCount() != 2:
echo "Usage: cmerge directory outfile"
else:
main(ParamStr(1), addFileExt(ParamStr(2), "c"))