Grammar and language summary and combing - Job 4

1. carding second chapter, understand and write a summary.

 A: The second chapter is mainly about the grammar and language, there is a certain grammar rules, and these rules of grammar and according to certain rules compiled into a combination of language, language grammar describes all the grammar of the sentence collection;

   According to the definition of formal grammar and language, the grammar G is defined as a four-tuple (V n- , V T , P, S);

   V n- is a non-terminal (or grammatical entity, or variable) current , V T is the terminator set , P is a set of rules , and comprising at least one nonterminal, S is the identifier or start symbol , which is a non-terminal symbol;

   V n- , V T , P is a nonempty finite set , V n- and V T does not contain a common element;

   There grammar Type 0 grammar (grammar phrase), type 1 grammars (context-sensitive grammar), type 2 grammar (CFG), type 3 grammar (regular grammar) four types;

   This chapter also learned syntax tree of knowledge related to some of the sentences in the grammar may be a sentence of two different syntax tree representation, which we call "ambiguous grammar";

  The syntax tree has several important concepts: handle, simple phrases, phrases, sentences, sentence structure, language;

   If in the process of derivation of the left to right is derived is called "the most left", if derived from right to left is called "rightmost derivation", also called "canonical derivation";

   These are probably the contents of the second chapter, the proposed definition of a detailed search of the books or Baidu can find that in here not long-winded;

 

2. Try to write grammar PL / 0 language.

Integer n-    n--> 0 |. 1 | 2 |. 3 | ... |. 8 |. 9

Identifier I       I -> A | B | C | ... | X | Y | Z | A | B | C | ... | X-| the Y | the Z

Expression E     :: = [+ | -] <item> {<subtraction operator> <term>}

Conditional statement   :: = if <condition> then <statement>

Assignment   :: = <id>: = <expression>

Compound statement   :: = begin <statement> {; <statement>} end

Function      <function> -> <main function> <Other functions> | <main function>

Program     :: = <Block> :: = [<Constant Description section>] [<Variable Description section>] [<Process Description section>] <statement>

...

Guess you like

Origin www.cnblogs.com/chenhaowen-shuaishuaide/p/11577452.html