Im on the platform again waiting for a train, so in the mean time before I can't move my hands due to getting pretty personal with some strangers, let's talk parsers.
What is a parser?
Imagine you are 2 years old again, you may have asked questions to grown-ups from time to time, between you and said grownup, your parents may have needed to step in to translate your unintelligible and very cute pseudo words into language that said grown-up can understand. Your parent just parsed something admittedly simple into something way more complex.
Are we 2 year olds talking to computers?
Most definitely, the computer doesn't understand your B, C, D, Java or JavaScript, we need a way to parse this stuff. There are 2 main ways to do this, parse through compiling and parse through interpreted.
What is compiled?
As a 2 year old, you grab some crayons and attempt to write some words on the nearest furniture you can find, that resulting scribble is understood by your parents who then explain thier interpretation of your scribble to another grownup. There is still interpreted behaviour going on but it's parsed from hard evidence, eg the scibble on the sofa, but it remains there until somebody cleans it off and you scribble again.
What is interpreted?
As a 2 year old who has now had thier crayons confiscated πποΈ, your only option is to babble. This is on the fly and means that your parents must parse your language as it happens.
What is a language actually.
A language is your 2 year old self's now formalized vocabulary, as you grow, you learn new words that enable new features in your life. You start to confirm to a specification, in my case it would have been English. You have a primary way to express yourself, you may prefer scribbles or bables. Although most children can do both, C++ has an interpreter, JavaScript has a compiler, bit still it's rare that a 2 year old is gifted enough to do both well.
Fast forward.
You are sort of all grown up, having known you would always write code (let me know in the comments!). You want to write a DSL, "a what?" A domain specific language, "ohh.. a what?". scss it's a micro language that handles things for a particular ecosystem, jsx and tsx are great examples too. How does anyone make a language like this and make it understandable? Simply put, grammer describes a language, for example a line terminator is ;
, a code block could be tab indented \t
. There are a few systems that allow us to describe grammer. I'm on the train now, times up, so let's get into that next in the series, and why am I talking about it too.
Top comments (0)