Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Chomsky hierarchy
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Context-free (Type-2) grammars=== {{main|Context-free grammar}} Type-2 grammars generate the [[context-free language]]s. These are defined by rules of the form <math>A \rightarrow \alpha</math> with <math>A</math> being a nonterminal and <math>\alpha</math> being a string of terminals and/or nonterminals. These languages are exactly all languages that can be recognized by a non-deterministic [[pushdown automaton]]. Context-free languages—or rather its subset of [[deterministic context-free language|deterministic context-free languages]]—are the theoretical basis for the phrase structure of most [[programming language]]s, though their syntax also includes context-sensitive [[Name resolution (programming languages)|name resolution]] due to declarations and [[Scope (computer science)|scope]]. Often a subset of grammars is used to make parsing easier, such as by an [[LL parser]]. For example, the context-free language <math>L = \{a^nb^n \mid n > 0\}</math> is generated by the Type-2 grammar <math>G = (\{S\}, \{a, b\}, P, S)</math> with the productions <math>P</math> being the following. :{{math|''S'' → ''aSb''}} :{{math|''S'' → ''ab''}} The language is context-free but not regular (by the [[pumping lemma for regular languages]]).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)