ref: aff5b4b72e11a8d31e45a0a99d6a02bf1b2f2ed1
parent: f5ac096a0ffa146d382d6087c4132e32a52ec8e2
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Feb 5 14:49:39 EST 2015
Pull parser initialization into mkparser() func.
--- a/build.myr
+++ b/build.myr
@@ -105,7 +105,7 @@
std.fatal(1, "Could not load dependencies for %s\n", targ.name)
;;
if !std.hthas(dg.deps, targ.name)
- std.fatal(1, "no target declared for %s\n", targ.name)
+ std.fatal(1, "no input files for %s\n", targ.name)
;;
if builddep(p, &dg, targ.name, targ.incpath) || !freshlibs(targ, dg.libs)
linkbin(&dg, targ.name, targ.inputs, targ.ldscript, targ.runtime, targ.incpath, targ.libdeps)
--- a/deps.myr
+++ b/deps.myr
@@ -10,7 +10,6 @@
pkg bld =
const myrdeps : (p : parser#, mt : myrtarg#, islib : bool, isclean : bool, dg : depgraph# -> bool)
-
/* a bit ugly: initialized from main() */
var usepat : regex.regex#
--- a/main.myr
+++ b/main.myr
@@ -64,7 +64,7 @@
.ldscript=bld.opt_ldscript,
.libdeps=[][:]
]
- p = std.zalloc()
+ p = mkparser("cli")
if bintarg
bld.buildbin(p, &mt)
else
@@ -97,19 +97,27 @@
const loadbuild = {path
var p
- p = std.zalloc()
- p.line = 1
- p.fname = path
+ p = mkparser(path)
match std.slurp(path)
| `std.Ok d: p.data = d
| `std.Fail _: std.fatal(1, "could not open file 'bldfile'\n")
;;
p.rest = p.data
- p.gensrc = std.mkht(std.strhash, std.streq)
bld.parse(p)
-> p
}
+
+const mkparser = {path
+ var p
+
+ p = std.zalloc()
+ p.line = 1
+ p.fname = "cli"
+ p.gensrc = std.mkht(std.strhash, std.streq)
+ -> p
+}
+
const usage = {prog
std.put("%s [-h] [-I path] [-l lib] [-b bin] inputs...\n", prog)
std.put("\t-h\tprint this help\n")