summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-04-21 02:30:54 -0700
committerOri Bernstein <ori@eigenstate.org>2017-04-21 02:37:12 -0700
commit518175c179216ecf8a6bf9129f330cfc8997cf15 (patch)
tree4a664f5044c17e6748857be3252c5b2e6c48c457 /mbld
parent0391facef2fc8f8704fcfb5150b9381876c3aebd (diff)
downloadmc-518175c179216ecf8a6bf9129f330cfc8997cf15.tar.gz
Reorder functions.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/parse.myr122
1 files changed, 62 insertions, 60 deletions
diff --git a/mbld/parse.myr b/mbld/parse.myr
index a8efbf1..614a0a2 100644
--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -7,6 +7,7 @@ use "syssel"
pkg bld =
const load : (b : build# -> bool)
+ $noret const failparse : (p : parser#, msg : byte[:], args : ... -> void)
;;
type parser = struct
@@ -124,6 +125,46 @@ const setmyropt = {p, t
;;
}
+const parse = {b, p, path
+ while true
+ skipspace(p)
+ if !target(b, p)
+ break
+ ;;
+ ;;
+ skipspace(p)
+ if p.rest.len > 0
+ failparse(p, "junk in file near {}\n", p.rest[:std.min(p.rest.len, 10)])
+ -> false
+ ;;
+ -> true
+}
+
+const target = {b, p
+ match word(p)
+ /* targets */
+ | `std.Some "bin": bintarget(b, p)
+ | `std.Some "lib": libtarget(b, p)
+ | `std.Some "test": testtarget(b, p)
+ | `std.Some "gen": cmdtarget(b, p, "gen", false)
+ | `std.Some "cmd": cmdtarget(b, p, "cmd", true)
+ | `std.Some "data": datatarget(b, p, "data")
+ | `std.Some "man": mantarget(b, p)
+ | `std.Some "sub": subtarget(b, p)
+ /* global attributes */
+ | `std.Some "incpath": incpath(b, p, &p.incpath, "incpath")
+ | `std.Some "libdeps": incpath(b, p, &p.libdeps, "libdeps")
+ | `std.Some "testdeps": incpath(b, p, &p.tstdeps, "testdeps")
+ | `std.Some "runtime": p.runtime = expectword(b, p, "runtime")
+ | `std.Some "ldscript": p.runtime = expectword(b, p, "ldscript")
+ | `std.Some "noinst": p.install = false
+ /* no word */
+ | `std.Some targtype: failparse(p, "unknown keyword {}\n", targtype)
+ | `std.None: -> false
+ ;;
+ -> true
+}
+
const mkparser = {path, dir, basedir, sel
var p
@@ -148,6 +189,15 @@ const mkparser = {path, dir, basedir, sel
-> p
}
+const freeparser = {p
+ std.slfree(p.fname)
+ std.slfree(p.fdir)
+ std.slfree(p.basedir)
+ std.slfree(p.subdirs)
+ std.slfree(p.data)
+ std.free(p)
+}
+
const sortdeps = {b
var looped
var marked
@@ -197,66 +247,6 @@ const getdeps = {b, parent, targname
;;
}
-const freeparser = {p
- std.slfree(p.fname)
- std.slfree(p.fdir)
- std.slfree(p.basedir)
- std.slfree(p.subdirs)
- std.slfree(p.data)
- std.free(p)
-}
-
-$noret const failparse = {p, msg, args : ...
- var buf : byte[1024]
- var ap
- var sl
-
- ap = std.vastart(&args)
- sl = std.bfmtv(buf[:], msg, &ap)
- std.fput(1, "{}:{}: {}", p.fname, p.line, sl)
- std.exit(1)
-}
-
-const parse = {b, p, path
- while true
- skipspace(p)
- if !target(b, p)
- break
- ;;
- ;;
- skipspace(p)
- if p.rest.len > 0
- failparse(p, "junk in file near {}\n", p.rest[:std.min(p.rest.len, 10)])
- -> false
- ;;
- -> true
-}
-
-const target = {b, p
- match word(p)
- /* targets */
- | `std.Some "bin": bintarget(b, p)
- | `std.Some "lib": libtarget(b, p)
- | `std.Some "test": testtarget(b, p)
- | `std.Some "gen": cmdtarget(b, p, "gen", false)
- | `std.Some "cmd": cmdtarget(b, p, "cmd", true)
- | `std.Some "data": datatarget(b, p, "data")
- | `std.Some "man": mantarget(b, p)
- | `std.Some "sub": subtarget(b, p)
- /* global attributes */
- | `std.Some "incpath": incpath(b, p, &p.incpath, "incpath")
- | `std.Some "libdeps": incpath(b, p, &p.libdeps, "libdeps")
- | `std.Some "testdeps": incpath(b, p, &p.tstdeps, "testdeps")
- | `std.Some "runtime": p.runtime = expectword(b, p, "runtime")
- | `std.Some "ldscript": p.runtime = expectword(b, p, "ldscript")
- | `std.Some "noinst": p.install = false
- /* no word */
- | `std.Some targtype: failparse(p, "unknown keyword {}\n", targtype)
- | `std.None: -> false
- ;;
- -> true
-}
-
/* <name>: '=' wordlist ';;' */
const incpath = {b, p, words, name
skipspace(p)
@@ -804,3 +794,15 @@ const libpath = {p, libpath
;;
-> (dir, lib, targ)
}
+
+$noret const failparse = {p, msg, args : ...
+ var buf : byte[1024]
+ var ap
+ var sl
+
+ ap = std.vastart(&args)
+ sl = std.bfmtv(buf[:], msg, &ap)
+ std.fput(1, "{}:{}: {}", p.fname, p.line, sl)
+ std.exit(1)
+}
+