![cover image](https://wikiwandv2-19431.kxcdn.com/_next/image?url=https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Parsing_a_C_program_that_needs_2_token_lookahead.svg/640px-Parsing_a_C_program_that_needs_2_token_lookahead.svg.png&w=640&q=50)
LL grammar
Type of a context-free grammar / From Wikipedia, the free encyclopedia
Dear Wikiwand AI, let's keep it short by simply answering these key questions:
Can you list the top facts and stats about LL-regular grammar?
Summarize this article for a 10 year old
In formal language theory, an LL grammar is a context-free grammar that can be parsed by an LL parser, which parses the input from Left to right, and constructs a Leftmost derivation of the sentence (hence LL, compared with LR parser that constructs a rightmost derivation). A language that has an LL grammar is known as an LL language. These form subsets of deterministic context-free grammars (DCFGs) and deterministic context-free languages (DCFLs), respectively. One says that a given grammar or language "is an LL grammar/language" or simply "is LL" to indicate that it is in this class.
![Thumb image](http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Parsing_a_C_program_that_needs_2_token_lookahead.svg/320px-Parsing_a_C_program_that_needs_2_token_lookahead.svg.png)
int v;main(){
" and is about to choose a rule to derive the nonterminal "Stmt
". Looking only at the first lookahead token "v
", it cannot decide which of both alternatives for "Stmt
" to choose, since two input continuations are possible. They can be discriminated by peeking at the second lookahead token (yellow background).LL parsers are table-based parsers, similar to LR parsers. LL grammars can alternatively be characterized as precisely those that can be parsed by a predictive parser – a recursive descent parser without backtracking – and these can be readily written by hand. This article is about the formal properties of LL grammars; for parsing, see LL parser or recursive descent parser.