├── .gitattributes
├── .gitignore
├── LICENSE
├── Module.manifest
├── README.md
├── build.gradle
├── build.sh
├── checkstyle.xml
├── data
└── libstd-4c74cbab78ec4891.fidb
├── extension.properties
├── media
├── analyzer_entry.png
├── decomp_muladd.png
├── extension_entry.png
├── ghidrust.png
├── not_rust_bin.png
├── report.pdf
├── rust_bin.png
├── with_fid.png
└── without_fid.png
└── src
└── main
├── help
└── help
│ ├── TOC_Source.xml
│ ├── shared
│ └── DefaultStyle.css
│ └── topics
│ └── GhidRust
│ ├── help.html
│ └── images
│ ├── analyzer_entry.png
│ ├── decomp_muladd.png
│ ├── extension_entry.png
│ ├── ghidrust.png
│ ├── not_rust_bin.png
│ ├── rust_bin.png
│ ├── with_fid.png
│ └── without_fid.png
├── java
└── ghidrust
│ ├── analyzer
│ └── RustStdAnalyzer.java
│ └── decompiler
│ ├── RustDecPlugin.java
│ ├── RustDecProvider.java
│ └── parser
│ ├── Run.java
│ ├── c
│ ├── CContext.java
│ ├── CFormatter.java
│ ├── CVisitor.java
│ └── gen
│ │ ├── ASTANDExpression.java
│ │ ├── ASTAbstractDeclarator.java
│ │ ├── ASTAdditiveExpression.java
│ │ ├── ASTArgumentExpressionList.java
│ │ ├── ASTAssignmentExpression.java
│ │ ├── ASTCastExpression.java
│ │ ├── ASTCompoundStatement.java
│ │ ├── ASTConditionalExpression.java
│ │ ├── ASTConstantExpression.java
│ │ ├── ASTDeclaration.java
│ │ ├── ASTDeclarationList.java
│ │ ├── ASTDeclarationSpecifiers.java
│ │ ├── ASTDeclarator.java
│ │ ├── ASTDirectAbstractDeclarator.java
│ │ ├── ASTDirectDeclarator.java
│ │ ├── ASTEqualityExpression.java
│ │ ├── ASTExclusiveORExpression.java
│ │ ├── ASTExpression.java
│ │ ├── ASTExpressionStatement.java
│ │ ├── ASTFunctionDefinition.java
│ │ ├── ASTGhostStringToken.java
│ │ ├── ASTIdentifierList.java
│ │ ├── ASTInclusiveORExpression.java
│ │ ├── ASTInitDeclarator.java
│ │ ├── ASTInitDeclaratorList.java
│ │ ├── ASTInitializer.java
│ │ ├── ASTInitializerList.java
│ │ ├── ASTIterationStatement.java
│ │ ├── ASTJumpStatement.java
│ │ ├── ASTLabeledStatement.java
│ │ ├── ASTLogicalANDExpression.java
│ │ ├── ASTLogicalORExpression.java
│ │ ├── ASTMultiplicativeExpression.java
│ │ ├── ASTParameterDeclaration.java
│ │ ├── ASTParameterList.java
│ │ ├── ASTParameterTypeList.java
│ │ ├── ASTPointer.java
│ │ ├── ASTPostfixExpression.java
│ │ ├── ASTPrimaryExpression.java
│ │ ├── ASTRelationalExpression.java
│ │ ├── ASTSelectionStatement.java
│ │ ├── ASTShiftExpression.java
│ │ ├── ASTSpecifierQualifierList.java
│ │ ├── ASTStatement.java
│ │ ├── ASTStatementList.java
│ │ ├── ASTStringToken.java
│ │ ├── ASTTypeName.java
│ │ ├── ASTTypeQualifierList.java
│ │ ├── ASTTypeStringToken.java
│ │ ├── ASTUnaryExpression.java
│ │ ├── CParser.java
│ │ ├── CParserConstants.java
│ │ ├── CParserDefaultVisitor.java
│ │ ├── CParserTokenManager.java
│ │ ├── CParserTreeConstants.java
│ │ ├── CParserVisitor.java
│ │ ├── JJTCParserState.java
│ │ ├── Node.java
│ │ ├── ParseException.java
│ │ ├── SimpleCharStream.java
│ │ ├── SimpleNode.java
│ │ ├── Token.java
│ │ ├── TokenMgrError.java
│ │ ├── c.jj
│ │ └── c.jjt
│ └── generate.sh
└── resources
└── images
├── icon.png
└── reload.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto eol=lf
3 |
4 | # binary files which should not be modified
5 | *.bmp binary
6 | *.dds binary
7 | *.gif binary
8 | *.jpg binary
9 | *.pbm binary
10 | *.pgm binary
11 | *.png binary
12 | *.ppm binary
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # temp files
2 | tmp/
3 |
4 | # editor config files
5 | .idea/
6 | .vscode/
7 | .settings/
8 |
9 | # build directories
10 | bin/
11 | build/
12 | dist/
13 |
14 | # gradle files
15 | .gradle/
16 | gradle/
17 | gradlew
18 | gradlew.bat
19 |
20 | # Java class files
21 | *.class
22 |
23 | # misc
24 | .DS_Store
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2023 Dhruv Maroo
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/Module.manifest:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/Module.manifest
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
GhidRust
4 |
GhidRust: Rust binary analysis extension for Ghidra
5 |
6 |
7 | **Status:** Development has been paused permanently. This plugin is in a partially usable condition. Few Rust binary analysis features have been upstreamed to Ghidra since the creation of this plugin.
8 |
9 | - [GP-2412: Improved support for Rust binaries](https://github.com/NationalSecurityAgency/ghidra/commit/921247f640c9a313bce80dc26e0f99939ddae4ad)
10 | - [GP-4158 adjust how DWARF handles Rust](https://github.com/NationalSecurityAgency/ghidra/commit/d9a900702e838ac639735fa783c342cc3b9ba76d)
11 | - [GP-4103: Fixing issue with loading Mach-O Rust binaries](https://github.com/NationalSecurityAgency/ghidra/commit/9dd1a3fb109578b059ec2c2d5e5ee62d1ec1e67a)
12 |
13 | Ghidra's Rust binary identification is now superior to this plugin. The only other features which this plugin provides is that of FunctionID database integration and of transpiling the decompiled C code to Rust code. Both of these are quite flaky.
14 |
15 | I will still be happy to accept any patches or pull requests, but there won't be any active development. Feel free to fork this project or create a new one. Please let me know if you do so, I will be happy to add your project's link here as an alternative.
16 |
17 | 
18 |
19 | This project was a part of one of my institute courses. For a detailed overview, please have a look at the [report](./media/report.pdf) created for the course submission. The following README is fairly sparse.
20 |
21 | ## Features
22 |
23 | ### Rust binary detection
24 |
25 | The plugin can detect Rust binaries. To use the feature, click on `GhidRust -> Check if Rust binary`. It will show a popup indicating whether it's a Rust binary or not.
26 |
27 | May not be a Rust binary | May be a Rust binary
28 | :-------------------------:|:-------------------------:
29 |  | 
30 |
31 | ### Function ID
32 |
33 | The plugin also consists of `RustStdAnalyzer` which analyzes Rust binaries and applies function signatures to the library functions (Rust's `std`) found in the binary. This is done using `.fidb` function ID database. A default database for x86-64 and Rust version 1.58.1 has been provided at [`libstd.fidb`](./data/libstd-4c74cbab78ec4891.fidb). This is useful when analyzing stripped Rust binaries.
34 |
35 | Without Function ID | With Function ID
36 | :-------------------------:|:-------------------------:
37 |  | 
38 |
39 | The analyzer is enabled by default for Rust binaries, and it's name in analyzer window is _"Detect Rust libstd functions"_.
40 |
41 | 
42 |
43 | ### Decompilation
44 |
45 | This is a work-in-progress feature as of now. It requires parsing the decompiled C code and then emitting the corresponding Rust code. Once that is done, Rust macro support will also be added in the future.
46 |
47 | The decompiler panel can be accessed by clicking `GhidRust -> Open decompiler`. It looks as follows.
48 |
49 | 
50 |
51 | ## Building
52 |
53 | There is a build script provided (`build.sh`) which can build and install the extension.
54 |
55 | ```
56 | $ ./build.sh -h
57 | GhidRust install script
58 | Usage: build.sh [-i | --install] -g GHIDRA_PATH
59 |
60 | -i | --install Install the extension
61 | -g | --ghidra Path to Ghidra installation (usually /opt/ghidra)
62 | -h | --help Show usage/help
63 | ```
64 |
65 | You can build the extension using the following command.
66 |
67 | ```
68 | $ ./build.sh -g
69 | ```
70 |
71 | You can install it using the install flag as follows.
72 |
73 | ```
74 | ./build.sh -ig
75 | ```
76 |
77 | ## Adding it to Ghidra
78 |
79 | To add it to Ghidra, just click on `File -> Install Extensions...` and choose GhidRust there. Once installed, you will have a `GhidRust` entry in the Ghidra toolbar which can be used to invoke the plugin.
80 |
81 | You might need to activate it from the `File -> Configure...` menu. Choose the `Miscellaneous` section, and click the checkbox beside _RustDecPlugin_.
82 |
83 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Builds a Ghidra Extension for a given Ghidra installation.
2 | //
3 | // An absolute path to the Ghidra installation directory must be supplied either by setting the
4 | // GHIDRA_INSTALL_DIR environment variable or Gradle project property:
5 | //
6 | // > export GHIDRA_INSTALL_DIR=
7 | // > gradle
8 | //
9 | // or
10 | //
11 | // > gradle -PGHIDRA_INSTALL_DIR=
12 | //
13 | // Gradle should be invoked from the directory of the project to build. Please see the
14 | // application.gradle.version property in /Ghidra/application.properties
15 | // for the correction version of Gradle to use for the Ghidra installation you specify.
16 |
17 | //----------------------START "DO NOT MODIFY" SECTION------------------------------
18 | def ghidraInstallDir
19 |
20 | if (System.env.GHIDRA_INSTALL_DIR) {
21 | ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
22 | }
23 | else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
24 | ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
25 | }
26 |
27 | if (ghidraInstallDir) {
28 | apply from: new File(ghidraInstallDir).getCanonicalPath() + "/support/buildExtension.gradle"
29 | }
30 | else {
31 | throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
32 | }
33 | //----------------------END "DO NOT MODIFY" SECTION-------------------------------
34 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | success() {
4 | echo -e "\033[32;1m[+]\033[0m" "$1"
5 | }
6 |
7 | status() {
8 | echo -e "\033[33;1m[-]\033[0m" "$1"
9 | }
10 |
11 | failure() {
12 | echo -e "\033[31;1m[!]\033[0m" "$1"
13 | }
14 |
15 | usage() {
16 | echo -e "Usage: $(basename $0) [-i | --install] -g GHIDRA_PATH"
17 | echo -e ""
18 | echo -e "\t-i | --install\t\t Install the extension"
19 | echo -e "\t-g | --ghidra\t\t Path to Ghidra installation (usually /opt/ghidra)"
20 | echo -e "\t-h | --help\t\t Show usage/help"
21 | }
22 |
23 | VALID_ARGS=$(getopt -o ig:h --long install,ghidra:,help -- "$@")
24 |
25 | if [[ $? -ne 0 ]]; then
26 | failure "Invalid arguments provided"
27 | exit 1;
28 | fi
29 |
30 | eval set -- "$VALID_ARGS"
31 |
32 | INSTALL=0
33 | GHIDRA=""
34 |
35 | while [ : ]; do
36 | case "$1" in
37 | -i | --install)
38 | INSTALL=1
39 | shift
40 | ;;
41 | -g | --ghidra)
42 | GHIDRA="$2"
43 | shift 2
44 | ;;
45 | -h | --help)
46 | echo -e "GhidRust install script"
47 | usage
48 | exit 0
49 | ;;
50 | ?)
51 | failure "Invalid arguments provided"
52 | echo -e ""
53 | usage
54 | exit 1
55 | ;;
56 | --) shift;
57 | break
58 | ;;
59 | esac
60 | done
61 |
62 | if [ -z "$GHIDRA" ]
63 | then
64 | failure "Required arguments not provided"
65 | echo -e ""
66 | usage
67 | exit 1
68 | fi
69 |
70 | rm dist/* 2> /dev/null
71 |
72 | status "Building GhidRust"
73 |
74 | gradle -PGHIDRA_INSTALL_DIR="$GHIDRA"
75 |
76 | if [[ $? -ne 0 ]]; then
77 | failure "Build command failed"
78 | exit 1;
79 | fi
80 |
81 | success "Build successful"
82 |
83 | if [ "$INSTALL" -eq "0" ]
84 | then
85 | exit 0
86 | fi
87 |
88 | status "Installing GhidRust"
89 |
90 | sudo rm -f "$GHIDRA"/Extensions/Ghidra/*GhidRust* 2> /dev/null
91 | sudo cp dist/* "$GHIDRA"/Extensions/Ghidra
92 |
93 | if [[ $? -ne 0 ]]; then
94 | failure "Installation failed"
95 | exit 1;
96 | fi
97 |
98 | success "Installation successful"
99 |
100 | status "Next steps"
101 |
102 | echo -e "\t 1. Open Ghidra"
103 | echo -e "\t 2. Go to File -> Install Extensions"
104 | echo -e "\t 3. Tick the checkbox beside GhidRust"
105 | echo -e "\t 4. Restart Ghidra"
106 |
--------------------------------------------------------------------------------
/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
59 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
76 |
77 |
78 |
80 |
81 |
82 |
88 |
89 |
90 |
91 |
94 |
95 |
96 |
97 |
98 |
102 |
103 |
104 |
105 |
106 |
108 |
109 |
110 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
131 |
134 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
182 |
183 |
184 |
186 |
188 |
189 |
190 |
191 |
193 |
194 |
195 |
196 |
198 |
199 |
200 |
201 |
203 |
204 |
205 |
206 |
208 |
209 |
210 |
211 |
213 |
214 |
215 |
216 |
218 |
219 |
220 |
221 |
223 |
224 |
225 |
226 |
228 |
229 |
230 |
231 |
233 |
234 |
235 |
236 |
238 |
239 |
240 |
241 |
243 |
244 |
245 |
246 |
248 |
250 |
252 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
278 |
279 |
280 |
283 |
284 |
285 |
286 |
292 |
293 |
294 |
295 |
299 |
300 |
301 |
302 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
317 |
318 |
319 |
320 |
321 |
322 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
338 |
339 |
340 |
341 |
344 |
345 |
346 |
347 |
348 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
--------------------------------------------------------------------------------
/data/libstd-4c74cbab78ec4891.fidb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/data/libstd-4c74cbab78ec4891.fidb
--------------------------------------------------------------------------------
/extension.properties:
--------------------------------------------------------------------------------
1 | name=@extname@
2 | description=Helps in analyzing and decompiling Rust binaries.
3 | author=DMaroo
4 | createdOn=4/11/2023
5 | version=@extversion@
6 |
--------------------------------------------------------------------------------
/media/analyzer_entry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/analyzer_entry.png
--------------------------------------------------------------------------------
/media/decomp_muladd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/decomp_muladd.png
--------------------------------------------------------------------------------
/media/extension_entry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/extension_entry.png
--------------------------------------------------------------------------------
/media/ghidrust.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/ghidrust.png
--------------------------------------------------------------------------------
/media/not_rust_bin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/not_rust_bin.png
--------------------------------------------------------------------------------
/media/report.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/report.pdf
--------------------------------------------------------------------------------
/media/rust_bin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/rust_bin.png
--------------------------------------------------------------------------------
/media/with_fid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/with_fid.png
--------------------------------------------------------------------------------
/media/without_fid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/media/without_fid.png
--------------------------------------------------------------------------------
/src/main/help/help/TOC_Source.xml:
--------------------------------------------------------------------------------
1 |
2 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/main/help/help/shared/DefaultStyle.css:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | WARNING!
18 | Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but
19 | px (pixel) or with no type marking.
20 |
21 | The blockquote tag is used heavily to control indentation throughout the help docs. Place the
22 | blockquote tag around other elements to create a standard indentation. The default values of
23 | blockquote are:
24 |
25 | blockquote {
26 | display: block;
27 | margin-top: 1em;
28 | margin-bottom: 1em;
29 | margin-left: 40px;
30 | margin-right: 40px;
31 | }
32 |
33 | */
34 |
35 |
36 | /*
37 | Add some indentation for lists to show their relation to the preceding text. The value is
38 | chosen based on the left margin of the body and the blockquote.
39 | */
40 | ul { margin-left: 50px; }
41 | ol { margin-left: 50px; }
42 | li { font-family:times new roman; font-size:14pt; margin-left: 5px; }
43 |
44 |
45 | h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
46 | h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
47 | h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
48 | h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
49 | h5 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:12pt; font-style:italic; }
50 |
51 |
52 | /*
53 | A class to be used for showing screenshot style images. These images will have padding above
54 | and below the image and will be centered. To apply this to a file path, use this syntax:
55 |
56 | */
57 | div.image { margin-top: 20px; margin-bottom: 40px; text-align: center; }
58 |
59 |
60 |
61 | /*
62 | P tag code. Most of the help files nest P tags inside of blockquote tags (the was the
63 | way it had been done in the beginning). The net effect is that the text is indented. In
64 | modern HTML we would use CSS to do this. We need to support the Ghidra P tags, nested in
65 | blockquote tags, as well as naked P tags. The following two lines accomplish this. Note
66 | that the 'blockquote p' definition will inherit from the first 'p' definition.
67 | */
68 | p { margin-left: 40px; font-family:times new roman; font-size:14pt; }
69 | blockquote p { margin-left: 10px; }
70 | p.providedbyplugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
71 | p.relatedtopic { color:#800080; margin-left: 10px; font-size:14pt; }
72 | p.image { margin-top: 100; margin-bottom: 100; }
73 |
74 |
75 | /*
76 | We wish for a tables to have space between it and the preceding element, so that text
77 | is not too close to the top of the table. Also, nest the table a bit so that it is clear
78 | the table relates to the preceding text.
79 | */
80 | table { margin-left: 20px; margin-top: 10px; width: 80%;}
81 | td { font-family:times new roman; font-size:14pt; vertical-align: top; }
82 | th { font-family:times new roman; font-size:14pt; font-weight:bold; background-color: #EDF3FE; }
83 |
84 |
85 |
86 | /*
87 | Code-like formatting for things such as file system paths and proper names of classes,
88 | methods, etc. To apply this to a file path, use this syntax:
89 | ...
90 | */
91 | code { color: black; font-weight: bold; font-family: courier new, monospace; font-size: 14pt; white-space: nowrap; }
92 | code.path { color: #4682B4; font-weight: bold; font-family: courier new, monospace; font-size: 14pt; white-space: nowrap; }
93 |
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/help.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | GhidRust
10 |
11 |
12 |
13 |
14 |
15 |
16 |
Status: Currently, the plugin is under extensive
24 | development. It is far from maturity. But a working prototype can be
25 | expected within a few weeks.
26 |
27 |
Features
28 |
Rust binary detection
29 |
The plugin can detect Rust binaries. To use the feature, click on
30 | GhidRust -> Check if Rust binary. It will show a popup
31 | indicating whether it's a Rust binary or not.
32 |
33 |
34 |
35 |
36 |
May not be a Rust binary
37 |
May be a Rust binary
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
Function ID
48 |
The plugin also consists of RustStdAnalyzer which
49 | analyzes Rust binaries and applies function signatures to the library
50 | functions (Rust's std) found in the binary. This is done
51 | using .fidb function ID database. A default database for
52 | x86-64 and Rust version 1.58.1 has been provided.
53 | This is useful when analyzing stripped Rust binaries.
54 |
55 |
56 |
57 |
Without Function ID
58 |
With Function ID
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
The analyzer is enabled by default for Rust binaries, and it's name
69 | in analyzer window is "Detect Rust libstd functions".
70 |
71 |
Decompilation
72 |
This is a work-in-progress feature as of now. It requires parsing the
73 | decompiled C code and then emitting the corresponding Rust code. Once
74 | that is done, Rust macro support will also be added in the future.
75 |
The decompiler panel can be accessed by clicking
76 | GhidRust -> Open decompiler. It looks as follows.
77 |
78 |
79 |
Building
80 |
There is a build script provided (build.sh) which can
81 | build and install the extension.
You can build the extension using the following command.
90 |
$ ./build.sh -g <GHIDRA_INSTALL_DIR>
91 |
You can install it using the install flag as follows.
92 |
./build.sh -ig <GHIDRA_INSTALL_DIR>
93 |
Adding it to Ghidra
94 |
To add it to Ghidra, just click on
95 | File -> Install Extensions... and choose GhidRust there.
96 | Once installed, you will have a GhidRust entry in the
97 | Ghidra toolbar which can be used to invoke the plugin.
98 |
99 |
You might need to activate it from the
100 | File -> Configure... menu. Choose the
101 | Miscellaneous section, and click the checkbox beside
102 | RustDecPlugin.
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/analyzer_entry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/analyzer_entry.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/decomp_muladd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/decomp_muladd.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/extension_entry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/extension_entry.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/ghidrust.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/ghidrust.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/not_rust_bin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/not_rust_bin.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/rust_bin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/rust_bin.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/with_fid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/with_fid.png
--------------------------------------------------------------------------------
/src/main/help/help/topics/GhidRust/images/without_fid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/help/help/topics/GhidRust/images/without_fid.png
--------------------------------------------------------------------------------
/src/main/java/ghidrust/analyzer/RustStdAnalyzer.java:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package ghidrust.analyzer;
18 |
19 | import ghidra.app.services.AbstractAnalyzer;
20 | import ghidra.app.services.AnalysisPriority;
21 | import ghidra.app.services.AnalyzerType;
22 | import ghidra.app.util.importer.MessageLog;
23 |
24 | import ghidra.program.model.address.Address;
25 | import ghidra.program.model.address.AddressSetView;
26 | import ghidra.program.model.listing.Program;
27 |
28 | import ghidra.util.exception.CancelledException;
29 | import ghidra.util.task.TaskMonitor;
30 |
31 | import ghidra.feature.fid.db.FidFileManager;
32 | import ghidra.framework.Application;
33 |
34 | import java.io.IOException;
35 | import generic.jar.ResourceFile;
36 |
37 | /**
38 | * Ghidra analyzer plugin to find whether the program is a Rust binary.
39 | */
40 | public class RustStdAnalyzer extends AbstractAnalyzer {
41 | private static final byte[][] rustArtifacts = {
42 | "run with `RUST_BACKTRACE=1` environment variable".getBytes(),
43 | "called `Option::unwrap()` on a `None` value".getBytes(),
44 | "called `Result::unwrap()` on an `Err` value".getBytes()
45 | };
46 | private static final String ENABLED_PROPERTY = "DecompilerParameterAnalyzer.enabled";
47 |
48 | /**
49 | * General plugin initialization.
50 | */
51 | public RustStdAnalyzer() {
52 | super("Detect Rust libstd functions",
53 | // CHECKSTYLE:OFF
54 | """
55 | Detects Rust standard library functions from saved signatures and saves analysis time.
56 |
57 | Provided by GhidRust
58 | """,
59 | // CHECKSTYLE:ON
60 | AnalyzerType.FUNCTION_ANALYZER);
61 |
62 | /*
63 | * This is just one above the priority at which the Function ID analyzer runs
64 | * (FUNCTION_ID_ANALYSIS - 1)
65 | * We need to run before the Function ID analyzer runs because we are populating
66 | * the Function ID analyzer
67 | * with our own Function ID databases.
68 | */
69 | setPriority(AnalysisPriority.FUNCTION_ID_ANALYSIS.before().before());
70 | }
71 |
72 | @Override
73 | public boolean getDefaultEnablement(Program program) {
74 | // Make sure the property has not been disabled
75 | String defaultEnabled = System.getProperty(ENABLED_PROPERTY);
76 | if (defaultEnabled != null && !Boolean.parseBoolean(defaultEnabled)) {
77 | return false;
78 | }
79 |
80 | /*
81 | * Be enabled by default so that we can make sure the analysis of Rust functions
82 | * takes place
83 | */
84 | return true;
85 | }
86 |
87 | @Override
88 | public boolean canAnalyze(Program program) {
89 | return isRustBinary(program);
90 | }
91 |
92 | @Override
93 | public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
94 | throws CancelledException {
95 | FidFileManager ffm = FidFileManager.getInstance();
96 | if (ffm == null) {
97 | return false;
98 | }
99 |
100 | ResourceFile dataDir;
101 | try {
102 | dataDir = Application.getModuleDataSubDirectory("");
103 | } catch (IOException exc) {
104 | log.appendException(exc);
105 | return false;
106 | }
107 |
108 | ResourceFile[] libs = dataDir.listFiles();
109 | for (ResourceFile lib : libs) {
110 | monitor.checkCanceled();
111 | ffm.addUserFidFile(lib.getFile(true));
112 | }
113 |
114 | return true;
115 | }
116 |
117 | @Override
118 | public void analysisEnded(Program program) {
119 | super.analysisEnded(program);
120 | }
121 |
122 | /**
123 | * For exposing the Rust checking code. This can be used as an library call
124 | * by any other plugin relying on this plugin.
125 | *
126 | * @param program The program being analyzed.
127 | * @return True if it is a Rust binaru, false otherwise.
128 | */
129 | public static boolean isRustBinary(Program program) {
130 | /*
131 | * Taken from
132 | * https://github.com/mandiant/capa-rules/blob/master/compiler/rust/compiled-
133 | * with-rust.yml
134 | */
135 |
136 | Address startSearch = program.getMinAddress();
137 | for (byte[] searchString : rustArtifacts) {
138 | Address foundAddr = program.getMemory().findBytes(
139 | startSearch, searchString, null, true, null
140 | );
141 | if (foundAddr != null) {
142 | return true;
143 | }
144 | }
145 |
146 | return false;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/RustDecPlugin.java:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package ghidrust.decompiler;
18 |
19 | import ghidra.app.events.ProgramActivatedPluginEvent;
20 | import ghidra.app.events.ProgramClosedPluginEvent;
21 | import ghidra.app.events.ProgramLocationPluginEvent;
22 | import ghidra.app.plugin.PluginCategoryNames;
23 | import ghidra.app.DeveloperPluginPackage;
24 |
25 | import docking.action.DockingAction;
26 | import docking.action.MenuData;
27 | import docking.ActionContext;
28 |
29 | import ghidra.framework.plugintool.Plugin;
30 | import ghidra.framework.plugintool.PluginInfo;
31 | import ghidra.framework.plugintool.PluginTool;
32 | import ghidra.framework.plugintool.util.PluginStatus;
33 | import ghidra.framework.plugintool.PluginEvent;
34 |
35 | import ghidra.program.model.listing.Program;
36 | import ghidra.program.util.ProgramLocation;
37 | import ghidra.util.Msg;
38 | import ghidrust.analyzer.RustStdAnalyzer;
39 |
40 | // @formatter:off
41 | /**
42 | * Add the PluginInfo annotation for the Rust decompiler plugin.
43 | */
44 | @PluginInfo(
45 | status = PluginStatus.STABLE,
46 | packageName = DeveloperPluginPackage.NAME,
47 | category = PluginCategoryNames.ANALYSIS,
48 | shortDescription = "Rust Decompiler",
49 | description = "Decompile Rust binaries' assembly to Rust code",
50 | eventsConsumed = {
51 | ProgramActivatedPluginEvent.class,
52 | ProgramLocationPluginEvent.class,
53 | ProgramClosedPluginEvent.class
54 | }
55 | )
56 | // @formatter:on
57 |
58 | public class RustDecPlugin extends Plugin {
59 | Program program;
60 | RustDecProvider provider;
61 |
62 | /**
63 | * Adds docking actions for opening the decompiler and checking whether the
64 | * binary is a Rust binary.
65 | *
66 | * @param tool PluginTool instance responsible for managing RustDecPlugin.
67 | */
68 | public RustDecPlugin(PluginTool tool) {
69 | super(tool);
70 | provider = new RustDecProvider(this, getName(), null);
71 |
72 | DockingAction decPlugin = new DockingAction("GhidRust", getName()) {
73 | @Override
74 | public void actionPerformed(ActionContext context) {
75 | provider.activateProvider();
76 | ;
77 | }
78 | };
79 |
80 | decPlugin.setEnabled(true);
81 | decPlugin.setMenuBarData(new MenuData(new String[] { "GhidRust", "Open decompiler" }));
82 |
83 | DockingAction checkPlugin = new DockingAction("GhidRust", getName()) {
84 | @Override
85 | public void actionPerformed(ActionContext context) {
86 | if (RustStdAnalyzer.isRustBinary(program)) {
87 | Msg.showInfo(this, null, "GhidRust", "[+] Yes, this may be a Rust binary!");
88 | } else {
89 | Msg.showInfo(this, null, "GhidRust", "[-] No, this may not be a Rust binary!");
90 | }
91 | }
92 | };
93 |
94 | checkPlugin.setEnabled(true);
95 | checkPlugin.setMenuBarData(new MenuData(
96 | new String[] { "GhidRust", "Check if Rust binary" }
97 | ));
98 |
99 | tool.addAction(decPlugin);
100 | tool.addAction(checkPlugin);
101 | }
102 |
103 | @Override
104 | public void processEvent(PluginEvent event) {
105 | if (event instanceof ProgramActivatedPluginEvent) {
106 | program = ((ProgramActivatedPluginEvent) event).getActiveProgram();
107 | provider.setProgram(program);
108 | provider.setLocation(null);
109 | } else if (event instanceof ProgramLocationPluginEvent) {
110 | ProgramLocation location = ((ProgramLocationPluginEvent) event).getLocation();
111 | provider.setLocation(location.getAddress());
112 | } else if (event instanceof ProgramClosedPluginEvent) {
113 | program = null;
114 | provider.setProgram(program);
115 | provider.setLocation(null);
116 | }
117 |
118 | provider.reload();
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/RustDecProvider.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler;
2 |
3 | import ghidra.program.model.listing.Program;
4 | import ghidra.program.model.address.Address;
5 | import ghidra.program.model.listing.Function;
6 |
7 | import ghidra.app.decompiler.DecompInterface;
8 | import ghidra.app.decompiler.DecompileResults;
9 | import ghidrust.decompiler.parser.c.CFormatter;
10 | import ghidrust.decompiler.parser.c.gen.CParser;
11 |
12 | import javax.swing.JComponent;
13 | import javax.swing.JLabel;
14 | import javax.swing.JPanel;
15 | import javax.swing.JTextArea;
16 | import javax.swing.JToolBar;
17 | import javax.swing.JButton;
18 | import javax.swing.Box;
19 | import javax.swing.JScrollPane;
20 | import javax.swing.ScrollPaneConstants;
21 |
22 | import java.awt.BorderLayout;
23 | import java.awt.event.ActionListener;
24 | import java.awt.event.ActionEvent;
25 |
26 | import docking.ComponentProvider;
27 | import ghidra.util.task.ConsoleTaskMonitor;
28 | import resources.ResourceManager;
29 |
30 | /**
31 | * Responsible for decompiling and showing the decompiled code in a window.
32 | */
33 | public class RustDecProvider extends ComponentProvider {
34 | private JPanel panel;
35 | private JTextArea codeArea;
36 | private JLabel funcTitle;
37 |
38 | private Program prog;
39 | private Address addr;
40 |
41 | private DecompInterface decompInterface = null;
42 |
43 | private static final String EMPTY_LABEL = "";
44 |
45 | /**
46 | * Initialize the provider by creating a decompilation interface and the
47 | * decompilation window.
48 | *
49 | * @param plugin Calling plugin, which in our case would be RustDecPlugin.
50 | * @param owner Owner of the plugin.
51 | * @param p Program on which this plugin is being used.
52 | */
53 | public RustDecProvider(RustDecPlugin plugin, String owner, Program p) {
54 | super(plugin.getTool(), owner, owner);
55 | setIcon(ResourceManager.loadImage("images/icon.png"));
56 |
57 | decompInterface = new DecompInterface();
58 | setProgram(p);
59 |
60 | buildPanel();
61 | }
62 |
63 | @Override
64 | public JComponent getComponent() {
65 | return panel;
66 | }
67 |
68 | private void buildPanel() {
69 | panel = new JPanel(new BorderLayout());
70 |
71 | funcTitle = new JLabel(EMPTY_LABEL);
72 | JButton reload = new JButton(ResourceManager.loadImage("images/reload.png"));
73 |
74 | reload.addActionListener(new ActionListener() {
75 | public void actionPerformed(ActionEvent e) {
76 | reload();
77 | }
78 | });
79 |
80 | JToolBar toolbar = new JToolBar("GhidRust", JToolBar.HORIZONTAL);
81 | toolbar.setFloatable(false);
82 | toolbar.add(funcTitle);
83 | toolbar.add(Box.createHorizontalGlue());
84 | toolbar.add(reload);
85 |
86 | codeArea = new JTextArea();
87 | codeArea.setEditable(false);
88 |
89 | JScrollPane scroll = new JScrollPane(codeArea);
90 | scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
91 |
92 | panel.add(toolbar, BorderLayout.PAGE_START);
93 | panel.add(scroll);
94 | }
95 |
96 | public void activateProvider() {
97 | setVisible(true);
98 | }
99 |
100 | /**
101 | * We save the program in a private class variable to be used later, and
102 | * open it using the decompiler interface.
103 | *
104 | * @param p program to be decompiled.
105 | */
106 | public void setProgram(Program p) {
107 | prog = p;
108 |
109 | decompInterface.closeProgram();
110 | if (prog != null) {
111 | decompInterface.openProgram(prog);
112 | }
113 | }
114 |
115 | public void setLocation(Address a) {
116 | addr = a;
117 | }
118 |
119 | /**
120 | * When reload is called, we trigger the decompilation.
121 | */
122 | public void reload() {
123 | if (prog == null) {
124 | funcTitle.setText(EMPTY_LABEL);
125 | codeArea.setText("[?] Open a program to see the decompilation!\n");
126 | return;
127 | }
128 |
129 | if (addr == null) {
130 | funcTitle.setText(EMPTY_LABEL);
131 | codeArea.setText("[?] Select a memory location to decompile!\n");
132 | return;
133 | }
134 |
135 | Function func = prog.getFunctionManager().getFunctionContaining(addr);
136 | if (func == null) {
137 | funcTitle.setText(EMPTY_LABEL);
138 | codeArea.setText("[!] No function found at " + addr.toString() + "\n");
139 | return;
140 | }
141 |
142 | funcTitle.setText(func.getName());
143 |
144 | if (decompInterface == null) {
145 | codeArea.setText("[!] Decompiler has not been initialized!\n");
146 | return;
147 | }
148 |
149 | DecompileResults results = decompInterface.decompileFunction(
150 | func, 0, new ConsoleTaskMonitor()
151 | );
152 | if (results == null || results.getDecompiledFunction() == null
153 | || results.getDecompiledFunction().getC() == null) {
154 | codeArea.setText("[!] Failed to decompile " + func.getName() + "\n");
155 | return;
156 | }
157 |
158 | String decompiled = results.getDecompiledFunction().getC();
159 | String rustCode = "";
160 |
161 | try {
162 | rustCode = CFormatter.format(CParser.transpile(decompiled));
163 | } catch (Exception e) {
164 | rustCode = "/* [!] Failed to transpile " + func.getName() + " */\n" + decompiled;
165 | }
166 |
167 | codeArea.setText(rustCode);
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/Run.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser;
2 |
3 | import ghidrust.decompiler.parser.c.gen.CParser;
4 | import ghidrust.decompiler.parser.c.CFormatter;
5 |
6 | /**
7 | * Run the transpiler as a command line standalone tool (for testing).
8 | */
9 | public class Run {
10 | public static void main(String[] args) {
11 | System.out.println(CFormatter.format(CParser.transpile(System.in)));
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/CContext.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c;
2 |
3 | public class CContext {
4 | public boolean statement_end_sc;
5 |
6 | public CContext() {
7 | statement_end_sc = true;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/CFormatter.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c;
2 |
3 | /**
4 | * Format decompiled code.
5 | */
6 | public class CFormatter {
7 | static int indentLevel;
8 |
9 | static String indent(int level) {
10 | StringBuffer sb = new StringBuffer("");
11 |
12 | for (int i = 0; i < level; i++) {
13 | sb.append("\t");
14 | }
15 |
16 | return sb.toString();
17 | }
18 |
19 | public CFormatter(int initialIndent) {
20 | indentLevel = initialIndent;
21 | }
22 |
23 | /**
24 | * Format the code being passed in by adding newlines and semicolons.
25 | *
26 | * @param code Code as a string.
27 | * @return Formatted code.
28 | */
29 | public static String format(String code) {
30 | StringBuffer pretty = new StringBuffer("");
31 |
32 | int str_len = code.length();
33 | pretty.append(indent(indentLevel));
34 | boolean disable = false;
35 |
36 | for (int i = 0; i < str_len; i++) {
37 | if (code.charAt(i) == '{') {
38 | pretty.append("{\n");
39 | indentLevel++;
40 | pretty.append(indent(indentLevel));
41 | } else if (code.charAt(i) == '}') {
42 | indentLevel--;
43 | if (code.charAt(i - 1) != ';') {
44 | pretty.append("\n");
45 | pretty.append(indent(indentLevel));
46 | } else {
47 | pretty.deleteCharAt(pretty.length() - 1);
48 | }
49 | pretty.append("}");
50 | if (!(i + 1 < str_len && code.charAt(i + 1) == ' ')) {
51 | pretty.append("\n");
52 | pretty.append(indent(indentLevel));
53 | }
54 | } else if (code.charAt(i) == ';') {
55 | pretty.append(";\n");
56 | pretty.append(indent(indentLevel));
57 | } else if (code.charAt(i) == '@') {
58 | /* special character to denote no action for next char */
59 | i++;
60 | pretty.append(code.charAt(i));
61 | } else {
62 | pretty.append(code.charAt(i));
63 | }
64 | }
65 |
66 | return pretty.toString();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/CVisitor.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c;
2 |
3 | // CHECKSTYLE:OFF
4 | import ghidrust.decompiler.parser.c.gen.*;
5 | import java.util.HashMap;
6 |
7 | /* Generated By:JavaCC: Do not edit this line. CParserDefaultVisitor.java Version 7.0.9 */
8 | public class CVisitor implements CParserVisitor {
9 | HashMap type_map = new HashMap();
10 |
11 | public CVisitor() {
12 | type_map.put("void", "");
13 | type_map.put("int", "i32");
14 |
15 | /* Not entirely true, but works for now */
16 | type_map.put("char", "char");
17 |
18 | type_map.put("short", "i16");
19 | type_map.put("long", "i32");
20 | type_map.put("float", "f32");
21 | type_map.put("double", "f64");
22 | type_map.put("signed", "i32");
23 | type_map.put("unsigned", "u32");
24 | type_map.put("code", "code");
25 | }
26 |
27 | public Object defaultVisit(SimpleNode node, Object data) {
28 | StringBuilder sb = new StringBuilder("");
29 |
30 | int child_count = node.jjtGetNumChildren();
31 | for (int i = 0; i < child_count; i++) {
32 | Node child = node.jjtGetChild(i);
33 | String ret = (String) child.jjtAccept(this, data);
34 | if (ret != null) {
35 | sb.append(ret);
36 | }
37 | }
38 |
39 | return sb.toString();
40 | }
41 |
42 | public Object defaultSpacedVisit(SimpleNode node, Object data, String separator, boolean last) {
43 | StringBuilder sb = new StringBuilder("");
44 |
45 | int child_count = node.jjtGetNumChildren();
46 | for (int i = 0; i < child_count; i++) {
47 | Node child = node.jjtGetChild(i);
48 | String ret = (String) child.jjtAccept(this, data);
49 | if (ret != null) {
50 | sb.append(ret);
51 | if (!ret.equals("") && (last || i != child_count - 1)) {
52 | sb.append(separator);
53 | }
54 | }
55 | }
56 |
57 | return sb.toString();
58 | }
59 |
60 | public Object visit(SimpleNode node, Object data) {
61 | return node.jjtAccept(this, data);
62 | }
63 |
64 | public Object visit(ASTStringToken node, Object data) {
65 | return node.image;
66 | }
67 |
68 | public Object visit(ASTGhostStringToken node, Object data) {
69 | return "";
70 | }
71 |
72 | public Object visit(ASTTypeStringToken node, Object data) {
73 | String typename = node.image;
74 |
75 | if (type_map.containsKey(typename)) {
76 | return type_map.get(typename);
77 | } else {
78 | return typename;
79 | }
80 | }
81 |
82 | public Object visit(ASTFunctionDefinition node, Object data) {
83 | node.dump("");
84 | StringBuilder rust_code = new StringBuilder("");
85 |
86 | rust_code.append("fn ");
87 | rust_code.append(node.jjtGetChild(1).jjtAccept(this, data));
88 |
89 | String ret_type = (String) node.jjtGetChild(0).jjtAccept(this, data);
90 | if (!ret_type.equals("")) {
91 | rust_code.append("-> ");
92 | }
93 | rust_code.append(ret_type);
94 | rust_code.append(" {");
95 | rust_code.append(node.jjtGetChild(2).jjtAccept(this, data));
96 | rust_code.append("}");
97 |
98 | return rust_code.toString();
99 | }
100 |
101 | public Object visit(ASTDeclaration node, Object data) {
102 | StringBuilder sb = new StringBuilder("");
103 | String[] ret = (String[]) node.jjtGetChild(1).jjtAccept(this, data);
104 |
105 | for (int i = 0; i < ret.length / 2; i++) {
106 | sb.append("let mut ");
107 | sb.append(ret[2 * i]);
108 | sb.append(": ");
109 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
110 | if (ret[2 * i + 1] != null) {
111 | sb.append(" = ");
112 | sb.append(ret[2 * i + 1]);
113 | }
114 | sb.append(";");
115 | }
116 |
117 | return sb.toString();
118 | }
119 |
120 | public Object visit(ASTDeclarationList node, Object data) {
121 | return defaultVisit(node, data);
122 | }
123 |
124 | public Object visit(ASTDeclarationSpecifiers node, Object data) {
125 | return defaultSpacedVisit(node, data, " ", false);
126 | }
127 |
128 | public Object visit(ASTInitDeclaratorList node, Object data) {
129 | String[] ret = new String[node.jjtGetNumChildren() * 2];
130 | for (int i = 0; i < node.jjtGetNumChildren(); i++) {
131 | String[] child_ret = (String[]) node.jjtGetChild(i).jjtAccept(this, data);
132 | ret[2 * i] = child_ret[0];
133 | ret[2 * i + 1] = child_ret[1];
134 | }
135 |
136 | return ret;
137 | }
138 |
139 | public Object visit(ASTInitDeclarator node, Object data) {
140 | String[] ret = new String[2];
141 | ret[0] = (String) node.jjtGetChild(0).jjtAccept(this, data);
142 | if (node.jjtGetNumChildren() == 1) {
143 | ret[1] = null;
144 | } else {
145 | ret[1] = (String) node.jjtGetChild(1).jjtAccept(this, data);
146 | }
147 |
148 | return ret;
149 | }
150 |
151 | public Object visit(ASTSpecifierQualifierList node, Object data) {
152 | return defaultVisit(node, data);
153 | }
154 |
155 | public Object visit(ASTDeclarator node, Object data) {
156 | return defaultVisit(node, data);
157 | }
158 |
159 | public Object visit(ASTDirectDeclarator node, Object data) {
160 | int child_num = node.jjtGetNumChildren();
161 |
162 | StringBuilder sb = new StringBuilder("");
163 | for (int i = 0; i < child_num; i++) {
164 | Node child = node.jjtGetChild(i);
165 | String child_val = (String) child.jjtAccept(this, data);
166 |
167 | if (child instanceof ASTDeclarator || child instanceof ASTParameterTypeList
168 | || child instanceof ASTIdentifierList) {
169 | sb.append("(");
170 | sb.append(child_val);
171 | sb.append(") ");
172 | } else if (child instanceof ASTConstantExpression) {
173 | sb.append("[");
174 | sb.append(child_val);
175 | sb.append("] ");
176 | } else {
177 | sb.append(child_val);
178 | }
179 | }
180 |
181 | return sb.toString();
182 | }
183 |
184 | public Object visit(ASTPointer node, Object data) {
185 | return defaultVisit(node, data);
186 | }
187 |
188 | public Object visit(ASTTypeQualifierList node, Object data) {
189 | return defaultVisit(node, data);
190 | }
191 |
192 | public Object visit(ASTParameterTypeList node, Object data) {
193 | return defaultVisit(node, data);
194 | }
195 |
196 | public Object visit(ASTParameterList node, Object data) {
197 | StringBuilder sb = new StringBuilder("");
198 | for (int i = 0; i < node.jjtGetNumChildren(); i++) {
199 | if (i != 0) {
200 | sb.append(", ");
201 | }
202 | sb.append(node.jjtGetChild(i).jjtAccept(this, data));
203 | }
204 |
205 | return sb.toString();
206 | }
207 |
208 | public Object visit(ASTParameterDeclaration node, Object data) {
209 | StringBuilder sb = new StringBuilder("");
210 |
211 | if (node.jjtGetNumChildren() > 1) {
212 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
213 | sb.append(": ");
214 | }
215 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
216 | return sb.toString();
217 | }
218 |
219 | public Object visit(ASTIdentifierList node, Object data) {
220 | return defaultVisit(node, data);
221 | }
222 |
223 | public Object visit(ASTInitializer node, Object data) {
224 | return defaultVisit(node, data);
225 | }
226 |
227 | public Object visit(ASTInitializerList node, Object data) {
228 | return defaultVisit(node, data);
229 | }
230 |
231 | public Object visit(ASTTypeName node, Object data) {
232 | return defaultVisit(node, data);
233 | }
234 |
235 | public Object visit(ASTAbstractDeclarator node, Object data) {
236 | return defaultVisit(node, data);
237 | }
238 |
239 | public Object visit(ASTDirectAbstractDeclarator node, Object data) {
240 | return defaultVisit(node, data);
241 | }
242 |
243 | public Object visit(ASTStatement node, Object data) {
244 | StringBuilder sb = new StringBuilder("");
245 |
246 | CContext ctx = new CContext();
247 | int child_num = node.jjtGetNumChildren();
248 |
249 | for (int i = 0; i < child_num; i++) {
250 | sb.append(node.jjtGetChild(i).jjtAccept(this, ctx));
251 |
252 | if (ctx.statement_end_sc) {
253 | sb.append(";");
254 | } else {
255 | ctx.statement_end_sc = true;
256 | }
257 | }
258 |
259 | return sb.toString();
260 | }
261 |
262 | public Object visit(ASTLabeledStatement node, Object data) {
263 | return defaultVisit(node, data);
264 | }
265 |
266 | public Object visit(ASTExpressionStatement node, Object data) {
267 | return defaultVisit(node, data);
268 | }
269 |
270 | public Object visit(ASTCompoundStatement node, Object data) {
271 | String ret = (String) defaultVisit(node, data);
272 | ((CContext) data).statement_end_sc = false;
273 | return ret;
274 | }
275 |
276 | public Object visit(ASTStatementList node, Object data) {
277 | return defaultVisit(node, data);
278 | }
279 |
280 | public Object visit(ASTSelectionStatement node, Object data) {
281 | StringBuilder ret = new StringBuilder(
282 | "if " + node.jjtGetChild(0).jjtAccept(this, data) + " {" + node.jjtGetChild(1).jjtAccept(this, data));
283 | ret.append("}");
284 | ((CContext) data).statement_end_sc = false;
285 | return ret;
286 | }
287 |
288 | public Object visit(ASTIterationStatement node, Object data) {
289 | StringBuilder sb = new StringBuilder("");
290 |
291 | if (node.choice == 1) {
292 | ((CContext) data).statement_end_sc = false;
293 |
294 | sb.append("while ");
295 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
296 | sb.append(" {");
297 |
298 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
299 | sb.append("}");
300 | } else if (node.choice == 2) {
301 | sb.append("do {");
302 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
303 | sb.append("} while (");
304 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
305 | sb.append(")");
306 | }
307 |
308 | return sb.toString();
309 | }
310 |
311 | public Object visit(ASTJumpStatement node, Object data) {
312 | StringBuilder sb = new StringBuilder("");
313 |
314 | if (node.choice == 2) {
315 | return "break";
316 | } else if (node.choice == 3) {
317 | return "continue";
318 | } else if (node.choice == 4) {
319 | ((CContext) data).statement_end_sc = false;
320 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
321 | } else {
322 | sb.append(defaultVisit(node, data));
323 | }
324 |
325 | return sb.toString();
326 | }
327 |
328 | public Object visit(ASTExpression node, Object data) {
329 | if (node.jjtGetChild(0) instanceof ASTAssignmentExpression) {
330 | return defaultSpacedVisit(node, data, " ", false);
331 | } else {
332 | ASTDeclaration decl = new ASTDeclaration(0);
333 | decl.jjtAddChild(node.jjtGetChild(0), 0);
334 | decl.jjtAddChild(node.jjtGetChild(1), 1);
335 | return decl.jjtAccept(this, data);
336 | }
337 | }
338 |
339 | public Object visit(ASTAssignmentExpression node, Object data) {
340 | return defaultSpacedVisit(node, data, " ", false);
341 | }
342 |
343 | public Object visit(ASTConditionalExpression node, Object data) {
344 | return defaultSpacedVisit(node, data, " ", false);
345 | }
346 |
347 | public Object visit(ASTConstantExpression node, Object data) {
348 | return defaultSpacedVisit(node, data, " ", false);
349 | }
350 |
351 | public Object visit(ASTLogicalORExpression node, Object data) {
352 | return defaultSpacedVisit(node, data, " ", false);
353 | }
354 |
355 | public Object visit(ASTLogicalANDExpression node, Object data) {
356 | return defaultSpacedVisit(node, data, " ", false);
357 | }
358 |
359 | public Object visit(ASTInclusiveORExpression node, Object data) {
360 | return defaultSpacedVisit(node, data, " ", false);
361 | }
362 |
363 | public Object visit(ASTExclusiveORExpression node, Object data) {
364 | return defaultSpacedVisit(node, data, " ", false);
365 | }
366 |
367 | public Object visit(ASTANDExpression node, Object data) {
368 | return defaultSpacedVisit(node, data, " ", false);
369 | }
370 |
371 | public Object visit(ASTEqualityExpression node, Object data) {
372 | return defaultSpacedVisit(node, data, " ", false);
373 | }
374 |
375 | public Object visit(ASTRelationalExpression node, Object data) {
376 | return defaultSpacedVisit(node, data, " ", false);
377 | }
378 |
379 | public Object visit(ASTShiftExpression node, Object data) {
380 | return defaultSpacedVisit(node, data, " ", false);
381 | }
382 |
383 | public Object visit(ASTAdditiveExpression node, Object data) {
384 | return defaultSpacedVisit(node, data, " ", false);
385 | }
386 |
387 | public Object visit(ASTMultiplicativeExpression node, Object data) {
388 | return defaultSpacedVisit(node, data, " ", false);
389 | }
390 |
391 | public Object visit(ASTCastExpression node, Object data) {
392 | StringBuilder sb = new StringBuilder("");
393 | if (node.jjtGetNumChildren() > 1) {
394 | sb.append("(");
395 |
396 | sb.append("(");
397 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
398 | sb.append(")");
399 |
400 | sb.append(" as ");
401 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
402 |
403 | sb.append(")");
404 | } else {
405 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
406 | }
407 |
408 | return sb.toString();
409 | }
410 |
411 | public Object visit(ASTUnaryExpression node, Object data) {
412 | String visit = (String) defaultVisit(node, data);
413 |
414 | if (node.choice > 1) {
415 | return "(" + visit + ")";
416 | } else {
417 | return visit;
418 | }
419 | }
420 |
421 | public Object visit(ASTPostfixExpression node, Object data) {
422 | StringBuilder sb = new StringBuilder("");
423 | sb.append(node.jjtGetChild(0).jjtAccept(this, data));
424 |
425 | if (node.choice == 1) {
426 | sb.append("[");
427 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
428 | sb.append("]");
429 |
430 | return sb.toString();
431 | } else if (node.choice == 2) {
432 | /* Function call */
433 | sb.append("(");
434 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
435 | sb.append(")");
436 |
437 | return sb.toString();
438 | } else if (node.choice == 3) {
439 | /* Field access */
440 | sb.append(".");
441 | sb.append(node.jjtGetChild(1).jjtAccept(this, data));
442 |
443 | return sb.toString();
444 | }
445 |
446 | return defaultSpacedVisit(node, data, " ", false);
447 | }
448 |
449 | public Object visit(ASTPrimaryExpression node, Object data) {
450 | return defaultSpacedVisit(node, data, " ", false);
451 | }
452 |
453 | public Object visit(ASTArgumentExpressionList node, Object data) {
454 | return defaultSpacedVisit(node, data, ", ", false);
455 | }
456 | }
457 | // CHECKSTYLE:ON
458 |
459 | /*
460 | * JavaCC - OriginalChecksum=fd39d82df2a1b516298b94d6f4a5e997 (do not edit this
461 | * line)
462 | */
463 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTANDExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTANDExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTANDExpression extends SimpleNode {
7 | public ASTANDExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTANDExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=7e93c9974e8f2b14420427b910c803b4 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTAbstractDeclarator.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTAbstractDeclarator.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTAbstractDeclarator extends SimpleNode {
7 | public ASTAbstractDeclarator(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTAbstractDeclarator(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=3c80989bb20f86b9b8036d71e7bef9c2 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTAdditiveExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTAdditiveExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTAdditiveExpression extends SimpleNode {
7 | public ASTAdditiveExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTAdditiveExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=f71bb1e7a072d878a992f57313d16468 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTArgumentExpressionList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTArgumentExpressionList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTArgumentExpressionList extends SimpleNode {
7 | public ASTArgumentExpressionList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTArgumentExpressionList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=3d50396a2f3da00f02231d6bf8462c1f (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTAssignmentExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTAssignmentExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTAssignmentExpression extends SimpleNode {
7 | public ASTAssignmentExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTAssignmentExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4e1bb62c278549e39d52bdb3b3ba2d83 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTCastExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTCastExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTCastExpression extends SimpleNode {
7 | public ASTCastExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTCastExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=5f74743ccea636bb6764ebed2ac163e2 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTCompoundStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTCompoundStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTCompoundStatement extends SimpleNode {
7 | public ASTCompoundStatement(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTCompoundStatement(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=0e0e31b45cd47c4f4461f95fd3e3de78 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTConditionalExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTConditionalExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTConditionalExpression extends SimpleNode {
7 | public ASTConditionalExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTConditionalExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=0abef7756156c947795a60956e579484 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTConstantExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTConstantExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTConstantExpression extends SimpleNode {
7 | public ASTConstantExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTConstantExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=9f5650e6758d6a765d019f16147af60b (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDeclaration.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDeclaration.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDeclaration extends SimpleNode {
7 | public ASTDeclaration(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDeclaration(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=348ef19493387532712ee3fd63bef963 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDeclarationList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDeclarationList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDeclarationList extends SimpleNode {
7 | public ASTDeclarationList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDeclarationList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=74a8d1f0be8d1ac35c19038dd28661b6 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDeclarationSpecifiers.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDeclarationSpecifiers.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDeclarationSpecifiers extends SimpleNode {
7 | public ASTDeclarationSpecifiers(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDeclarationSpecifiers(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=2696c846786a5a2eade82856402afbaa (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDeclarator.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDeclarator.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDeclarator extends SimpleNode {
7 | public ASTDeclarator(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDeclarator(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=8171a8ae0c9b5d4aed5906caced0fc03 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDirectAbstractDeclarator.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDirectAbstractDeclarator.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDirectAbstractDeclarator extends SimpleNode {
7 | public ASTDirectAbstractDeclarator(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDirectAbstractDeclarator(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=73556b7b7bb74f11f30bb99721dd1118 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTDirectDeclarator.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTDirectDeclarator.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTDirectDeclarator extends SimpleNode {
7 | public ASTDirectDeclarator(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTDirectDeclarator(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4b709aa773fb5b1aa3770e5a95e3fa10 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTEqualityExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTEqualityExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTEqualityExpression extends SimpleNode {
7 | public ASTEqualityExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTEqualityExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=aab2519466666944adaf86111afb0582 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTExclusiveORExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTExclusiveORExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTExclusiveORExpression extends SimpleNode {
7 | public ASTExclusiveORExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTExclusiveORExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=6f56922e1bdf9afc2877228247e2891b (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTExpression extends SimpleNode {
7 | public ASTExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=9adff7edeff999906ffb1039a66f050d (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTExpressionStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTExpressionStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTExpressionStatement extends SimpleNode {
7 | public ASTExpressionStatement(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTExpressionStatement(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=1c74fd0cb78ed440334aeeb1769835bf (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTFunctionDefinition.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTFunctionDefinition.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTFunctionDefinition extends SimpleNode {
7 | public ASTFunctionDefinition(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTFunctionDefinition(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=ceed4da5ab63eb8db1c189c0a2b48e1d (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTGhostStringToken.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTGhostStringToken.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTGhostStringToken extends SimpleNode {
7 | public String image;
8 | public ASTGhostStringToken(int id) {
9 | super(id);
10 | }
11 |
12 | public ASTGhostStringToken(CParser p, int id) {
13 | super(p, id);
14 | }
15 |
16 |
17 | /** Accept the visitor. **/
18 | public Object jjtAccept(CParserVisitor visitor, Object data) {
19 |
20 | return
21 | visitor.visit(this, data);
22 | }
23 | }
24 | /* JavaCC - OriginalChecksum=f69f4334f2315a848a78628a0a52e742 (do not edit this line) */
25 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTIdentifierList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTIdentifierList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTIdentifierList extends SimpleNode {
7 | public ASTIdentifierList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTIdentifierList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4b59a3f78866b6522e8f01a33a7e42ea (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTInclusiveORExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTInclusiveORExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTInclusiveORExpression extends SimpleNode {
7 | public ASTInclusiveORExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTInclusiveORExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4be48bfdf235cd5783ba6d95e5f75d7a (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTInitDeclarator.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTInitDeclarator.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTInitDeclarator extends SimpleNode {
7 | public ASTInitDeclarator(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTInitDeclarator(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=5a3d91755680a04c5498b43e77500777 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTInitDeclaratorList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTInitDeclaratorList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTInitDeclaratorList extends SimpleNode {
7 | public ASTInitDeclaratorList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTInitDeclaratorList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=a2d08638fd0cf7a82e33e58b0478332a (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTInitializer.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTInitializer.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTInitializer extends SimpleNode {
7 | public ASTInitializer(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTInitializer(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=1e50ef3004d5c30bf923f81791f50da2 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTInitializerList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTInitializerList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTInitializerList extends SimpleNode {
7 | public ASTInitializerList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTInitializerList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=558244df30965162e70057ea29c24a1b (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTIterationStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTIterationStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTIterationStatement extends SimpleNode {
7 | public int choice;
8 |
9 | public ASTIterationStatement(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTIterationStatement(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=7b7c82e89dcb516eca8590537cd9f70a (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTJumpStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTJumpStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTJumpStatement extends SimpleNode {
7 | public int choice;
8 |
9 | public ASTJumpStatement(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTJumpStatement(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=8f8900c8aee5bbcbce1cd63910a5145a (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTLabeledStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTLabeledStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTLabeledStatement extends SimpleNode {
7 | public ASTLabeledStatement(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTLabeledStatement(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=90c945b0f67caa48bc985322079aff53 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTLogicalANDExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTLogicalANDExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTLogicalANDExpression extends SimpleNode {
7 | public ASTLogicalANDExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTLogicalANDExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=1d00e1b3f3b5cc84eb240091695aa110 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTLogicalORExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTLogicalORExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTLogicalORExpression extends SimpleNode {
7 | public ASTLogicalORExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTLogicalORExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4b98654445da39285ab465c0e8addd5e (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTMultiplicativeExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTMultiplicativeExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTMultiplicativeExpression extends SimpleNode {
7 | public ASTMultiplicativeExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTMultiplicativeExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=bc0ec0ccb8aa48f86316c0b7a00f830c (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTParameterDeclaration.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTParameterDeclaration.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTParameterDeclaration extends SimpleNode {
7 | public ASTParameterDeclaration(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTParameterDeclaration(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4aebee4940a994d0d51c48c5280f9eb8 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTParameterList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTParameterList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTParameterList extends SimpleNode {
7 | public ASTParameterList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTParameterList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=4df2dd10fe864789b789e1afaa3b1ed1 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTParameterTypeList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTParameterTypeList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTParameterTypeList extends SimpleNode {
7 | public ASTParameterTypeList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTParameterTypeList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=2424e97a6a345ef3f2a72b0086086cb7 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTPointer.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTPointer.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTPointer extends SimpleNode {
7 | public ASTPointer(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTPointer(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=e3d91b51bd9822af624c9f60557bbd98 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTPostfixExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTPostfixExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTPostfixExpression extends SimpleNode {
7 | public int choice;
8 |
9 | public ASTPostfixExpression(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTPostfixExpression(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=921e4951da40bb22d131f8b3ba6a1988 (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTPrimaryExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTPrimaryExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTPrimaryExpression extends SimpleNode {
7 | public ASTPrimaryExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTPrimaryExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=74ddac2af3988d157a1b94a9d821defd (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTRelationalExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTRelationalExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTRelationalExpression extends SimpleNode {
7 | public ASTRelationalExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTRelationalExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=819382a46b070e41d5029a3e39fe5a89 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTSelectionStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTSelectionStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTSelectionStatement extends SimpleNode {
7 | public ASTSelectionStatement(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTSelectionStatement(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=1d0effb2de665660bde555051d4eaf39 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTShiftExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTShiftExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTShiftExpression extends SimpleNode {
7 | public ASTShiftExpression(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTShiftExpression(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=6e6a85bea0361907c843fbe90c9de598 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTSpecifierQualifierList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTSpecifierQualifierList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTSpecifierQualifierList extends SimpleNode {
7 | public ASTSpecifierQualifierList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTSpecifierQualifierList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=7fafbaad1e5888617b5543d24af0d7e3 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTStatement.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTStatement.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTStatement extends SimpleNode {
7 | public ASTStatement(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTStatement(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=c72fe84922519215ac2b49c1d95d7b03 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTStatementList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTStatementList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTStatementList extends SimpleNode {
7 | public ASTStatementList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTStatementList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=7d811424c808895d04aa0efe33fefd71 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTStringToken.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTStringToken.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTStringToken extends SimpleNode {
7 | public String image;
8 |
9 | public ASTStringToken(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTStringToken(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=73f64d714d8c3f0f819df770be5c932d (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTTypeName.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTTypeName.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTTypeName extends SimpleNode {
7 | public ASTTypeName(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTTypeName(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=6649fc4e18b27ff4c36885518a37d22c (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTTypeQualifierList.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTTypeQualifierList.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTTypeQualifierList extends SimpleNode {
7 | public ASTTypeQualifierList(int id) {
8 | super(id);
9 | }
10 |
11 | public ASTTypeQualifierList(CParser p, int id) {
12 | super(p, id);
13 | }
14 |
15 |
16 | /** Accept the visitor. **/
17 | public Object jjtAccept(CParserVisitor visitor, Object data) {
18 |
19 | return
20 | visitor.visit(this, data);
21 | }
22 | }
23 | /* JavaCC - OriginalChecksum=9ed914bbeab9d4fba7337616cdf8c796 (do not edit this line) */
24 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTTypeStringToken.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTTypeStringToken.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTTypeStringToken extends SimpleNode {
7 | public String image;
8 |
9 | public ASTTypeStringToken(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTTypeStringToken(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=b189beab6a69b3fbf2cd6d3dc65da871 (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ASTUnaryExpression.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. ASTUnaryExpression.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class ASTUnaryExpression extends SimpleNode {
7 | public int choice;
8 |
9 | public ASTUnaryExpression(int id) {
10 | super(id);
11 | }
12 |
13 | public ASTUnaryExpression(CParser p, int id) {
14 | super(p, id);
15 | }
16 |
17 |
18 | /** Accept the visitor. **/
19 | public Object jjtAccept(CParserVisitor visitor, Object data) {
20 |
21 | return
22 | visitor.visit(this, data);
23 | }
24 | }
25 | /* JavaCC - OriginalChecksum=d19d61fd0527008bafedc0dbcae70bec (do not edit this line) */
26 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/CParserConstants.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree&JavaCC: Do not edit this line. CParserConstants.java */
4 |
5 | /**
6 | * Token literal values and constants.
7 | * Generated by org.javacc.parser.OtherFilesGen#start()
8 | */
9 | public interface CParserConstants {
10 |
11 | /** End of File. */
12 | int EOF = 0;
13 | /** RegularExpression Id. */
14 | int INTEGER_LITERAL = 12;
15 | /** RegularExpression Id. */
16 | int DECIMAL_LITERAL = 13;
17 | /** RegularExpression Id. */
18 | int HEX_LITERAL = 14;
19 | /** RegularExpression Id. */
20 | int OCTAL_LITERAL = 15;
21 | /** RegularExpression Id. */
22 | int FLOATING_POINT_LITERAL = 16;
23 | /** RegularExpression Id. */
24 | int EXPONENT = 17;
25 | /** RegularExpression Id. */
26 | int CHARACTER_LITERAL = 18;
27 | /** RegularExpression Id. */
28 | int STRING_LITERAL = 19;
29 | /** RegularExpression Id. */
30 | int BOOLEAN = 20;
31 | /** RegularExpression Id. */
32 | int UNDEFINED_TYPE = 21;
33 | /** RegularExpression Id. */
34 | int CONTINUE = 22;
35 | /** RegularExpression Id. */
36 | int VOLATILE = 23;
37 | /** RegularExpression Id. */
38 | int REGISTER = 24;
39 | /** RegularExpression Id. */
40 | int UNSIGNED = 25;
41 | /** RegularExpression Id. */
42 | int TYPEDEF = 26;
43 | /** RegularExpression Id. */
44 | int DFLT = 27;
45 | /** RegularExpression Id. */
46 | int DOUBLE = 28;
47 | /** RegularExpression Id. */
48 | int SIZEOF = 29;
49 | /** RegularExpression Id. */
50 | int SWITCH = 30;
51 | /** RegularExpression Id. */
52 | int RETURN = 31;
53 | /** RegularExpression Id. */
54 | int EXTERN = 32;
55 | /** RegularExpression Id. */
56 | int STRUCT = 33;
57 | /** RegularExpression Id. */
58 | int STATIC = 34;
59 | /** RegularExpression Id. */
60 | int SIGNED = 35;
61 | /** RegularExpression Id. */
62 | int WHILE = 36;
63 | /** RegularExpression Id. */
64 | int BREAK = 37;
65 | /** RegularExpression Id. */
66 | int UNION = 38;
67 | /** RegularExpression Id. */
68 | int CONST = 39;
69 | /** RegularExpression Id. */
70 | int FLOAT = 40;
71 | /** RegularExpression Id. */
72 | int SHORT = 41;
73 | /** RegularExpression Id. */
74 | int ELSE = 42;
75 | /** RegularExpression Id. */
76 | int CASE = 43;
77 | /** RegularExpression Id. */
78 | int LONG = 44;
79 | /** RegularExpression Id. */
80 | int ENUM = 45;
81 | /** RegularExpression Id. */
82 | int AUTO = 46;
83 | /** RegularExpression Id. */
84 | int VOID = 47;
85 | /** RegularExpression Id. */
86 | int CHAR = 48;
87 | /** RegularExpression Id. */
88 | int GOTO = 49;
89 | /** RegularExpression Id. */
90 | int FOR = 50;
91 | /** RegularExpression Id. */
92 | int INT = 51;
93 | /** RegularExpression Id. */
94 | int IF = 52;
95 | /** RegularExpression Id. */
96 | int DO = 53;
97 | /** RegularExpression Id. */
98 | int BOOL_TYPE = 54;
99 | /** RegularExpression Id. */
100 | int CODE = 55;
101 | /** RegularExpression Id. */
102 | int IDENTIFIER = 56;
103 | /** RegularExpression Id. */
104 | int LETTER = 57;
105 | /** RegularExpression Id. */
106 | int DIGIT = 58;
107 | /** RegularExpression Id. */
108 | int SEPARATOR = 59;
109 |
110 | /** Lexical state. */
111 | int DEFAULT = 0;
112 | /** Lexical state. */
113 | int PREPROCESSOR_OUTPUT = 1;
114 |
115 | /** Literal token values. */
116 | String[] tokenImage = {
117 | "",
118 | "\" \"",
119 | "\"\\t\"",
120 | "\"\\n\"",
121 | "\"\\r\"",
122 | "",
123 | "",
124 | "\"#\"",
125 | "\"\\n\"",
126 | "\"\\\\\\n\"",
127 | "\"\\\\\\r\\n\"",
128 | "",
129 | "",
130 | "",
131 | "",
132 | "",
133 | "",
134 | "",
135 | "",
136 | "",
137 | "",
138 | "",
139 | "\"continue\"",
140 | "\"volatile\"",
141 | "\"register\"",
142 | "\"unsigned\"",
143 | "\"typedef\"",
144 | "\"default\"",
145 | "\"double\"",
146 | "\"sizeof\"",
147 | "\"switch\"",
148 | "\"return\"",
149 | "\"extern\"",
150 | "\"struct\"",
151 | "\"static\"",
152 | "\"signed\"",
153 | "\"while\"",
154 | "\"break\"",
155 | "\"union\"",
156 | "\"const\"",
157 | "\"float\"",
158 | "\"short\"",
159 | "\"else\"",
160 | "\"case\"",
161 | "\"long\"",
162 | "\"enum\"",
163 | "\"auto\"",
164 | "\"void\"",
165 | "\"char\"",
166 | "\"goto\"",
167 | "\"for\"",
168 | "\"int\"",
169 | "\"if\"",
170 | "\"do\"",
171 | "\"bool\"",
172 | "\"code\"",
173 | "",
174 | "",
175 | "",
176 | "",
177 | "\";\"",
178 | "\",\"",
179 | "\"=\"",
180 | "\"(\"",
181 | "\")\"",
182 | "\"[\"",
183 | "\"]\"",
184 | "\"*\"",
185 | "\"...\"",
186 | "\"{\"",
187 | "\"}\"",
188 | "\":\"",
189 | "\"*=\"",
190 | "\"/=\"",
191 | "\"%=\"",
192 | "\"+=\"",
193 | "\"-=\"",
194 | "\"<<=\"",
195 | "\">>=\"",
196 | "\"&=\"",
197 | "\"^=\"",
198 | "\"|=\"",
199 | "\"?\"",
200 | "\"||\"",
201 | "\"&&\"",
202 | "\"|\"",
203 | "\"^\"",
204 | "\"&\"",
205 | "\"==\"",
206 | "\"!=\"",
207 | "\"<\"",
208 | "\">\"",
209 | "\"<=\"",
210 | "\">=\"",
211 | "\"<<\"",
212 | "\">>\"",
213 | "\"+\"",
214 | "\"-\"",
215 | "\"/\"",
216 | "\"%\"",
217 | "\"++\"",
218 | "\"--\"",
219 | "\"~\"",
220 | "\"!\"",
221 | "\".\"",
222 | "\"->\"",
223 | };
224 |
225 | }
226 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/CParserDefaultVisitor.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. CParserDefaultVisitor.java Version 7.0.9 */
4 | public class CParserDefaultVisitor implements CParserVisitor{
5 | public Object defaultVisit(SimpleNode node, Object data){
6 | node.childrenAccept(this, data);
7 | return data;
8 | }
9 | public Object visit(SimpleNode node, Object data){
10 | return defaultVisit(node, data);
11 | }
12 | public Object visit(ASTFunctionDefinition node, Object data){
13 | return defaultVisit(node, data);
14 | }
15 | public Object visit(ASTDeclaration node, Object data){
16 | return defaultVisit(node, data);
17 | }
18 | public Object visit(ASTDeclarationList node, Object data){
19 | return defaultVisit(node, data);
20 | }
21 | public Object visit(ASTDeclarationSpecifiers node, Object data){
22 | return defaultVisit(node, data);
23 | }
24 | public Object visit(ASTGhostStringToken node, Object data){
25 | return defaultVisit(node, data);
26 | }
27 | public Object visit(ASTTypeStringToken node, Object data){
28 | return defaultVisit(node, data);
29 | }
30 | public Object visit(ASTStringToken node, Object data){
31 | return defaultVisit(node, data);
32 | }
33 | public Object visit(ASTInitDeclaratorList node, Object data){
34 | return defaultVisit(node, data);
35 | }
36 | public Object visit(ASTInitDeclarator node, Object data){
37 | return defaultVisit(node, data);
38 | }
39 | public Object visit(ASTSpecifierQualifierList node, Object data){
40 | return defaultVisit(node, data);
41 | }
42 | public Object visit(ASTDeclarator node, Object data){
43 | return defaultVisit(node, data);
44 | }
45 | public Object visit(ASTDirectDeclarator node, Object data){
46 | return defaultVisit(node, data);
47 | }
48 | public Object visit(ASTPointer node, Object data){
49 | return defaultVisit(node, data);
50 | }
51 | public Object visit(ASTTypeQualifierList node, Object data){
52 | return defaultVisit(node, data);
53 | }
54 | public Object visit(ASTParameterTypeList node, Object data){
55 | return defaultVisit(node, data);
56 | }
57 | public Object visit(ASTParameterList node, Object data){
58 | return defaultVisit(node, data);
59 | }
60 | public Object visit(ASTParameterDeclaration node, Object data){
61 | return defaultVisit(node, data);
62 | }
63 | public Object visit(ASTIdentifierList node, Object data){
64 | return defaultVisit(node, data);
65 | }
66 | public Object visit(ASTInitializer node, Object data){
67 | return defaultVisit(node, data);
68 | }
69 | public Object visit(ASTInitializerList node, Object data){
70 | return defaultVisit(node, data);
71 | }
72 | public Object visit(ASTTypeName node, Object data){
73 | return defaultVisit(node, data);
74 | }
75 | public Object visit(ASTAbstractDeclarator node, Object data){
76 | return defaultVisit(node, data);
77 | }
78 | public Object visit(ASTDirectAbstractDeclarator node, Object data){
79 | return defaultVisit(node, data);
80 | }
81 | public Object visit(ASTStatement node, Object data){
82 | return defaultVisit(node, data);
83 | }
84 | public Object visit(ASTLabeledStatement node, Object data){
85 | return defaultVisit(node, data);
86 | }
87 | public Object visit(ASTExpressionStatement node, Object data){
88 | return defaultVisit(node, data);
89 | }
90 | public Object visit(ASTCompoundStatement node, Object data){
91 | return defaultVisit(node, data);
92 | }
93 | public Object visit(ASTStatementList node, Object data){
94 | return defaultVisit(node, data);
95 | }
96 | public Object visit(ASTSelectionStatement node, Object data){
97 | return defaultVisit(node, data);
98 | }
99 | public Object visit(ASTIterationStatement node, Object data){
100 | return defaultVisit(node, data);
101 | }
102 | public Object visit(ASTJumpStatement node, Object data){
103 | return defaultVisit(node, data);
104 | }
105 | public Object visit(ASTExpression node, Object data){
106 | return defaultVisit(node, data);
107 | }
108 | public Object visit(ASTAssignmentExpression node, Object data){
109 | return defaultVisit(node, data);
110 | }
111 | public Object visit(ASTConditionalExpression node, Object data){
112 | return defaultVisit(node, data);
113 | }
114 | public Object visit(ASTConstantExpression node, Object data){
115 | return defaultVisit(node, data);
116 | }
117 | public Object visit(ASTLogicalORExpression node, Object data){
118 | return defaultVisit(node, data);
119 | }
120 | public Object visit(ASTLogicalANDExpression node, Object data){
121 | return defaultVisit(node, data);
122 | }
123 | public Object visit(ASTInclusiveORExpression node, Object data){
124 | return defaultVisit(node, data);
125 | }
126 | public Object visit(ASTExclusiveORExpression node, Object data){
127 | return defaultVisit(node, data);
128 | }
129 | public Object visit(ASTANDExpression node, Object data){
130 | return defaultVisit(node, data);
131 | }
132 | public Object visit(ASTEqualityExpression node, Object data){
133 | return defaultVisit(node, data);
134 | }
135 | public Object visit(ASTRelationalExpression node, Object data){
136 | return defaultVisit(node, data);
137 | }
138 | public Object visit(ASTShiftExpression node, Object data){
139 | return defaultVisit(node, data);
140 | }
141 | public Object visit(ASTAdditiveExpression node, Object data){
142 | return defaultVisit(node, data);
143 | }
144 | public Object visit(ASTMultiplicativeExpression node, Object data){
145 | return defaultVisit(node, data);
146 | }
147 | public Object visit(ASTCastExpression node, Object data){
148 | return defaultVisit(node, data);
149 | }
150 | public Object visit(ASTUnaryExpression node, Object data){
151 | return defaultVisit(node, data);
152 | }
153 | public Object visit(ASTPostfixExpression node, Object data){
154 | return defaultVisit(node, data);
155 | }
156 | public Object visit(ASTPrimaryExpression node, Object data){
157 | return defaultVisit(node, data);
158 | }
159 | public Object visit(ASTArgumentExpressionList node, Object data){
160 | return defaultVisit(node, data);
161 | }
162 | }
163 | /* JavaCC - OriginalChecksum=0df21b33819a468166075ef388879333 (do not edit this line) */
164 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/CParserTreeConstants.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. CParserTreeConstants.java Version 7.0.9 */
4 | public interface CParserTreeConstants
5 | {
6 | public int JJTFUNCTIONDEFINITION = 0;
7 | public int JJTDECLARATION = 1;
8 | public int JJTDECLARATIONLIST = 2;
9 | public int JJTDECLARATIONSPECIFIERS = 3;
10 | public int JJTGHOSTSTRINGTOKEN = 4;
11 | public int JJTTYPESTRINGTOKEN = 5;
12 | public int JJTSTRINGTOKEN = 6;
13 | public int JJTINITDECLARATORLIST = 7;
14 | public int JJTINITDECLARATOR = 8;
15 | public int JJTSPECIFIERQUALIFIERLIST = 9;
16 | public int JJTDECLARATOR = 10;
17 | public int JJTDIRECTDECLARATOR = 11;
18 | public int JJTPOINTER = 12;
19 | public int JJTTYPEQUALIFIERLIST = 13;
20 | public int JJTPARAMETERTYPELIST = 14;
21 | public int JJTPARAMETERLIST = 15;
22 | public int JJTPARAMETERDECLARATION = 16;
23 | public int JJTIDENTIFIERLIST = 17;
24 | public int JJTINITIALIZER = 18;
25 | public int JJTINITIALIZERLIST = 19;
26 | public int JJTTYPENAME = 20;
27 | public int JJTABSTRACTDECLARATOR = 21;
28 | public int JJTDIRECTABSTRACTDECLARATOR = 22;
29 | public int JJTSTATEMENT = 23;
30 | public int JJTLABELEDSTATEMENT = 24;
31 | public int JJTEXPRESSIONSTATEMENT = 25;
32 | public int JJTCOMPOUNDSTATEMENT = 26;
33 | public int JJTSTATEMENTLIST = 27;
34 | public int JJTSELECTIONSTATEMENT = 28;
35 | public int JJTITERATIONSTATEMENT = 29;
36 | public int JJTJUMPSTATEMENT = 30;
37 | public int JJTEXPRESSION = 31;
38 | public int JJTASSIGNMENTEXPRESSION = 32;
39 | public int JJTCONDITIONALEXPRESSION = 33;
40 | public int JJTCONSTANTEXPRESSION = 34;
41 | public int JJTLOGICALOREXPRESSION = 35;
42 | public int JJTLOGICALANDEXPRESSION = 36;
43 | public int JJTINCLUSIVEOREXPRESSION = 37;
44 | public int JJTEXCLUSIVEOREXPRESSION = 38;
45 | public int JJTANDEXPRESSION = 39;
46 | public int JJTEQUALITYEXPRESSION = 40;
47 | public int JJTRELATIONALEXPRESSION = 41;
48 | public int JJTSHIFTEXPRESSION = 42;
49 | public int JJTADDITIVEEXPRESSION = 43;
50 | public int JJTMULTIPLICATIVEEXPRESSION = 44;
51 | public int JJTCASTEXPRESSION = 45;
52 | public int JJTUNARYEXPRESSION = 46;
53 | public int JJTPOSTFIXEXPRESSION = 47;
54 | public int JJTPRIMARYEXPRESSION = 48;
55 | public int JJTARGUMENTEXPRESSIONLIST = 49;
56 |
57 |
58 | public String[] jjtNodeName = {
59 | "FunctionDefinition",
60 | "Declaration",
61 | "DeclarationList",
62 | "DeclarationSpecifiers",
63 | "GhostStringToken",
64 | "TypeStringToken",
65 | "StringToken",
66 | "InitDeclaratorList",
67 | "InitDeclarator",
68 | "SpecifierQualifierList",
69 | "Declarator",
70 | "DirectDeclarator",
71 | "Pointer",
72 | "TypeQualifierList",
73 | "ParameterTypeList",
74 | "ParameterList",
75 | "ParameterDeclaration",
76 | "IdentifierList",
77 | "Initializer",
78 | "InitializerList",
79 | "TypeName",
80 | "AbstractDeclarator",
81 | "DirectAbstractDeclarator",
82 | "Statement",
83 | "LabeledStatement",
84 | "ExpressionStatement",
85 | "CompoundStatement",
86 | "StatementList",
87 | "SelectionStatement",
88 | "IterationStatement",
89 | "JumpStatement",
90 | "Expression",
91 | "AssignmentExpression",
92 | "ConditionalExpression",
93 | "ConstantExpression",
94 | "LogicalORExpression",
95 | "LogicalANDExpression",
96 | "InclusiveORExpression",
97 | "ExclusiveORExpression",
98 | "ANDExpression",
99 | "EqualityExpression",
100 | "RelationalExpression",
101 | "ShiftExpression",
102 | "AdditiveExpression",
103 | "MultiplicativeExpression",
104 | "CastExpression",
105 | "UnaryExpression",
106 | "PostfixExpression",
107 | "PrimaryExpression",
108 | "ArgumentExpressionList",
109 | };
110 | }
111 | /* JavaCC - OriginalChecksum=e23e00fb56ffad799524355d8342c899 (do not edit this line) */
112 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/CParserVisitor.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. CParserVisitor.java Version 7.0.9 */
4 | public interface CParserVisitor
5 | {
6 | public Object visit(SimpleNode node, Object data);
7 | public Object visit(ASTFunctionDefinition node, Object data);
8 | public Object visit(ASTDeclaration node, Object data);
9 | public Object visit(ASTDeclarationList node, Object data);
10 | public Object visit(ASTDeclarationSpecifiers node, Object data);
11 | public Object visit(ASTGhostStringToken node, Object data);
12 | public Object visit(ASTTypeStringToken node, Object data);
13 | public Object visit(ASTStringToken node, Object data);
14 | public Object visit(ASTInitDeclaratorList node, Object data);
15 | public Object visit(ASTInitDeclarator node, Object data);
16 | public Object visit(ASTSpecifierQualifierList node, Object data);
17 | public Object visit(ASTDeclarator node, Object data);
18 | public Object visit(ASTDirectDeclarator node, Object data);
19 | public Object visit(ASTPointer node, Object data);
20 | public Object visit(ASTTypeQualifierList node, Object data);
21 | public Object visit(ASTParameterTypeList node, Object data);
22 | public Object visit(ASTParameterList node, Object data);
23 | public Object visit(ASTParameterDeclaration node, Object data);
24 | public Object visit(ASTIdentifierList node, Object data);
25 | public Object visit(ASTInitializer node, Object data);
26 | public Object visit(ASTInitializerList node, Object data);
27 | public Object visit(ASTTypeName node, Object data);
28 | public Object visit(ASTAbstractDeclarator node, Object data);
29 | public Object visit(ASTDirectAbstractDeclarator node, Object data);
30 | public Object visit(ASTStatement node, Object data);
31 | public Object visit(ASTLabeledStatement node, Object data);
32 | public Object visit(ASTExpressionStatement node, Object data);
33 | public Object visit(ASTCompoundStatement node, Object data);
34 | public Object visit(ASTStatementList node, Object data);
35 | public Object visit(ASTSelectionStatement node, Object data);
36 | public Object visit(ASTIterationStatement node, Object data);
37 | public Object visit(ASTJumpStatement node, Object data);
38 | public Object visit(ASTExpression node, Object data);
39 | public Object visit(ASTAssignmentExpression node, Object data);
40 | public Object visit(ASTConditionalExpression node, Object data);
41 | public Object visit(ASTConstantExpression node, Object data);
42 | public Object visit(ASTLogicalORExpression node, Object data);
43 | public Object visit(ASTLogicalANDExpression node, Object data);
44 | public Object visit(ASTInclusiveORExpression node, Object data);
45 | public Object visit(ASTExclusiveORExpression node, Object data);
46 | public Object visit(ASTANDExpression node, Object data);
47 | public Object visit(ASTEqualityExpression node, Object data);
48 | public Object visit(ASTRelationalExpression node, Object data);
49 | public Object visit(ASTShiftExpression node, Object data);
50 | public Object visit(ASTAdditiveExpression node, Object data);
51 | public Object visit(ASTMultiplicativeExpression node, Object data);
52 | public Object visit(ASTCastExpression node, Object data);
53 | public Object visit(ASTUnaryExpression node, Object data);
54 | public Object visit(ASTPostfixExpression node, Object data);
55 | public Object visit(ASTPrimaryExpression node, Object data);
56 | public Object visit(ASTArgumentExpressionList node, Object data);
57 | }
58 | /* JavaCC - OriginalChecksum=c11b3a8c5731c3cdcccff61a264d1174 (do not edit this line) */
59 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/JJTCParserState.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. JJTCParserState.java Version 7.0.9 */
4 | public class JJTCParserState {
5 | private java.util.List nodes;
6 | private java.util.List marks;
7 |
8 | private int sp; // number of nodes on stack
9 | private int mk; // current mark
10 | private boolean node_created;
11 |
12 | public JJTCParserState() {
13 | nodes = new java.util.ArrayList();
14 | marks = new java.util.ArrayList();
15 | sp = 0;
16 | mk = 0;
17 | }
18 |
19 | /* Determines whether the current node was actually closed and
20 | pushed. This should only be called in the final user action of a
21 | node scope. */
22 | public boolean nodeCreated() {
23 | return node_created;
24 | }
25 |
26 | /* Call this to reinitialize the node stack. It is called
27 | automatically by the parser's ReInit() method. */
28 | public void reset() {
29 | nodes.clear();
30 | marks.clear();
31 | sp = 0;
32 | mk = 0;
33 | }
34 |
35 | /* Returns the root node of the AST. It only makes sense to call
36 | this after a successful parse. */
37 | public Node rootNode() {
38 | return nodes.get(0);
39 | }
40 |
41 | /* Pushes a node on to the stack. */
42 | public void pushNode(Node n) {
43 | nodes.add(n);
44 | ++sp;
45 | }
46 |
47 | /* Returns the node on the top of the stack, and remove it from the
48 | stack. */
49 | public Node popNode() {
50 | if (--sp < mk) {
51 | mk = marks.remove(marks.size()-1);
52 | }
53 | return nodes.remove(nodes.size()-1);
54 | }
55 |
56 | /* Returns the node currently on the top of the stack. */
57 | public Node peekNode() {
58 | return nodes.get(nodes.size()-1);
59 | }
60 |
61 | /* Returns the number of children on the stack in the current node
62 | scope. */
63 | public int nodeArity() {
64 | return sp - mk;
65 | }
66 |
67 |
68 | public void clearNodeScope(Node n) {
69 | while (sp > mk) {
70 | popNode();
71 | }
72 | mk = marks.remove(marks.size()-1);
73 | }
74 |
75 |
76 | public void openNodeScope(Node n) {
77 | marks.add(mk);
78 | mk = sp;
79 | n.jjtOpen();
80 | }
81 |
82 |
83 | /* A definite node is constructed from a specified number of
84 | children. That number of nodes are popped from the stack and
85 | made the children of the definite node. Then the definite node
86 | is pushed on to the stack. */
87 | public void closeNodeScope(Node n, int num) {
88 | mk = marks.remove(marks.size()-1);
89 | while (num-- > 0) {
90 | Node c = popNode();
91 | c.jjtSetParent(n);
92 | n.jjtAddChild(c, num);
93 | }
94 | n.jjtClose();
95 | pushNode(n);
96 | node_created = true;
97 | }
98 |
99 |
100 | /* A conditional node is constructed if its condition is true. All
101 | the nodes that have been pushed since the node was opened are
102 | made children of the conditional node, which is then pushed
103 | on to the stack. If the condition is false the node is not
104 | constructed and they are left on the stack. */
105 | public void closeNodeScope(Node n, boolean condition) {
106 | if (condition) {
107 | int a = nodeArity();
108 | mk = marks.remove(marks.size()-1);
109 | while (a-- > 0) {
110 | Node c = popNode();
111 | c.jjtSetParent(n);
112 | n.jjtAddChild(c, a);
113 | }
114 | n.jjtClose();
115 | pushNode(n);
116 | node_created = true;
117 | } else {
118 | mk = marks.remove(marks.size()-1);
119 | node_created = false;
120 | }
121 | }
122 | }
123 | /* JavaCC - OriginalChecksum=ab6c16d936495b21e639077683ccf423 (do not edit this line) */
124 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/Node.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. Node.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | /* All AST nodes must implement this interface. It provides basic
6 | machinery for constructing the parent and child relationships
7 | between nodes. */
8 |
9 | public
10 | interface Node {
11 |
12 | /** This method is called after the node has been made the current
13 | node. It indicates that child nodes can now be added to it. */
14 | public void jjtOpen();
15 |
16 | /** This method is called after all the child nodes have been
17 | added. */
18 | public void jjtClose();
19 |
20 | /** This pair of methods are used to inform the node of its
21 | parent. */
22 | public void jjtSetParent(Node n);
23 | public Node jjtGetParent();
24 |
25 | /** This method tells the node to add its argument to the node's
26 | list of children. */
27 | public void jjtAddChild(Node n, int i);
28 |
29 | /** This method returns a child node. The children are numbered
30 | from zero, left to right. */
31 | public Node jjtGetChild(int i);
32 |
33 | /** Return the number of children the node has. */
34 | public int jjtGetNumChildren();
35 |
36 | public int getId();
37 |
38 | /** Accept the visitor. **/
39 | public Object jjtAccept(CParserVisitor visitor, Object data);
40 | }
41 | /* JavaCC - OriginalChecksum=93c32f64ec01c5821c3fb11c9d59d33b (do not edit this line) */
42 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/ParseException.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 7.0 */
4 | /* JavaCCOptions:KEEP_LINE_COLUMN=true */
5 | /**
6 | * This exception is thrown when parse errors are encountered.
7 | * You can explicitly create objects of this exception type by
8 | * calling the method generateParseException in the generated
9 | * parser.
10 | *
11 | * You can modify this class to customize your error reporting
12 | * mechanisms so long as you retain the public fields.
13 | */
14 | public class ParseException extends Exception {
15 |
16 | /**
17 | * The version identifier for this Serializable class.
18 | * Increment only if the serialized form of the
19 | * class changes.
20 | */
21 | private static final long serialVersionUID = 1L;
22 |
23 | /**
24 | * The end of line string for this machine.
25 | */
26 | protected static String EOL = System.getProperty("line.separator", "\n");
27 |
28 | /**
29 | * This constructor is used by the method "generateParseException"
30 | * in the generated parser. Calling this constructor generates
31 | * a new object of this type with the fields "currentToken",
32 | * "expectedTokenSequences", and "tokenImage" set.
33 | */
34 | public ParseException(Token currentTokenVal,
35 | int[][] expectedTokenSequencesVal,
36 | String[] tokenImageVal
37 | )
38 | {
39 | super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
40 | currentToken = currentTokenVal;
41 | expectedTokenSequences = expectedTokenSequencesVal;
42 | tokenImage = tokenImageVal;
43 | }
44 |
45 | /**
46 | * The following constructors are for use by you for whatever
47 | * purpose you can think of. Constructing the exception in this
48 | * manner makes the exception behave in the normal way - i.e., as
49 | * documented in the class "Throwable". The fields "errorToken",
50 | * "expectedTokenSequences", and "tokenImage" do not contain
51 | * relevant information. The JavaCC generated code does not use
52 | * these constructors.
53 | */
54 |
55 | public ParseException() {
56 | super();
57 | }
58 |
59 | /** Constructor with message. */
60 | public ParseException(String message) {
61 | super(message);
62 | }
63 |
64 |
65 | /**
66 | * This is the last token that has been consumed successfully. If
67 | * this object has been created due to a parse error, the token
68 | * following this token will (therefore) be the first error token.
69 | */
70 | public Token currentToken;
71 |
72 | /**
73 | * Each entry in this array is an array of integers. Each array
74 | * of integers represents a sequence of tokens (by their ordinal
75 | * values) that is expected at this point of the parse.
76 | */
77 | public int[][] expectedTokenSequences;
78 |
79 | /**
80 | * This is a reference to the "tokenImage" array of the generated
81 | * parser within which the parse error occurred. This array is
82 | * defined in the generated ...Constants interface.
83 | */
84 | public String[] tokenImage;
85 |
86 | /**
87 | * It uses "currentToken" and "expectedTokenSequences" to generate a parse
88 | * error message and returns it. If this object has been created
89 | * due to a parse error, and you do not catch it (it gets thrown
90 | * from the parser) the correct error message
91 | * gets displayed.
92 | */
93 | private static String initialise(Token currentToken,
94 | int[][] expectedTokenSequences,
95 | String[] tokenImage) {
96 |
97 | StringBuilder expected = new StringBuilder();
98 | int maxSize = 0;
99 | for (int i = 0; i < expectedTokenSequences.length; i++) {
100 | if (maxSize < expectedTokenSequences[i].length) {
101 | maxSize = expectedTokenSequences[i].length;
102 | }
103 | for (int j = 0; j < expectedTokenSequences[i].length; j++) {
104 | expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
105 | }
106 | if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
107 | expected.append("...");
108 | }
109 | expected.append(EOL).append(" ");
110 | }
111 | String retval = "Encountered \"";
112 | Token tok = currentToken.next;
113 | for (int i = 0; i < maxSize; i++) {
114 | if (i != 0) retval += " ";
115 | if (tok.kind == 0) {
116 | retval += tokenImage[0];
117 | break;
118 | }
119 | retval += " " + tokenImage[tok.kind];
120 | retval += " \"";
121 | retval += add_escapes(tok.image);
122 | retval += " \"";
123 | tok = tok.next;
124 | }
125 | retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
126 | retval += "." + EOL;
127 |
128 |
129 | if (expectedTokenSequences.length == 0) {
130 | // Nothing to add here
131 | } else {
132 | if (expectedTokenSequences.length == 1) {
133 | retval += "Was expecting:" + EOL + " ";
134 | } else {
135 | retval += "Was expecting one of:" + EOL + " ";
136 | }
137 | retval += expected.toString();
138 | }
139 |
140 | return retval;
141 | }
142 |
143 |
144 | /**
145 | * Used to convert raw characters to their escaped version
146 | * when these raw version cannot be used as part of an ASCII
147 | * string literal.
148 | */
149 | static String add_escapes(String str) {
150 | StringBuilder retval = new StringBuilder();
151 | char ch;
152 | for (int i = 0; i < str.length(); i++) {
153 | switch (str.charAt(i))
154 | {
155 | case '\b':
156 | retval.append("\\b");
157 | continue;
158 | case '\t':
159 | retval.append("\\t");
160 | continue;
161 | case '\n':
162 | retval.append("\\n");
163 | continue;
164 | case '\f':
165 | retval.append("\\f");
166 | continue;
167 | case '\r':
168 | retval.append("\\r");
169 | continue;
170 | case '\"':
171 | retval.append("\\\"");
172 | continue;
173 | case '\'':
174 | retval.append("\\\'");
175 | continue;
176 | case '\\':
177 | retval.append("\\\\");
178 | continue;
179 | default:
180 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
181 | String s = "0000" + Integer.toString(ch, 16);
182 | retval.append("\\u" + s.substring(s.length() - 4, s.length()));
183 | } else {
184 | retval.append(ch);
185 | }
186 | continue;
187 | }
188 | }
189 | return retval.toString();
190 | }
191 |
192 | }
193 | /* JavaCC - OriginalChecksum=0fbdc1f3a882b6ef66ce3f2a7a0e4228 (do not edit this line) */
194 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/SimpleCharStream.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 7.0 */
4 | /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | /**
6 | * An implementation of interface CharStream, where the stream is assumed to
7 | * contain only ASCII characters (without unicode processing).
8 | */
9 |
10 | public class SimpleCharStream
11 | {
12 | /** Whether parser is static. */
13 | public static final boolean staticFlag = false;
14 | int bufsize;
15 | int available;
16 | int tokenBegin;
17 | /** Position in buffer. */
18 | public int bufpos = -1;
19 | protected int bufline[];
20 | protected int bufcolumn[];
21 |
22 | protected int column = 0;
23 | protected int line = 1;
24 |
25 | protected boolean prevCharIsCR = false;
26 | protected boolean prevCharIsLF = false;
27 |
28 | protected java.io.Reader inputStream;
29 |
30 | protected char[] buffer;
31 | protected int maxNextCharInd = 0;
32 | protected int inBuf = 0;
33 | protected int tabSize = 1;
34 | protected boolean trackLineColumn = true;
35 |
36 | public void setTabSize(int i) { tabSize = i; }
37 | public int getTabSize() { return tabSize; }
38 |
39 |
40 |
41 | protected void ExpandBuff(boolean wrapAround)
42 | {
43 | char[] newbuffer = new char[bufsize + 2048];
44 | int newbufline[] = new int[bufsize + 2048];
45 | int newbufcolumn[] = new int[bufsize + 2048];
46 |
47 | try
48 | {
49 | if (wrapAround)
50 | {
51 | System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
52 | System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
53 | buffer = newbuffer;
54 |
55 | System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
56 | System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
57 | bufline = newbufline;
58 |
59 | System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
60 | System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
61 | bufcolumn = newbufcolumn;
62 |
63 | maxNextCharInd = (bufpos += (bufsize - tokenBegin));
64 | }
65 | else
66 | {
67 | System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
68 | buffer = newbuffer;
69 |
70 | System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
71 | bufline = newbufline;
72 |
73 | System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
74 | bufcolumn = newbufcolumn;
75 |
76 | maxNextCharInd = (bufpos -= tokenBegin);
77 | }
78 | }
79 | catch (Throwable t)
80 | {
81 | throw new Error(t.getMessage());
82 | }
83 |
84 |
85 | bufsize += 2048;
86 | available = bufsize;
87 | tokenBegin = 0;
88 | }
89 |
90 | protected void FillBuff() throws java.io.IOException
91 | {
92 | if (maxNextCharInd == available)
93 | {
94 | if (available == bufsize)
95 | {
96 | if (tokenBegin > 2048)
97 | {
98 | bufpos = maxNextCharInd = 0;
99 | available = tokenBegin;
100 | }
101 | else if (tokenBegin < 0)
102 | bufpos = maxNextCharInd = 0;
103 | else
104 | ExpandBuff(false);
105 | }
106 | else if (available > tokenBegin)
107 | available = bufsize;
108 | else if ((tokenBegin - available) < 2048)
109 | ExpandBuff(true);
110 | else
111 | available = tokenBegin;
112 | }
113 |
114 | int i;
115 | try {
116 | if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)
117 | {
118 | inputStream.close();
119 | throw new java.io.IOException();
120 | }
121 | else
122 | maxNextCharInd += i;
123 | return;
124 | }
125 | catch(java.io.IOException e) {
126 | --bufpos;
127 | backup(0);
128 | if (tokenBegin == -1)
129 | tokenBegin = bufpos;
130 | throw e;
131 | }
132 | }
133 |
134 | /** Start. */
135 | public char BeginToken() throws java.io.IOException
136 | {
137 | tokenBegin = -1;
138 | char c = readChar();
139 | tokenBegin = bufpos;
140 |
141 | return c;
142 | }
143 |
144 | protected void UpdateLineColumn(char c)
145 | {
146 | column++;
147 |
148 | if (prevCharIsLF)
149 | {
150 | prevCharIsLF = false;
151 | line += (column = 1);
152 | }
153 | else if (prevCharIsCR)
154 | {
155 | prevCharIsCR = false;
156 | if (c == '\n')
157 | {
158 | prevCharIsLF = true;
159 | }
160 | else
161 | line += (column = 1);
162 | }
163 |
164 | switch (c)
165 | {
166 | case '\r' :
167 | prevCharIsCR = true;
168 | break;
169 | case '\n' :
170 | prevCharIsLF = true;
171 | break;
172 | case '\t' :
173 | column--;
174 | column += (tabSize - (column % tabSize));
175 | break;
176 | default :
177 | break;
178 | }
179 |
180 | bufline[bufpos] = line;
181 | bufcolumn[bufpos] = column;
182 | }
183 |
184 | /** Read a character. */
185 | public char readChar() throws java.io.IOException
186 | {
187 | if (inBuf > 0)
188 | {
189 | --inBuf;
190 |
191 | if (++bufpos == bufsize)
192 | bufpos = 0;
193 |
194 | return buffer[bufpos];
195 | }
196 |
197 | if (++bufpos >= maxNextCharInd)
198 | FillBuff();
199 |
200 | char c = buffer[bufpos];
201 |
202 | UpdateLineColumn(c);
203 | return c;
204 | }
205 |
206 | @Deprecated
207 | /**
208 | * @deprecated
209 | * @see #getEndColumn
210 | */
211 |
212 | public int getColumn() {
213 | return bufcolumn[bufpos];
214 | }
215 |
216 | @Deprecated
217 | /**
218 | * @deprecated
219 | * @see #getEndLine
220 | */
221 |
222 | public int getLine() {
223 | return bufline[bufpos];
224 | }
225 |
226 | /** Get token end column number. */
227 | public int getEndColumn() {
228 | return bufcolumn[bufpos];
229 | }
230 |
231 | /** Get token end line number. */
232 | public int getEndLine() {
233 | return bufline[bufpos];
234 | }
235 |
236 | /** Get token beginning column number. */
237 | public int getBeginColumn() {
238 | return bufcolumn[tokenBegin];
239 | }
240 |
241 | /** Get token beginning line number. */
242 | public int getBeginLine() {
243 | return bufline[tokenBegin];
244 | }
245 |
246 | /** Backup a number of characters. */
247 | public void backup(int amount) {
248 |
249 | inBuf += amount;
250 | if ((bufpos -= amount) < 0)
251 | bufpos += bufsize;
252 | }
253 |
254 | /** Constructor. */
255 | public SimpleCharStream(java.io.Reader dstream, int startline,
256 | int startcolumn, int buffersize)
257 | {
258 | inputStream = dstream;
259 | line = startline;
260 | column = startcolumn - 1;
261 |
262 | available = bufsize = buffersize;
263 | buffer = new char[buffersize];
264 | bufline = new int[buffersize];
265 | bufcolumn = new int[buffersize];
266 | }
267 |
268 | /** Constructor. */
269 | public SimpleCharStream(java.io.Reader dstream, int startline,
270 | int startcolumn)
271 | {
272 | this(dstream, startline, startcolumn, 4096);
273 | }
274 |
275 | /** Constructor. */
276 | public SimpleCharStream(java.io.Reader dstream)
277 | {
278 | this(dstream, 1, 1, 4096);
279 | }
280 |
281 | /** Reinitialise. */
282 | public void ReInit(java.io.Reader dstream, int startline,
283 | int startcolumn, int buffersize)
284 | {
285 | inputStream = dstream;
286 | line = startline;
287 | column = startcolumn - 1;
288 |
289 | if (buffer == null || buffersize != buffer.length)
290 | {
291 | available = bufsize = buffersize;
292 | buffer = new char[buffersize];
293 | bufline = new int[buffersize];
294 | bufcolumn = new int[buffersize];
295 | }
296 | prevCharIsLF = prevCharIsCR = false;
297 | tokenBegin = inBuf = maxNextCharInd = 0;
298 | bufpos = -1;
299 | }
300 |
301 | /** Reinitialise. */
302 | public void ReInit(java.io.Reader dstream, int startline,
303 | int startcolumn)
304 | {
305 | ReInit(dstream, startline, startcolumn, 4096);
306 | }
307 |
308 | /** Reinitialise. */
309 | public void ReInit(java.io.Reader dstream)
310 | {
311 | ReInit(dstream, 1, 1, 4096);
312 | }
313 | /** Constructor. */
314 | public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
315 | int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
316 | {
317 | this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
318 | }
319 |
320 | /** Constructor. */
321 | public SimpleCharStream(java.io.InputStream dstream, int startline,
322 | int startcolumn, int buffersize)
323 | {
324 | this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
325 | }
326 |
327 | /** Constructor. */
328 | public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
329 | int startcolumn) throws java.io.UnsupportedEncodingException
330 | {
331 | this(dstream, encoding, startline, startcolumn, 4096);
332 | }
333 |
334 | /** Constructor. */
335 | public SimpleCharStream(java.io.InputStream dstream, int startline,
336 | int startcolumn)
337 | {
338 | this(dstream, startline, startcolumn, 4096);
339 | }
340 |
341 | /** Constructor. */
342 | public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
343 | {
344 | this(dstream, encoding, 1, 1, 4096);
345 | }
346 |
347 | /** Constructor. */
348 | public SimpleCharStream(java.io.InputStream dstream)
349 | {
350 | this(dstream, 1, 1, 4096);
351 | }
352 |
353 | /** Reinitialise. */
354 | public void ReInit(java.io.InputStream dstream, String encoding, int startline,
355 | int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
356 | {
357 | ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
358 | }
359 |
360 | /** Reinitialise. */
361 | public void ReInit(java.io.InputStream dstream, int startline,
362 | int startcolumn, int buffersize)
363 | {
364 | ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
365 | }
366 |
367 | /** Reinitialise. */
368 | public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
369 | {
370 | ReInit(dstream, encoding, 1, 1, 4096);
371 | }
372 |
373 | /** Reinitialise. */
374 | public void ReInit(java.io.InputStream dstream)
375 | {
376 | ReInit(dstream, 1, 1, 4096);
377 | }
378 | /** Reinitialise. */
379 | public void ReInit(java.io.InputStream dstream, String encoding, int startline,
380 | int startcolumn) throws java.io.UnsupportedEncodingException
381 | {
382 | ReInit(dstream, encoding, startline, startcolumn, 4096);
383 | }
384 | /** Reinitialise. */
385 | public void ReInit(java.io.InputStream dstream, int startline,
386 | int startcolumn)
387 | {
388 | ReInit(dstream, startline, startcolumn, 4096);
389 | }
390 | /** Get token literal value. */
391 | public String GetImage()
392 | {
393 | if (bufpos >= tokenBegin)
394 | return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
395 | else
396 | return new String(buffer, tokenBegin, bufsize - tokenBegin) +
397 | new String(buffer, 0, bufpos + 1);
398 | }
399 |
400 | /** Get the suffix. */
401 | public char[] GetSuffix(int len)
402 | {
403 | char[] ret = new char[len];
404 |
405 | if ((bufpos + 1) >= len)
406 | System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
407 | else
408 | {
409 | System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
410 | len - bufpos - 1);
411 | System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
412 | }
413 |
414 | return ret;
415 | }
416 |
417 | /** Reset buffer when finished. */
418 | public void Done()
419 | {
420 | buffer = null;
421 | bufline = null;
422 | bufcolumn = null;
423 | }
424 |
425 | /**
426 | * Method to adjust line and column numbers for the start of a token.
427 | */
428 | public void adjustBeginLineColumn(int newLine, int newCol)
429 | {
430 | int start = tokenBegin;
431 | int len;
432 |
433 | if (bufpos >= tokenBegin)
434 | {
435 | len = bufpos - tokenBegin + inBuf + 1;
436 | }
437 | else
438 | {
439 | len = bufsize - tokenBegin + bufpos + 1 + inBuf;
440 | }
441 |
442 | int i = 0, j = 0, k = 0;
443 | int nextColDiff = 0, columnDiff = 0;
444 |
445 | while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
446 | {
447 | bufline[j] = newLine;
448 | nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
449 | bufcolumn[j] = newCol + columnDiff;
450 | columnDiff = nextColDiff;
451 | i++;
452 | }
453 |
454 | if (i < len)
455 | {
456 | bufline[j] = newLine++;
457 | bufcolumn[j] = newCol + columnDiff;
458 |
459 | while (i++ < len)
460 | {
461 | if (bufline[j = start % bufsize] != bufline[++start % bufsize])
462 | bufline[j] = newLine++;
463 | else
464 | bufline[j] = newLine;
465 | }
466 | }
467 |
468 | line = bufline[j];
469 | column = bufcolumn[j];
470 | }
471 | boolean getTrackLineColumn() { return trackLineColumn; }
472 | void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; }
473 | }
474 | /* JavaCC - OriginalChecksum=320e3957affec8972ad656fb86b8d782 (do not edit this line) */
475 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/SimpleNode.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 7.0 */
4 | /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | public
6 | class SimpleNode implements Node {
7 |
8 | protected Node parent;
9 | protected Node[] children;
10 | protected int id;
11 | protected Object value;
12 | protected CParser parser;
13 |
14 | public SimpleNode(int i) {
15 | id = i;
16 | }
17 |
18 | public SimpleNode(CParser p, int i) {
19 | this(i);
20 | parser = p;
21 | }
22 |
23 | public void jjtOpen() {
24 | }
25 |
26 | public void jjtClose() {
27 | }
28 |
29 | public void jjtSetParent(Node n) { parent = n; }
30 | public Node jjtGetParent() { return parent; }
31 |
32 | public void jjtAddChild(Node n, int i) {
33 | if (children == null) {
34 | children = new Node[i + 1];
35 | } else if (i >= children.length) {
36 | Node c[] = new Node[i + 1];
37 | System.arraycopy(children, 0, c, 0, children.length);
38 | children = c;
39 | }
40 | children[i] = n;
41 | }
42 |
43 | public Node jjtGetChild(int i) {
44 | return children[i];
45 | }
46 |
47 | public int jjtGetNumChildren() {
48 | return (children == null) ? 0 : children.length;
49 | }
50 |
51 | public void jjtSetValue(Object value) { this.value = value; }
52 | public Object jjtGetValue() { return value; }
53 |
54 | /** Accept the visitor. **/
55 | public Object jjtAccept(CParserVisitor visitor, Object data)
56 | {
57 | return visitor.visit(this, data);
58 | }
59 |
60 | /** Accept the visitor. **/
61 | public Object childrenAccept(CParserVisitor visitor, Object data)
62 | {
63 | if (children != null) {
64 | for (int i = 0; i < children.length; ++i) {
65 | children[i].jjtAccept(visitor, data);
66 | }
67 | }
68 | return data;
69 | }
70 |
71 | /* You can override these two methods in subclasses of SimpleNode to
72 | customize the way the node appears when the tree is dumped. If
73 | your output uses more than one line you should override
74 | toString(String), otherwise overriding toString() is probably all
75 | you need to do. */
76 |
77 | public String toString() {
78 | return CParserTreeConstants.jjtNodeName[id];
79 | }
80 | public String toString(String prefix) { return prefix + toString(); }
81 |
82 | /* Override this method if you want to customize how the node dumps
83 | out its children. */
84 |
85 | public void dump(String prefix) {
86 | System.out.println(toString(prefix));
87 | if (children != null) {
88 | for (int i = 0; i < children.length; ++i) {
89 | SimpleNode n = (SimpleNode)children[i];
90 | if (n != null) {
91 | n.dump(prefix + " ");
92 | }
93 | }
94 | }
95 | }
96 |
97 | public int getId() {
98 | return id;
99 | }
100 | }
101 |
102 | /* JavaCC - OriginalChecksum=97592567112e82e2388d067919812e6e (do not edit this line) */
103 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/Token.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. Token.java Version 7.0 */
4 | /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
5 | /**
6 | * Describes the input token stream.
7 | */
8 |
9 | public class Token implements java.io.Serializable {
10 |
11 | /**
12 | * The version identifier for this Serializable class.
13 | * Increment only if the serialized form of the
14 | * class changes.
15 | */
16 | private static final long serialVersionUID = 1L;
17 |
18 | /**
19 | * An integer that describes the kind of this token. This numbering
20 | * system is determined by JavaCCParser, and a table of these numbers is
21 | * stored in the file ...Constants.java.
22 | */
23 | public int kind;
24 |
25 | /** The line number of the first character of this Token. */
26 | public int beginLine;
27 | /** The column number of the first character of this Token. */
28 | public int beginColumn;
29 | /** The line number of the last character of this Token. */
30 | public int endLine;
31 | /** The column number of the last character of this Token. */
32 | public int endColumn;
33 |
34 | /**
35 | * The string image of the token.
36 | */
37 | public String image;
38 |
39 | /**
40 | * A reference to the next regular (non-special) token from the input
41 | * stream. If this is the last token from the input stream, or if the
42 | * token manager has not read tokens beyond this one, this field is
43 | * set to null. This is true only if this token is also a regular
44 | * token. Otherwise, see below for a description of the contents of
45 | * this field.
46 | */
47 | public Token next;
48 |
49 | /**
50 | * This field is used to access special tokens that occur prior to this
51 | * token, but after the immediately preceding regular (non-special) token.
52 | * If there are no such special tokens, this field is set to null.
53 | * When there are more than one such special token, this field refers
54 | * to the last of these special tokens, which in turn refers to the next
55 | * previous special token through its specialToken field, and so on
56 | * until the first special token (whose specialToken field is null).
57 | * The next fields of special tokens refer to other special tokens that
58 | * immediately follow it (without an intervening regular token). If there
59 | * is no such token, this field is null.
60 | */
61 | public Token specialToken;
62 |
63 | /**
64 | * An optional attribute value of the Token.
65 | * Tokens which are not used as syntactic sugar will often contain
66 | * meaningful values that will be used later on by the compiler or
67 | * interpreter. This attribute value is often different from the image.
68 | * Any subclass of Token that actually wants to return a non-null value can
69 | * override this method as appropriate.
70 | */
71 | public Object getValue() {
72 | return null;
73 | }
74 |
75 | /**
76 | * No-argument constructor
77 | */
78 | public Token() {}
79 |
80 | /**
81 | * Constructs a new token for the specified Image.
82 | */
83 | public Token(int kind)
84 | {
85 | this(kind, null);
86 | }
87 |
88 | /**
89 | * Constructs a new token for the specified Image and Kind.
90 | */
91 | public Token(int kind, String image)
92 | {
93 | this.kind = kind;
94 | this.image = image;
95 | }
96 |
97 | /**
98 | * Returns the image.
99 | */
100 | @Override
101 | public String toString()
102 | {
103 | return image;
104 | }
105 |
106 | /**
107 | * Returns a new Token object, by default. However, if you want, you
108 | * can create and return subclass objects based on the value of ofKind.
109 | * Simply add the cases to the switch for all those special cases.
110 | * For example, if you have a subclass of Token called IDToken that
111 | * you want to create if ofKind is ID, simply add something like :
112 | *
113 | * case MyParserConstants.ID : return new IDToken(ofKind, image);
114 | *
115 | * to the following switch statement. Then you can cast matchedToken
116 | * variable to the appropriate type and use sit in your lexical actions.
117 | */
118 | public static Token newToken(int ofKind, String image)
119 | {
120 | switch(ofKind)
121 | {
122 | default : return new Token(ofKind, image);
123 | }
124 | }
125 |
126 | public static Token newToken(int ofKind)
127 | {
128 | return newToken(ofKind, null);
129 | }
130 |
131 | }
132 | /* JavaCC - OriginalChecksum=093f73b266edc0ed6a424fcd3b5446d1 (do not edit this line) */
133 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/TokenMgrError.java:
--------------------------------------------------------------------------------
1 | package ghidrust.decompiler.parser.c.gen;
2 |
3 | /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 7.0 */
4 | /* JavaCCOptions: */
5 | /** Token Manager Error. */
6 | public class TokenMgrError extends Error
7 | {
8 |
9 | /**
10 | * The version identifier for this Serializable class.
11 | * Increment only if the serialized form of the
12 | * class changes.
13 | */
14 | private static final long serialVersionUID = 1L;
15 |
16 | /*
17 | * Ordinals for various reasons why an Error of this type can be thrown.
18 | */
19 |
20 | /**
21 | * Lexical error occurred.
22 | */
23 | public static final int LEXICAL_ERROR = 0;
24 |
25 | /**
26 | * An attempt was made to create a second instance of a static token manager.
27 | */
28 | public static final int STATIC_LEXER_ERROR = 1;
29 |
30 | /**
31 | * Tried to change to an invalid lexical state.
32 | */
33 | public static final int INVALID_LEXICAL_STATE = 2;
34 |
35 | /**
36 | * Detected (and bailed out of) an infinite loop in the token manager.
37 | */
38 | public static final int LOOP_DETECTED = 3;
39 |
40 | /**
41 | * Indicates the reason why the exception is thrown. It will have
42 | * one of the above 4 values.
43 | */
44 | int errorCode;
45 |
46 | /**
47 | * Replaces unprintable characters by their escaped (or unicode escaped)
48 | * equivalents in the given string
49 | */
50 | protected static final String addEscapes(String str) {
51 | StringBuilder retval = new StringBuilder();
52 | char ch;
53 | for (int i = 0; i < str.length(); i++) {
54 | switch (str.charAt(i))
55 | {
56 | case '\b':
57 | retval.append("\\b");
58 | continue;
59 | case '\t':
60 | retval.append("\\t");
61 | continue;
62 | case '\n':
63 | retval.append("\\n");
64 | continue;
65 | case '\f':
66 | retval.append("\\f");
67 | continue;
68 | case '\r':
69 | retval.append("\\r");
70 | continue;
71 | case '\"':
72 | retval.append("\\\"");
73 | continue;
74 | case '\'':
75 | retval.append("\\\'");
76 | continue;
77 | case '\\':
78 | retval.append("\\\\");
79 | continue;
80 | default:
81 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
82 | String s = "0000" + Integer.toString(ch, 16);
83 | retval.append("\\u" + s.substring(s.length() - 4, s.length()));
84 | } else {
85 | retval.append(ch);
86 | }
87 | continue;
88 | }
89 | }
90 | return retval.toString();
91 | }
92 |
93 | /**
94 | * Returns a detailed message for the Error when it is thrown by the
95 | * token manager to indicate a lexical error.
96 | * Parameters :
97 | * EOFSeen : indicates if EOF caused the lexical error
98 | * curLexState : lexical state in which this error occurred
99 | * errorLine : line number when the error occurred
100 | * errorColumn : column number when the error occurred
101 | * errorAfter : prefix that was seen before this error occurred
102 | * curchar : the offending character
103 | * Note: You can customize the lexical error message by modifying this method.
104 | */
105 | protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) {
106 | char curChar1 = (char)curChar;
107 | return("Lexical error at line " +
108 | errorLine + ", column " +
109 | errorColumn + ". Encountered: " +
110 | (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") +
111 | "after : \"" + addEscapes(errorAfter) + "\"");
112 | }
113 |
114 | /**
115 | * You can also modify the body of this method to customize your error messages.
116 | * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
117 | * of end-users concern, so you can return something like :
118 | *
119 | * "Internal Error : Please file a bug report .... "
120 | *
121 | * from this method for such cases in the release version of your parser.
122 | */
123 | @Override
124 | public String getMessage() {
125 | return super.getMessage();
126 | }
127 |
128 | /*
129 | * Constructors of various flavors follow.
130 | */
131 |
132 | /** No arg constructor. */
133 | public TokenMgrError() {
134 | }
135 |
136 | /** Constructor with message and reason. */
137 | public TokenMgrError(String message, int reason) {
138 | super(message);
139 | errorCode = reason;
140 | }
141 |
142 | /** Full Constructor. */
143 | public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar, int reason) {
144 | this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
145 | }
146 | }
147 | /* JavaCC - OriginalChecksum=9e201c978d59ab6f122a52837e6310b1 (do not edit this line) */
148 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/c/gen/c.jjt:
--------------------------------------------------------------------------------
1 | /*
2 | C grammar and JJTree definition for use with JavaCC
3 | Contributed by Doug South (dsouth@squirrel.com.au) 21/3/97
4 | From: https://github.com/javacc/javacc/blob/master/grammars/CParser.jj
5 | */
6 |
7 | /* The following code has been significantly modified so as to make it compatible with Ghidra's decompiled output
8 | * and for the Rust transpilation
9 | */
10 |
11 | options {
12 | MULTI = true;
13 | VISITOR = true;
14 | STATIC = false;
15 | }
16 |
17 | PARSER_BEGIN(CParser)
18 |
19 | import java.io.InputStream;
20 | import java.io.ByteArrayInputStream;
21 | import java.nio.charset.StandardCharsets;
22 | import ghidrust.decompiler.parser.c.CVisitor;
23 | import ghidrust.decompiler.parser.c.CContext;
24 |
25 | public class CParser {
26 | private static CParser c_parser;
27 |
28 | // Run the parser
29 | public static String transpile(String c_code) {
30 | InputStream stream = new ByteArrayInputStream(c_code.getBytes(StandardCharsets.UTF_8));
31 | return transpile(stream);
32 | }
33 |
34 | public static String transpile(InputStream stream) {
35 | c_parser = new CParser(stream);
36 |
37 | try {
38 | return parse();
39 | } catch (ParseException e) {
40 | System.out.println("Rust transpiler: Encountered errors during parsing.");
41 | e.printStackTrace();
42 | return null;
43 | }
44 | }
45 |
46 | public static String parse() throws ParseException {
47 | CParserVisitor visitor = new CVisitor();
48 | return (String) c_parser.FunctionDefinition().jjtAccept(visitor, new CContext());
49 | }
50 | }
51 |
52 | PARSER_END(CParser)
53 |
54 | SKIP : {
55 | " "
56 | | "\t"
57 | | "\n"
58 | | "\r"
59 | | <"//" (~["\n","\r"])* ("\n" | "\r" | "\r\n")>
60 | | <"/*" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/">
61 | | "#" : PREPROCESSOR_OUTPUT
62 | }
63 |
64 | SKIP:
65 | {
66 | "\n" : DEFAULT
67 | }
68 |
69 | MORE:
70 | {
71 | "\\\n"
72 | |
73 | "\\\r\n"
74 | |
75 | < ~[] >
76 | }
77 |
78 |
79 | TOKEN : {
80 | (["l","L"])? | (["l","L"])? | (["l","L"])?>
81 | | <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])*>
82 | | <#HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+>
83 | | <#OCTAL_LITERAL: "0" (["0"-"7"])*>
84 | | )? (["f","F","d","D"])? | "." (["0"-"9"])+ ()? (["f","F","d","D"])? | (["0"-"9"])+ (["f","F","d","D"])? | (["0"-"9"])+ ()? ["f","F","d","D"]>
85 | | <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
86 | |
87 | |
88 | |
89 | | )?> // Ghidra specific unknown type
90 | }
91 |
92 | TOKEN : {
93 | |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | |
126 | // code ptr, Ghidra specific
127 | }
128 |
129 | TOKEN : {
130 | | ) ( | | )*>
131 | | <#LETTER: ["$","A"-"Z","_","a"-"z"]>
132 | | <#DIGIT: ["0"-"9"]>
133 | | <#SEPARATOR: [":"]>
134 | }
135 |
136 |
137 | SimpleNode FunctionDefinition() : {}
138 | {
139 | [LOOKAHEAD(DeclarationSpecifiers()) DeclarationSpecifiers()] Declarator()
140 | CompoundStatement()
141 | {
142 | return jjtThis;
143 | }
144 | }
145 |
146 | void Declaration() : {}
147 | {
148 | DeclarationSpecifiers() [ InitDeclaratorList() ] ";"
149 | }
150 |
151 | void DeclarationList() : {}
152 | {
153 | ( LOOKAHEAD(Declaration()) Declaration() )+
154 | }
155 |
156 | void DeclarationSpecifiers() : {}
157 | {
158 | StorageClassSpecifier() [ LOOKAHEAD(DeclarationSpecifiers())
159 | DeclarationSpecifiers() ] |
160 | TypeSpecifier() [ LOOKAHEAD(DeclarationSpecifiers())
161 | DeclarationSpecifiers() ] |
162 | TypeQualifier() [ LOOKAHEAD(DeclarationSpecifiers())
163 | DeclarationSpecifiers() ]
164 | }
165 |
166 | void StorageClassSpecifier() #GhostStringToken :
167 | {
168 | Token t;
169 | }
170 | {
171 | ( t = | t = | t = | t = | t = )
172 | {
173 | jjtThis.image = t.image;
174 | }
175 | }
176 |
177 | void TypeSpecifier() #TypeStringToken :
178 | {
179 | Token t;
180 | }
181 | {
182 | ( t = | t = | t = | t = | t = | t = | t = | t = |
183 | t = | t = | t = | t = )
184 | {
185 | jjtThis.image = t.image;
186 | }
187 | }
188 |
189 | void TypeQualifier() #StringToken :
190 | {
191 | Token t;
192 | }
193 | {
194 | ( t = | t = )
195 | {
196 | jjtThis.image = t.image;
197 | }
198 | }
199 |
200 | void InitDeclaratorList() : {}
201 | {
202 | InitDeclarator() ("," InitDeclarator())*
203 | }
204 |
205 | void InitDeclarator() : {}
206 | {
207 | Declarator() [ "=" Initializer() ]
208 | }
209 |
210 | void SpecifierQualifierList() : {}
211 | {
212 | TypeSpecifier() [ LOOKAHEAD(SpecifierQualifierList())
213 | SpecifierQualifierList() ]|
214 | TypeQualifier() [ LOOKAHEAD(SpecifierQualifierList())
215 | SpecifierQualifierList() ]
216 | }
217 |
218 | void Declarator() : {}
219 | {
220 | [ Pointer() ] DirectDeclarator()
221 | }
222 |
223 | void DirectDeclarator() : {}
224 | {
225 | ( Identifier() | "(" Declarator() ")" )
226 | ( "[" [ ConstantExpression() ] "]" |
227 | LOOKAHEAD(3) "(" ParameterTypeList() ")" |
228 | "(" [ IdentifierList() ] ")" )*
229 | }
230 |
231 | void Pointer() : {}
232 | {
233 | "*" [ TypeQualifierList() ] [ Pointer() ]
234 | }
235 |
236 | void TypeQualifierList() : {}
237 | {
238 | (TypeQualifier())+
239 | }
240 |
241 | void ParameterTypeList() : {}
242 | {
243 | ParameterList() ["," "..." ]
244 | }
245 |
246 | void ParameterList() : {}
247 | {
248 | ParameterDeclaration() (LOOKAHEAD(2) "," ParameterDeclaration())*
249 | }
250 |
251 | void ParameterDeclaration() : {}
252 | {
253 | DeclarationSpecifiers() ( LOOKAHEAD(Declarator()) Declarator() | [ AbstractDeclarator() ] )
254 | }
255 |
256 | void IdentifierList() : {}
257 | {
258 | Identifier() ("," Identifier())*
259 | }
260 |
261 | void Initializer() : {}
262 | {
263 | ( AssignmentExpression() |
264 | "{" InitializerList() [","] "}" )
265 | }
266 |
267 | void InitializerList() : {}
268 | {
269 | Initializer() (LOOKAHEAD(2) "," Initializer())*
270 | }
271 |
272 | void TypeName() : {}
273 | {
274 | SpecifierQualifierList() [ AbstractDeclarator() ]
275 |
276 | }
277 |
278 | void AbstractDeclarator() : {}
279 | {
280 | ( LOOKAHEAD(3) Pointer() |
281 | [Pointer()] DirectAbstractDeclarator() )
282 | }
283 |
284 | void DirectAbstractDeclarator() : {}
285 | {
286 | ( LOOKAHEAD(2) "(" AbstractDeclarator() ")" |
287 | "[" [ConstantExpression()] "]" |
288 | "(" [ParameterTypeList()] ")" )
289 |
290 | ( "[" [ ConstantExpression() ] "]" | "(" [ ParameterTypeList() ] ")" )*
291 | }
292 |
293 | void Statement() : {}
294 | {
295 | ( LOOKAHEAD(Identifier() ":") LabeledStatement() |
296 | ExpressionStatement() |
297 | CompoundStatement() |
298 | SelectionStatement() |
299 | IterationStatement() |
300 | JumpStatement() )
301 | }
302 |
303 | void LabeledStatement() : {}
304 | {
305 | ( Identifier() ":" Statement() |
306 | ConstantExpression() ":" Statement() |
307 | ":" Statement() )
308 | }
309 |
310 | void ExpressionStatement() : {}
311 | {
312 | [ Expression() ] ";"
313 | }
314 |
315 | void CompoundStatement() : {}
316 | {
317 | "{" [ LOOKAHEAD(DeclarationList()) DeclarationList() ]
318 | [ StatementList() ]
319 | "}"
320 | }
321 |
322 | void StatementList() : {}
323 | {
324 | (Statement())+
325 | }
326 |
327 | void SelectionStatement() : {}
328 | {
329 | ( "(" Expression() ")" Statement() [ LOOKAHEAD(2) Statement() ] |
330 | "(" Expression() ")" Statement() )
331 | }
332 |
333 | void IterationStatement() :
334 | {
335 | int choice = 0;
336 | }
337 | {
338 | ( "(" Expression() ")" Statement() { choice = 1; } |
339 | Statement() "(" Expression() ")" ";" { choice = 2; } |
340 | "(" [ Expression() ] ";" [ Expression() ] ";" [ Expression() ] ")" Statement() { choice = 3; } )
341 | {
342 | jjtThis.choice = choice;
343 | }
344 | }
345 |
346 | void JumpStatement() :
347 | {
348 | int choice = 0;
349 | }
350 | {
351 | ( Identifier() ";" | { choice = 1; }
352 | ";" | { choice = 2; }
353 | ";" | { choice = 3; }
354 | [ Expression() ] ";" { choice = 4; } )
355 | {
356 | jjtThis.choice = choice;
357 | }
358 | }
359 |
360 | void Expression() : {}
361 | {
362 | AssignmentExpression() ( "," AssignmentExpression() )* | DeclarationSpecifiers() InitDeclaratorList()
363 | }
364 |
365 | void AssignmentExpression() : {}
366 | {
367 | LOOKAHEAD(UnaryExpression() AssignmentOperator()) UnaryExpression() AssignmentOperator() AssignmentExpression() |
368 | LOOKAHEAD(3) ConditionalExpression()
369 | }
370 |
371 | void AssignmentOperator() #StringToken :
372 | {
373 | Token t;
374 | }
375 | {
376 | ( t = "=" | t = "*=" | t = "/=" | t = "%=" | t = "+=" | t = "-=" | t = "<<=" | t = ">>=" | t = "&=" | t = "^=" | t = "|=" )
377 | {
378 | jjtThis.image = t.image;
379 | }
380 | }
381 |
382 | void ConditionalExpression() : {}
383 | {
384 | LogicalORExpression() [ "?" Expression() ":" ConditionalExpression() ]
385 | }
386 |
387 | void ConstantExpression() : {}
388 | {
389 | ConditionalExpression()
390 | }
391 |
392 | void LogicalORExpression() : {}
393 | {
394 | LogicalANDExpression() [ "||" LogicalORExpression() ]
395 | }
396 |
397 | void LogicalANDExpression() : {}
398 | {
399 | InclusiveORExpression() [ "&&" LogicalANDExpression() ]
400 | }
401 |
402 | void InclusiveORExpression() : {}
403 | {
404 | ExclusiveORExpression() [ "|" InclusiveORExpression() ]
405 | }
406 |
407 | void ExclusiveORExpression() : {}
408 | {
409 | ANDExpression() [ "^" ExclusiveORExpression() ]
410 | }
411 |
412 | void ANDExpression() : {}
413 | {
414 | EqualityExpression() [ "&" ANDExpression() ]
415 | }
416 |
417 | void EqualityExpression() : {}
418 | {
419 | RelationalExpression() [ EqualityOperator() EqualityExpression() ]
420 | }
421 |
422 | void EqualityOperator() #StringToken :
423 | {
424 | Token t;
425 | }
426 | {
427 | ( t = "==" | t = "!=" )
428 | {
429 | jjtThis.image = t.image;
430 | }
431 | }
432 |
433 | void RelationalExpression() : {}
434 | {
435 | ShiftExpression() [ComparaisonOperator() RelationalExpression()]
436 | }
437 |
438 | void ComparaisonOperator() #StringToken :
439 | {
440 | Token t;
441 | }
442 | {
443 | ( t = "<" | t = ">" | t = "<=" | t = ">=" )
444 | {
445 | jjtThis.image = t.image;
446 | }
447 | }
448 |
449 | void ShiftExpression() : {}
450 | {
451 | AdditiveExpression() [ ( "<<" | ">>" ) ShiftExpression() ]
452 | }
453 |
454 | void AdditiveExpression() : {}
455 | {
456 | MultiplicativeExpression() [ AdditionOperator() AdditiveExpression() ]
457 | }
458 |
459 | void AdditionOperator() #StringToken :
460 | {
461 | Token t;
462 | }
463 | {
464 | ( t = "+" | t = "-" )
465 | {
466 | jjtThis.image = t.image;
467 | }
468 | }
469 |
470 | void MultiplicativeExpression() : {}
471 | {
472 | CastExpression() [ ( "*" | "/" | "%" ) MultiplicativeExpression() ]
473 | }
474 |
475 | void CastExpression() : {}
476 | {
477 | ( LOOKAHEAD("(" TypeName() ")" CastExpression() ) "(" TypeName() ")" CastExpression() |
478 | UnaryExpression() )
479 | }
480 |
481 | void UnaryExpression() :
482 | {
483 | int choice = 0;
484 | }
485 | {
486 | ( LOOKAHEAD(3) PostfixExpression() { choice = 1; } |
487 | "++" UnaryExpression() { choice = 2; } |
488 | "--" UnaryExpression() { choice = 3; } |
489 | UnaryOperator() CastExpression() { choice = 4; } |
490 | ( LOOKAHEAD(UnaryExpression() ) UnaryExpression() { choice = 5; } | "(" TypeName() ")" ) { choice = 6; } )
491 | {
492 | jjtThis.choice = choice;
493 | }
494 | }
495 |
496 | void UnaryOperator() #StringToken :
497 | {
498 | Token t;
499 | }
500 | {
501 | ( t = "&" | t = "*" | t = "+" | t = "-" | t = "~" | t = "!" )
502 | {
503 | jjtThis.image = t.image;
504 | }
505 | }
506 |
507 | void PostfixExpression() : {
508 | int choice = 0;
509 | }
510 | {
511 | PrimaryExpression() ( "[" Expression() "]" { choice = 1; } |
512 | "(" [ LOOKAHEAD(ArgumentExpressionList() ) ArgumentExpressionList() ] ")" { choice = 2; } |
513 | "." Identifier() { choice = 3; } |
514 | "->" Identifier() | { choice = 4; }
515 | "++" | { choice = 5; }
516 | "--" { choice = 6; } )*
517 | {
518 | jjtThis.choice = choice;
519 | }
520 | }
521 |
522 | void PrimaryExpression() : {}
523 | {
524 | ( Identifier() |
525 | Constant() |
526 | "(" Expression() ")" )
527 | }
528 |
529 | void ArgumentExpressionList() : {}
530 | {
531 | AssignmentExpression() ( "," AssignmentExpression() )*
532 | }
533 |
534 | ASTStringToken Identifier() #StringToken :
535 | {
536 | Token r = null;
537 | ASTStringToken t = null;
538 | Token s = null;
539 | int choice = 0;
540 | }
541 | {
542 | (LOOKAHEAD() r = { choice = 1; } | [ r = ] "<" t = Identifier() ">" [ s = ] { choice = 2; })
543 | {
544 | if (choice == 2) {
545 | jjtThis.image = (r != null ? r.image : "") + "<" + t.image + ">" + (s != null ? s.image : "");
546 | } else if (choice == 1) {
547 | jjtThis.image = r.image;
548 | }
549 |
550 | return jjtThis;
551 | }
552 | }
553 |
554 | void Constant() #StringToken :
555 | {
556 | Token t;
557 | }
558 | {
559 | (t = | t = | t = | t = | t = )
560 | {
561 | jjtThis.image = t.image;
562 | }
563 | }
564 |
--------------------------------------------------------------------------------
/src/main/java/ghidrust/decompiler/parser/generate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Shell script to generate the parsers and add the package statement to the top of each file
4 |
5 | cd c/gen
6 |
7 | BACKUP_FILES="ASTPostfixExpression ASTIterationStatement ASTUnaryExpression ASTJumpStatement \
8 | $(ls -1 AST*Token.java | cut -d. -f1 | tr '\n' ' ')"
9 |
10 | for file in $BACKUP_FILES; do
11 | mv -- "${file}.java" "${file}.bak"
12 | done
13 |
14 | rm -f *.java c.jj
15 |
16 | jjtree c.jjt
17 | javacc c.jj
18 |
19 | sleep 1
20 |
21 | for file in *.java; do
22 | sed -i '1s/^/package ghidrust.decompiler.parser.c.gen;\n\n/' $file
23 | done
24 |
25 | for file in $BACKUP_FILES; do
26 | mv -- "${file}.bak" "${file}.java"
27 | done
28 |
--------------------------------------------------------------------------------
/src/main/resources/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/resources/images/icon.png
--------------------------------------------------------------------------------
/src/main/resources/images/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DMaroo/GhidRust/a4c5ebeee4c7506c29191fc5be9fc0cda9934952/src/main/resources/images/reload.png
--------------------------------------------------------------------------------