If you never end up trying to pop from an empty stack, and the stack's empty at the end of the string, the string is valid.įor a context-sensitive language, a PDA isn't enough. To see that in action, you can parse nested parentheses by moving left to right and pushing a left parentheses onto a stack each time you encounter one, and popping each time you encounter a right parentheses. its decision is based only on its current state and input, a push-down automaton also has a stack at its disposal and can peek at the top of the stack for taking decisions. Whereas a finite state machine makes use of no auxiliary storage, i.e. This is presumably what the context-sensitivity of context-sensitive grammars is alluding to.Ī context-free language can be recognized a push-down automaton. If the non-terminal B is preceded by the terminal/literal character c, you rewrite that term to WB but if it's preceded by b, you expand to bb instead. Now consider this other grammar which recognizes strings of the form (e.g. The left-hand side of every rule consists of a single non-terminal (in this case it's always S, but there could be more.) It means all of its production rules have a single non-terminal on their left hand side.įor example, this grammar which recognizes strings of matched parentheses ("()", "()()", "(())()".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |