diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/database.boot | 24 | ||||
-rw-r--r-- | src/interp/sys-driver.boot | 15 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/interp/database.boot b/src/interp/database.boot index 7f6849a3..c6f9c50a 100644 --- a/src/interp/database.boot +++ b/src/interp/database.boot @@ -797,3 +797,27 @@ populateDBFromFile path == while (entry := readExpr dbfile) ~= %nothing repeat makeInitialDB entry finally closeStream dbfile + +printInitdbInfo(path,dbfile) == main(path,dbfile) where + main(path,dbfile) == + for x in parseSpadFile path repeat + x is ['DEF,lhs,:.] => fn(lhs,path,dbfile) + x is ["where",['DEF,lhs,:.],:.] => fn(lhs,path,dbfile) + fn(lhs,path,dbfile) == + if lhs isnt [.,:.] then lhs := [lhs] + db := constructorDB lhs.op + db = nil => nil + form := [id for x in lhs.args] + where id() == (x is [":",x',:.] => x'; x) + form := [lhs.op,:form] + prettyPrint([form,dbConstructorKind db,dbAbbreviation db,path],dbfile) + writeNewline dbfile + +printAllInitdbInfo(srcdir,dbfile) == + paths := DIRECTORY strconc(ensureTrailingSlash srcdir,'"*.spad") + or coreError strconc('"no .spad file in directory ",srcdir) + try + out := outputTextFile dbfile + for path in paths repeat + printInitdbInfo(NAMESTRING path,out) + finally closeStream out diff --git a/src/interp/sys-driver.boot b/src/interp/sys-driver.boot index e2116f08..1a097549 100644 --- a/src/interp/sys-driver.boot +++ b/src/interp/sys-driver.boot @@ -175,6 +175,7 @@ restart() == --% initializeDatabases firstTime? == + getOptionValue "build-initdb" => nil initdb := getOptionValue "initial-db" => populateDBFromFile initdb not firstTime? => openDatabases() fillDatabasesInCore() @@ -306,6 +307,20 @@ buildDatabasesHandler(prog,options,args) == installDriver(Option '"build-databases",function buildDatabasesHandler) + +buildInitdbHandler(prog,options,args) == + $displayStartMsgs := false + initializeGlobalState() + srcdir := getOptionValue "spad-srcdir" or + coreError '"missing --spad-srcdir=<dir> argument" + not string? srcdir => coreError '"invalid value for --spad-srcdir" + dbfile := getOptionValue "output" or '"initdb.daase" + not string? dbfile => coreError '"invalid value for --output" + printAllInitdbInfo(srcdir,dbfile) + coreQuit(errorCount() > 0 => 1; 0) + +installDriver(Option '"build-initdb",function buildInitdbHandler) + --% ++ Main entry point to the interactive system. |