zevv / npeg

PEGs for Nim, another take
MIT License
330 stars 22 forks source link

Avoid the OS if possible #54

Closed ehmry closed 1 year ago

ehmry commented 1 year ago

Do not import the os module or attempt to create files unless compile-time conditionals indicate that the platform supports it or the behavior is requested from a define. This allows Npeg to be built for platforms without access to an OS.

zevv commented 1 year ago

Excellent, thank you

zevv commented 1 year ago

Just curious: what platform are you targeting?

ehmry commented 1 year ago

Solo5 unikernels. The platform support isn't yet upstreamed to Nim in part because I don't know that to do about the os module.

I use Npeg to parse the initial command-line string from the unikernel supervisor - https://codeberg.org/eris/nim-eris/src/branch/solo5/src/eris/solo5/eris_unikernel.nim#L27 https://git.syndicate-lang.org/ehmry/preserves-nim/src/branch/trunk/src/preserves/private/parse.nim

zevv commented 1 year ago

Nice, I'll have a look at that!

Yeah, for most embedded or non-standard platforms I usually fall back to --os:any, which works in almost any environment and has very few dependencies. Not needing to have any upstream support in the standard libraries is nice, imho.