Skip to content Skip to sidebar Skip to footer

Is JavaScript/ECMAScript A Regular Language?

I've tried a few google searches, and I cannot come up with any articles/previous questions that address this. The reason is a minor dispute I'm having with someone about using in

Solution 1:

Indeed, JavaScript is not a regular language, which can be proved with the fact that braces must be balanced as your intuition suggested.

A useful tool for demonstrating that languages are not regular is the Pumping Lemma. You can use it to demonstrate that if JavaScript was regular, some sequence like

function(){ function() { function(){ ... function () {

(in which { are not matched) could be repeated any number of times when surrounded by a certain prefix and suffix, which is in obviously in contradiction with the fact that curly braces must be matched.


Post a Comment for "Is JavaScript/ECMAScript A Regular Language?"