Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 12 years, 9 months ago. Active 5 years ago. Viewed k times. Can someone help me put all of this together?
Improve this question. Jason Baker Jason Baker k gold badges silver badges bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Sujoy Sujoy 7, 3 3 gold badges 27 27 silver badges 36 36 bronze badges.
The only thing is that there is only one way the nodes in the syntax tree can be positioned for instance the associativity ambiguity does not exist when a regular grammar is used. This example is actually wrong. The problem is that we don't want to produce two variables in the first rule, but rather two terminals. There are palindromes that can be expressed in a regular grammar: the palindromes that consist of a single character. This shows that a CFG can describe a regular language, even if it violates the left or right linearity.
Admittedly, this is a not-so-obvious palindrome.. Come to think of it, this answer is actually wrong. It says "context-free" grammar is basically any combination of terminals and non-terminals.
Your first grammar is regular. Improve this answer. Fixed, thanks. So is it true that if a grammar produces a regular language there is a regex conversion?
However, there is no algorithm which will tell you what that regular expression is unless the grammar is regular. It's trivial because you only have to look at the form of the rules. No analysis is necessary. But that tells you less about the language recognised by the grammar. It only provides an uoper bound: a context-free grammar cannot recognise a context-sensitive language, but there is no guarantee that the language it recognises is not regular.
Have you checked out the Wikipedia entry on the Chomsky hierarchy? Show 3 more comments. If you can find an infinite distinguishable prefix set, then your language is not regular. Community Bot 1. Draconis Draconis 6, 1 1 gold badge 14 14 silver badges 24 24 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Featured on Meta. Now live: A fully responsive profile. Version labels for answers. Related 1. TOC Quizes. Table of Contents. Save Article. Improve Article. Like Article. Previous Chomsky Hierarchy in Theory of Computation. Next Pumping Lemma in Theory of Computation. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide.
Load Comments.
0コメント