TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to parse text for a DSL at compile time? (C++)

44 pointsby Cieplakalmost 8 years ago

4 comments

dom96over 7 years ago
It seems like doing this in C++ is overly complex. In language's like Nim where you can just executed ordinary code at compile-time it would be far simpler.
评论 #15064945 未加载
评论 #15065565 未加载
评论 #15067330 未加载
评论 #15064951 未加载
评论 #15066920 未加载
评论 #15068284 未加载
评论 #15069918 未加载
kazinatorover 7 years ago
In practice, what you would do is write a preprocessing&#x2F;code-generating <i>tool</i> that runs in the build environment, as part of the toolchain.
评论 #15068948 未加载
Doxinover 7 years ago
D has this use case solved in a really nice way. All you have to do is write a function that converts the DSL into D code and then do something like `mixin(my_dsl_converter(&#x27;foobar&#x27;))`.
stargrazerover 7 years ago
This may not be quite what the original poster is looking for, but boost::spirit allows one to build DSLs directly in the code. The DSL is then used to parse constructs and execute the results.