meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| code_injection_in_javacc_21 [2020/02/09 17:00] – [2. The INJECT block with no type specified] revusky | code_injection_in_javacc_21 [2020/09/29 10:24] (current) – [1. An INJECT block that specifies the class name] revusky | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| - | Note, first of all, that he '' | + | Note, first of all, that the '' |
| '' | '' | ||
| Line 10: | Line 10: | ||
| This form a class (or interface) name and looks something like this: | This form a class (or interface) name and looks something like this: | ||
| - | | + | |
| - | | + | import foo.bar.IFoobar; |
| - | import foo.bar.Foobar; | + | |
| implements IFoobar; | implements IFoobar; | ||
| - | | ||
| | | ||
| | | ||
| Line 23: | Line 21: | ||
| The above snippet should be self-explanatory. The INJECT statement specifies the class in which to inject the code. In this example, it is '' | The above snippet should be self-explanatory. The INJECT statement specifies the class in which to inject the code. In this example, it is '' | ||
| - | Since an INJECT block can be placed anywhere in your grammar file where you could put a production, you would naturally tend to place the above snippet next to the relevant BNF production, which would, of course, be the '' | + | Since an INJECT block can be placed anywhere in your grammar file where you could put a production, you would naturally tend to place the above snippet next to the relevant BNF production, which would, of course, be the '' |
| ===== 2. The INJECT block with no type specified ===== | ===== 2. The INJECT block with no type specified ===== | ||
| Line 29: | Line 27: | ||
| The other form of writing '' | The other form of writing '' | ||
| - | <pre> | + | < |
| | | ||
| | | ||
| Line 42: | Line 39: | ||
| } | } | ||
| } | } | ||
| + | </ | ||
| - | </ | ||
| - | |||
| The above code causes the code within the block to be injected inside the generated Token.java file -- in this example, it would be presumably so that the Token object can implement the '' | The above code causes the code within the block to be injected inside the generated Token.java file -- in this example, it would be presumably so that the Token object can implement the '' | ||