I'm building a small DSL for some configuration files and I'm exploring the idea of making it a subset of Swift. I've already toyed around with @resultBuilders
and things are looking great. However, I'd also like to limit some of features/libraries that Swift normally has.
In other words, code written in this DSL would be valid Swift code, but not the other way around.
Also, this DSL is fully declarative, it will never be compiled, I just need the syntax + autocompletion/limited intellisense, so I'm skipping altogether the compilation part and focusing on lexical analysis / parsing and semantic analysis.
For the lexer I can use libSyntax
and limit the tokens to my smaller, supported subset. However, I'm not sure what I should use for semantic analysis. I'm looking into SourceKit right now.
I guess my question would be: is this something achievable within a reasonable amount of effor or should I invest my time in trying to write my own simple lexer/semantic analyser.