Archive for the ‘ebnf’ tag
Easy DSLs in Scala
Debasish Ghosh has another excellent Scala post, this one on External DSLs made easy with Scala Parser Combinators:
External DSLs are hard since implementing them involves reinventing most of the mechanisms found in a general purpose language. Designing internal DSLs are equally hard, more so in a statically typed language. Dynamically typed languages like Ruby offer strong meta-programming facilities, which help in implementing internal DSLs. But metaprogramming in Ruby is still considered elitist by many, and is not an art mastered by programmers at large.
…
Here is a sample DSL (simplified for brevity) for accepting client orders to buy/sell equities ..(buy 100 IBM shares at max USD 45, sell 50 CISCO shares at min USD 25, buy 100 Google shares at max USD 800) for trading_account "SSS1234"The equivalent XML will be too verbose, too painful for the eyes, and will definitely need more extraneous infrastructure over native language support for meaningful processing.