论文—简单优先文法(国外英文资料).docVIP

  • 4
  • 0
  • 约6.58万字
  • 约 17页
  • 2017-06-05 发布于河南
  • 举报

论文—简单优先文法(国外英文资料).doc

论文—简单优先文法(国外英文资料)

论文—简单优先文法(国外英文资料) We use the three priority relationships to determine whether the symbol stack is moving in or out of the order of the current symbol, and if the first two are moved in, the third is a statute. In the process, we use a handle to search for the grammar that is used for the statute. The leftmost direct phrase in a sentence is called the handle of the sentence pattern. A direct phrase and handle of a pattern can be described by the subtree of its syntax tree. Syntax tree of a simple child tree (only single subtree) strings of symbols of leaf node is the sentence patterns about the simple child of the root node a phrase directly. The symbolic string of the leaves of the simple subtree on the left of the syntax tree is the handle of this pattern. For example: for the grammar G [S] mentioned above, the substring (R) is the handle of the symbol string (R), a). Third, program operation effect To understand the programming ideas of the post, lets look at how the program works, as shown in figure 1. Figure 1. The legal statement runs the result Saw the above program is running as a result, I believe you already have a certain knowledge of simple priority analysis, lets to look at the simple precedence grammar analyzer design train of thought. Fourth, design idea (1) the definition of grammatical structure The public struct MyData/grammar structure definition (to facilitate the analysis of the grammar into two parts) { Public string s1, s2; / / s1 is the non-terminal part of the grammar (before the equals sign), s2 is the second half Public int s2_length; / / s2 length (easy to use) } Public int N = 50; / / the number of grammar bars that can be entered at most Public MyData [] gam = new MyData [N]; / / keep all the grammar in the array Public int num = 0; / / the number of grammar bars entered (2) the preferential relation matrix Analyzing the definition of a priority relationship is not difficult to get the following results: The two linked characters are p

文档评论(0)

1亿VIP精品文档

相关文档