Repository metrics
- Stars
- (346 stars)
- PR merge metrics
- (PR metrics pending)
Description
The current implementation of the .cfg file processing does not have any form of AST and instead evaluates code directly during lexing, mutating the global configuration values in-place. Refactoring the .cfg file parser would allow:
-
make testing simpler - instead of mutating whole global configuration in-place, test can be separated into parser (can test and assert structure of the AST) and evaluation (can properly assert changed values).
-
Together with https://github.com/nim-works/nimskull/issues/158
.cfgparser can now be seen as a simple function of the input(config: string, oldOptions: ActiveOptions) -> ActiveOptions -
std/parsecfgcan be used in regular code, but the compiler has nonstandard implementation that cannot be used or understood by external tooling, requiring full reimplementation. Having proper AST will address this issue at least as far as reading is concerned -
Compiler implementation uses nim lexer to "save space and work", which causes more syntax discrepancies:
path=$config/testis valid in one syntax, but for.cfgyou need to use `path="$config/test" only -
Testament uses parsecfg with support for
'''for multiline string literals implemented vias.substr(a, b-1).multiReplace({"'''": tripleQuote, "\\31": "\31"}) -
Changes can be made either by improving the current
std/parsecfgparser to include events for@if,@commandetc., or rewriting the currentnimconf.nimto use the implementation from parsecfg - in that case new module can be added intoexperimental/parsecfgand used only for compiler needs for the time being.