Nepedia
Back to Discover
Independent Reader
🔢

Formal grammar

math Maturity 11-13 Next article →

Imagine a set of rules for a game. You start with one special symbol. This is called a start symbol. You use rules to change your symbols into new ones. These are called production rules. Each rule has a left side and a right side. You take what is on the left and swap it for the right.

Terminal and non-terminal symbols example
Terminal and non-terminal symbols example

There are two kinds of symbols in this game. Some are terminal symbols. These are the final parts of a string. They do not change anymore. Other symbols are nonterminal symbols. These are tools that help you keep rewriting. You keep going until only terminal symbols are left.

Some rules are very strict. This creates different types of grammars. Noam Chomsky grouped these into a hierarchy. He found that some grammars are more powerful than others. For example, regular grammars use very simple rules. Context-free grammars use slightly more complex rules. Computer scientists use these ideas to build parsers. A parser is a tool that checks if a string follows the rules. It helps computers understand the form of a language.

180 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:Terminal and non-terminal symbols example.png
Terminal and non-terminal symbols example.png
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.