2
$\begingroup$

Why we use context-free grammar for parsing? Why not regular expression and not context-sensitive grammar?

$\endgroup$
6
$\begingroup$

Because regular expressions are too weak and context-sensitive languages are too difficult to parse. More specifically, regular expressions can't specify that the brackets in your program match up; determining whether a string matches a context-sensitive language is PSPACE-complete (so probably takes exponential time).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.