Let's take a look at the context-independent grammar, which generally defines the context-independent grammar:
The BNF paradigm (Backus-naur Form) is often used to denote context-independent grammars ...
Next come a concept called derivation:
There are two types of derivation, the most left-hand and the most right-torn:
In fact, the purpose of lexical analysis can be described by the above-mentioned context-independent grammar:
Here's a question:
Regular grammar
In the course we discuss the context-independent grammar (i.e., type 2 grammar), and we refer to the regular grammar and indicate that it corresponds to the regular expression. Regular grammar is actually a kind of special form of context-independent grammar, each of its production rules can only be one of the following three forms:
A-B C
X-B
Y-
Notice that there are certain constraints on the right side of each rule: the first form is that the right is only Terminator followed by non-Terminator; the second form is that there can only be one terminator on the right, and the right part of the third rule is empty.
Given the following regular expression
A (b|c) *
Try to write the regular grammar that corresponds to it.
My answer:
S--AB
BB B
CB
-
Reading dragon Book compiling Principles of Grammar Analysis (2) ...