Blog Articles on DDD, Event Sourcing and software development in general, with a sprinkle of PHP and sarcasm.

Writing a DSL parser using PegJS

In the [previous article](/blog/write-dsls-and-code-faster/) I wrote about Domain Specific Languages (DSLs) and how useful they are, but I didn't get into the details of parsing them, that's where this article comes in. Previously we made this DSL: ```javascript User.ScheduleAppointment has { a UserId userId an AppointmentDatetime appointmentDatetime a Location location from { a LocationName locationName from location a Latitude latitude a Longitude longitude } } ``` We want to take the above, and parse it. That means turning the text into an Abstract Syntax Tree (AST). An AST is a tree structure that's easy ...
Read on »

Write DSLs and Code Faster

# What is a DSL DSL stands for Domain Specific language, this means that it is a language that is designed to solve a specific problem in a domain. DSLs are great if you want to write a generic solution to a specific problem without all the boilerplate code. A good DSL is easy to write and understand. Once someone understands the domain language, they can read the DSL, and understand the problem, even if they're not a coder. DSLs allow us to automate many things, including aspects of development, greatly increasing our speed and lowering codes and error rates. # Here's one I made earlier At work, I was getting annoyed with how it a...
Read on »