From 72fe3fcafb88ef3e4ca784dafd8b866277561221 Mon Sep 17 00:00:00 2001 From: alaviss Date: Sat, 4 Nov 2023 14:11:06 -0500 Subject: [PATCH] front/nimconf: add exported version of readConfigFile (#1007) ## Summary This API is used by [nimph](https://github.com/disruptek/nimph) to read configuration files for modification. ## Details * This is a part of the effort to get nimph running with nimskull --------- Co-authored-by: Saem Ghani --- compiler/front/nimconf.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/front/nimconf.nim b/compiler/front/nimconf.nim index c21ff1e15e3..d96699ca910 100644 --- a/compiler/front/nimconf.nim +++ b/compiler/front/nimconf.nim @@ -107,7 +107,6 @@ type CancelConfigProcessing = object of CatchableError ## internal error used to halt processing - # ---------------- configuration file parser ----------------------------- # we use Nim's lexer here to save space and work @@ -502,4 +501,11 @@ proc loadConfigs*( stopOnError: stopOnError) parser.loadConfigs(cfg, cache) - +proc readConfigFile*( + filename: AbsoluteFile, cache: IdentCache, + conf: ConfigRef, evtHandler: NimConfEvtWriter +): bool {.inline.} = + # created and exported for `nimph` + var parser = NimConfParser(config: conf, cfgEvtWriter: evtHandler, + stopOnError: true) + parser.readConfigFile(filename, cache)