Regular vs Context Free Grammars

Regular grammar is either right or left linear, whereas context free grammar is basically any combination of terminals and non-terminals. Hence you can see that regular grammar is a subset of context-free grammar. So for a palindrome for instance, is of the form, S->ABA A->something B->something You can clearly see that palindromes cannot be expressed … Read more

Is C++ context-free or context-sensitive?

Below is my (current) favorite demonstration of why parsing C++ is (probably) Turing-complete, since it shows a program which is syntactically correct if and only if a given integer is prime. So I assert that C++ is neither context-free nor context-sensitive. If you allow arbitrary symbol sequences on both sides of any production, you produce … Read more

The recognizing power of “modern” regexes

Pattern Recursion With recursive patterns, you have a form of recursive descent matching. This is fine for a variety of problems, but once you want to actually do recursive descent parsing, you need to insert capture groups here and there, and it is awkward to recover the full parse structure in this way. Damian Conway’s … Read more