OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <title>The Lemon Parser Generator</title> | 3 <title>The Lemon Parser Generator</title> |
4 </head> | 4 </head> |
5 <body bgcolor=white> | 5 <body bgcolor=white> |
6 <h1 align=center>The Lemon Parser Generator</h1> | 6 <h1 align=center>The Lemon Parser Generator</h1> |
7 | 7 |
8 <p>Lemon is an LALR(1) parser generator for C or C++. | 8 <p>Lemon is an LALR(1) parser generator for C or C++. |
9 It does the same job as ``bison'' and ``yacc''. | 9 It does the same job as ``bison'' and ``yacc''. |
10 But lemon is not another bison or yacc clone. It | 10 But lemon is not another bison or yacc clone. It |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 It does not have sections or divisions like yacc or bison. Any | 275 It does not have sections or divisions like yacc or bison. Any |
276 declaration can occur at any point in the file. | 276 declaration can occur at any point in the file. |
277 Lemon ignores whitespace (except where it is needed to separate | 277 Lemon ignores whitespace (except where it is needed to separate |
278 tokens) and it honors the same commenting conventions as C and C++.</p> | 278 tokens) and it honors the same commenting conventions as C and C++.</p> |
279 | 279 |
280 <h3>Terminals and Nonterminals</h3> | 280 <h3>Terminals and Nonterminals</h3> |
281 | 281 |
282 <p>A terminal symbol (token) is any string of alphanumeric | 282 <p>A terminal symbol (token) is any string of alphanumeric |
283 and underscore characters | 283 and underscore characters |
284 that begins with an upper case letter. | 284 that begins with an upper case letter. |
285 A terminal can contain lower class letters after the first character, | 285 A terminal can contain lowercase letters after the first character, |
286 but the usual convention is to make terminals all upper case. | 286 but the usual convention is to make terminals all upper case. |
287 A nonterminal, on the other hand, is any string of alphanumeric | 287 A nonterminal, on the other hand, is any string of alphanumeric |
288 and underscore characters than begins with a lower case letter. | 288 and underscore characters than begins with a lower case letter. |
289 Again, the usual convention is to make nonterminals use all lower | 289 Again, the usual convention is to make nonterminals use all lower |
290 case letters.</p> | 290 case letters.</p> |
291 | 291 |
292 <p>In Lemon, terminal and nonterminal symbols do not need to | 292 <p>In Lemon, terminal and nonterminal symbols do not need to |
293 be declared or identified in a separate section of the grammar file. | 293 be declared or identified in a separate section of the grammar file. |
294 Lemon is able to generate a list of all terminals and nonterminals | 294 Lemon is able to generate a list of all terminals and nonterminals |
295 by examining the grammar rules, and it can always distinguish a | 295 by examining the grammar rules, and it can always distinguish a |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 shift, but report a parsing conflict. | 474 shift, but report a parsing conflict. |
475 <li> If the precedence of the token to be shifted is greater than | 475 <li> If the precedence of the token to be shifted is greater than |
476 the precedence of the rule to reduce, then resolve in favor | 476 the precedence of the rule to reduce, then resolve in favor |
477 of the shift. No parsing conflict is reported. | 477 of the shift. No parsing conflict is reported. |
478 <li> If the precedence of the token it be shifted is less than the | 478 <li> If the precedence of the token it be shifted is less than the |
479 precedence of the rule to reduce, then resolve in favor of the | 479 precedence of the rule to reduce, then resolve in favor of the |
480 reduce action. No parsing conflict is reported. | 480 reduce action. No parsing conflict is reported. |
481 <li> If the precedences are the same and the shift token is | 481 <li> If the precedences are the same and the shift token is |
482 right-associative, then resolve in favor of the shift. | 482 right-associative, then resolve in favor of the shift. |
483 No parsing conflict is reported. | 483 No parsing conflict is reported. |
484 <li> If the precedences are the same the the shift token is | 484 <li> If the precedences are the same the shift token is |
485 left-associative, then resolve in favor of the reduce. | 485 left-associative, then resolve in favor of the reduce. |
486 No parsing conflict is reported. | 486 No parsing conflict is reported. |
487 <li> Otherwise, resolve the conflict by doing the shift and | 487 <li> Otherwise, resolve the conflict by doing the shift and |
488 report the parsing conflict. | 488 report the parsing conflict. |
489 </ul> | 489 </ul> |
490 Reduce-reduce conflicts are resolved this way: | 490 Reduce-reduce conflicts are resolved this way: |
491 <ul> | 491 <ul> |
492 <li> If either reduce rule | 492 <li> If either reduce rule |
493 lacks precedence information, then resolve in favor of the | 493 lacks precedence information, then resolve in favor of the |
494 rule that appears first in the grammar and report a parsing | 494 rule that appears first in the grammar and report a parsing |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 883 |
884 <p>If the parser pops its stack until the stack is empty, and it still | 884 <p>If the parser pops its stack until the stack is empty, and it still |
885 is unable to shift the error symbol, then the %parse_failed routine | 885 is unable to shift the error symbol, then the %parse_failed routine |
886 is invoked and the parser resets itself to its start state, ready | 886 is invoked and the parser resets itself to its start state, ready |
887 to begin parsing a new file. This is what will happen at the very | 887 to begin parsing a new file. This is what will happen at the very |
888 first syntax error, of course, if there are no instances of the | 888 first syntax error, of course, if there are no instances of the |
889 ``error'' non-terminal in your grammar.</p> | 889 ``error'' non-terminal in your grammar.</p> |
890 | 890 |
891 </body> | 891 </body> |
892 </html> | 892 </html> |
OLD | NEW |