From ee8f14c75e47eb24a2a24cea1ed47b4240e64da6 Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Mon, 9 Oct 2023 22:35:40 -0700 Subject: [PATCH] Added WIP files Added WIP test Got tests to pass Got more tests to pass Got more tests to pass Got tests to pass Fixed unittests Added missing instruction offset information Added more tests Updated Cargo.toml Added WIP highlight unittests Added extra code location code Added more tests Got all main (non highlight) unittests working Added WIP tests Added more tests Got tests to pass Got more tests to pass Added WIP test Fixed newlines Got more tests to pass Added WIP tests for comments Fixed unittest WIP unittest updates Removed unused code Added new test Added tests Got all tests to pass Added comment rule Added more tests Added WIP scanner.cc Added mising comment Got more tests to pass Added WIP test Got tests to pass Added WIP unittests Added WIP tests Fixed unittests Added new failing test Simplified a test Removed unused code Condensing some queries down Getting more tests to pass Changed the instruction parser to be more correct Added EOF checks, just in case Got unittests to pass Renamed existing variables Simplified rules Got all tests to pass Updated comment Added README.md Added missing screenshot Added check.sh Got all tests to pass Added fake, broken test Fixed test Removed test --- .github/workflows/test.yml | 10 - Cargo.toml | 26 + README.md | 60 +- binding.gyp | 19 + bindings/node/binding.cc | 28 + bindings/node/index.js | 19 + bindings/rust/build.rs | 38 + bindings/rust/lib.rs | 52 + check.sh | 17 + grammar.js | 144 +++ package.json | 40 + queries/highlights.scm | 20 + src/grammar.json | 513 ++++++++ src/node-types.json | 366 ++++++ src/parser.c | 1955 +++++++++++++++++++++++++++++++ src/scanner.cc | 235 ++++ src/tree_sitter/parser.h | 224 ++++ test/corpus/comment.txt | 59 + test/corpus/header.txt | 16 + test/corpus/path.txt | 64 + test/corpus/sample.txt | 216 ++++ test/corpus/scan.txt | 130 ++ test/corpus/sections.txt | 399 +++++++ test/highlight/header.objdump | 5 + test/highlight/sample.objdump | 26 + test/highlight/sections.objdump | 34 + 26 files changed, 4704 insertions(+), 11 deletions(-) create mode 100644 Cargo.toml create mode 100644 binding.gyp create mode 100644 bindings/node/binding.cc create mode 100644 bindings/node/index.js create mode 100644 bindings/rust/build.rs create mode 100644 bindings/rust/lib.rs create mode 100755 check.sh create mode 100644 grammar.js create mode 100644 package.json create mode 100644 queries/highlights.scm create mode 100644 src/grammar.json create mode 100644 src/node-types.json create mode 100644 src/parser.c create mode 100644 src/scanner.cc create mode 100644 src/tree_sitter/parser.h create mode 100644 test/corpus/comment.txt create mode 100644 test/corpus/header.txt create mode 100644 test/corpus/path.txt create mode 100644 test/corpus/sample.txt create mode 100644 test/corpus/scan.txt create mode 100644 test/corpus/sections.txt create mode 100644 test/highlight/header.objdump create mode 100644 test/highlight/sample.objdump create mode 100644 test/highlight/sections.objdump diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 609db1d..3cc2784 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,13 +21,3 @@ jobs: node-version: 14 - run: npm install - run: npm test - - test_windows: - runs-on: windows-2019 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 14 - - run: npm install - - run: npm run-script test-windows diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d0e1670 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "tree-sitter-objdump" +description = "objdump grammar for the tree-sitter parsing library" +version = "1.0.0" +keywords = ["incremental", "parsing", "objdump"] +categories = ["parsing", "text-editors"] +repository = "https://github.com/ColinKennedy/tree-sitter-objdump" +edition = "2018" +license = "MIT" + +build = "bindings/rust/build.rs" +include = [ + "bindings/rust/*", + "grammar.js", + "queries/*", + "src/*", +] + +[lib] +path = "bindings/rust/lib.rs" + +[dependencies] +tree-sitter = "~0.20.10" + +[build-dependencies] +cc = "1.0" diff --git a/README.md b/README.md index 7280dad..0ac9db0 100644 --- a/README.md +++ b/README.md @@ -1 +1,59 @@ -TODO add this +# tree-sitter-objdump +This library parses objdump text using +[tree-sitter](https://tree-sitter.github.io/tree-sitter) to produce +a light-weight grammar of the file. + + +![tree-sitter-objdump-highlights](https://github.com/ColinKennedy/tree-sitter-objdump/assets/10103049/57ee586d-a021-483f-8dd5-1f090184fde6) + + +## Disclaimer +This repository's parsing rules are subject to change. + + +## Building + Using +### Neovim +Make sure you include the following somewhere in your `init.lua` file. + +```lua +require("nvim-treesitter.configs").setup { + ensure_installed = {"objdump"}, + parser_install_dir = installation_directory, + highlight = { enable = true }, + + -- More stuff +} +``` + + +## Testing +### Unittests +- Install the [tree-sitter-cli](https://www.npmjs.com/package/tree-sitter-cli) +```sh +cd {root} +tree-sitter test +``` + +All tests should pass. + + +### Actual Objdump Files +The best way to test tree-sitter-usd is to parse Objdump files in-action. + +A quick way to do that is to run `check.sh` + + +```sh +check.sh # Searches the current directory +check.sh /path/to/place +``` + +This outputs objdump text to `/tmp/objdump_files` + +Then run + +```sh +cat /tmp/objdumps | xargs -I{} sh -c 'tree-sitter parse {} > /dev/null || echo "{}"' > /tmp/fails +``` + +If all is going well, the output file `/tmp/fails` should be empty! diff --git a/binding.gyp b/binding.gyp new file mode 100644 index 0000000..868250d --- /dev/null +++ b/binding.gyp @@ -0,0 +1,19 @@ +{ + "targets": [ + { + "target_name": "tree_sitter_objdump_binding", + "include_dirs": [ + " +#include "nan.h" + +using namespace v8; + +extern "C" TSLanguage * tree_sitter_objdump(); + +namespace { + +NAN_METHOD(New) {} + +void Init(Local exports, Local module) { + Local tpl = Nan::New(New); + tpl->SetClassName(Nan::New("Language").ToLocalChecked()); + tpl->InstanceTemplate()->SetInternalFieldCount(1); + + Local constructor = Nan::GetFunction(tpl).ToLocalChecked(); + Local instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); + Nan::SetInternalFieldPointer(instance, 0, tree_sitter_objdump()); + + Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("objdump").ToLocalChecked()); + Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); +} + +NODE_MODULE(tree_sitter_objdump_binding, Init) + +} // namespace diff --git a/bindings/node/index.js b/bindings/node/index.js new file mode 100644 index 0000000..cfd62e5 --- /dev/null +++ b/bindings/node/index.js @@ -0,0 +1,19 @@ +try { + module.exports = require("../../build/Release/tree_sitter_objdump_binding"); +} catch (error1) { + if (error1.code !== 'MODULE_NOT_FOUND') { + throw error1; + } + try { + module.exports = require("../../build/Debug/tree_sitter_objdump_binding"); + } catch (error2) { + if (error2.code !== 'MODULE_NOT_FOUND') { + throw error2; + } + throw error1 + } +} + +try { + module.exports.nodeTypeInfo = require("../../src/node-types.json"); +} catch (_) {} diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs new file mode 100644 index 0000000..618e90a --- /dev/null +++ b/bindings/rust/build.rs @@ -0,0 +1,38 @@ +fn main() { + let src_dir = std::path::Path::new("src"); + + let mut c_config = cc::Build::new(); + c_config.include(&src_dir); + c_config + .flag_if_supported("-Wno-unused-parameter") + .flag_if_supported("-Wno-unused-but-set-variable") + .flag_if_supported("-Wno-trigraphs"); + let parser_path = src_dir.join("parser.c"); + c_config.file(&parser_path); + + // If your language uses an external scanner written in C, + // then include this block of code: + + /* + let scanner_path = src_dir.join("scanner.c"); + c_config.file(&scanner_path); + println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); + */ + + c_config.compile("parser"); + println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); + + // If your language uses an external scanner written in C++, + // then include this block of code: + + let mut cpp_config = cc::Build::new(); + cpp_config.cpp(true); + cpp_config.include(&src_dir); + cpp_config + .flag_if_supported("-Wno-unused-parameter") + .flag_if_supported("-Wno-unused-but-set-variable"); + let scanner_path = src_dir.join("scanner.cc"); + cpp_config.file(&scanner_path); + cpp_config.compile("scanner"); + println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); +} diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs new file mode 100644 index 0000000..e3c0cf7 --- /dev/null +++ b/bindings/rust/lib.rs @@ -0,0 +1,52 @@ +//! This crate provides objdump language support for the [tree-sitter][] parsing library. +//! +//! Typically, you will use the [language][language func] function to add this language to a +//! tree-sitter [Parser][], and then use the parser to parse some code: +//! +//! ``` +//! let code = ""; +//! let mut parser = tree_sitter::Parser::new(); +//! parser.set_language(tree_sitter_objdump::language()).expect("Error loading objdump grammar"); +//! let tree = parser.parse(code, None).unwrap(); +//! ``` +//! +//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html +//! [language func]: fn.language.html +//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html +//! [tree-sitter]: https://tree-sitter.github.io/ + +use tree_sitter::Language; + +extern "C" { + fn tree_sitter_objdump() -> Language; +} + +/// Get the tree-sitter [Language][] for this grammar. +/// +/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html +pub fn language() -> Language { + unsafe { tree_sitter_objdump() } +} + +/// The content of the [`node-types.json`][] file for this grammar. +/// +/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types +pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); + +// Uncomment these to include any queries that this grammar contains + +// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm"); +// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); +// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); +// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); + +#[cfg(test)] +mod tests { + #[test] + fn test_can_load_grammar() { + let mut parser = tree_sitter::Parser::new(); + parser + .set_language(super::language()) + .expect("Error loading objdump language"); + } +} diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..71a002f --- /dev/null +++ b/check.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +directory=${1:-$PWD} +$($(find $directory -type f -executable | xargs -I{} sh -c "file -i '{}' \; | grep 'x-executable; charset=binary'" 2> /dev/null) | cut -d: -f1 | sed "s:^\.::" | xargs du | sort -n | awk '{print $2}'`) + +for file in $files +do + output=/tmp/objdump_files/file_`basename $file`.cppdump + + if [ -e $output ] + then + continue + fi + + echo "Processing $file" + objdump "$file" --disassemble-all --demangle=auto --line-numbers --disassemble-zeroes -M intel > $output +done diff --git a/grammar.js b/grammar.js new file mode 100644 index 0000000..f9520ed --- /dev/null +++ b/grammar.js @@ -0,0 +1,144 @@ +// Copyright (C) 2023 Colin Kennedy +// This file is part of tree-sitter-asm-intel . +// +// tree-sitter-asm-intel is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// tree-sitter-asm-intel is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with tree-sitter-asm-intel, see . + + +module.exports = grammar( + { + name: "objdump", + + conflicts: $=> [ + [$.disassembly_section], + ], + + externals: $ => [ + $.code_identifier, + $.instruction, + $._whitespace_no_newline, + ], + + rules: { + source: $ => repeat($._line), + + _line: $ => choice( + $.disassembly_section_label, + $.disassembly_section, + $.header, + + // These values are technically not "correct" to a objdump log + // but are frequently helpful for debugging / viewing text in + // isolation. + // + $.label_line, + $.memory_offset, + $.source_location, + ), + + header: $ => seq($.file_path, ":", "file", "format", $.identifier), + + disassembly_section: $ => seq( + alias($.address, $.section_address), + alias(/<.+>/, $.identifier), + optional($.file_offset), + ":", + repeat1(choice($.memory_offset, $.source_location, $.label_line)), + ), + + source_location: $ => seq( + $.file_path, + ":", + $.integer, // The file's line number + optional($.discriminator), + ), + + discriminator: $ => seq("(", "discriminator", $.integer, ")"), + + memory_offset: $ => seq( + $.address, + ":", + $.machine_code_bytes, + choice( + $._whitespace_no_newline, + seq( + /[^\n]/, + choice($._instruction_and_comment, $._instruction_and_location), + ) + ), + ), + + _instruction_and_comment: $ => seq( + $.instruction, + $.comment + ), + _instruction_and_location: $ => prec.left( + 2, + seq( + $.instruction, + optional($.code_location), + optional($.file_offset), + ) + ), + + comment: $ => seq( + "#", + choice( + $._comment_with_address, + $._comment_with_label, + ), + ), + + _comment_with_label: $ => seq($.address, $.code_location, optional($.file_offset)), + _comment_with_address: $ => $.hexadecimal, + + code_location: $ => seq( + "<", + alias($.code_identifier, $.identifier), + optional(seq("+", $.hexadecimal)), + ">", + ), + + label_line: $ => seq(alias($._label_identifier, $.label), ":"), + + hexadecimal: $ => /0[xh][0-9a-fA-F]+/, + byte: $ => /[0-9a-fA-F]{2}/, + machine_code_bytes: $ => space_separated1($.byte), + + address: $ => /[0-9a-fA-F]+/, + + file_offset: $ => seq("(", "File", "Offset:", $.hexadecimal, ")"), + + disassembly_section_label: $ => seq( + "Disassembly of section ", + $.section_name, + ":", + ), + + integer: $ => /\d+/, + + // TODO: Support windows paths, later. Also make sure Linux paths work + file_path: $ => /[\/\w\-\.\+]+/, + + _label_identifier: $ => /[A-Za-z.@_][A-Za-z0-9.@_$-\(\)]*/, // Test this, later + identifier: $ => /[^\n]+/, + + section_name: $ => /\.[^:]+/, + } + } +) + + +function space_separated1(rule) { + return seq(rule, repeat(seq(" ", rule))); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b68a293 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "author": "Colin Kennedy", + "bugs": { + "url": "https://github.com/ColinKennedy/tree-sitter-usd/issues" + }, + "dependencies": { + "nan": "^2.12.1" + }, + "description": "objdump grammar for tree-sitter", + "devDependencies": { + "tree-sitter-cli": "^0.20.8" + }, + "homepage": "https://github.com/ColinKennedy/tree-sitter-objdump#readme", + "keywords": [ + "tree-sitter", + "objdump", + "parsing", + "incremental" + ], + "main": "bindings/node", + "name": "tree-sitter-objdump", + "repository": { + "type": "git", + "url": "git+https://github.com/ColinKennedy/tree-sitter-objdump.git" + }, + "scripts": { + "test": "tree-sitter test", + "test-windows": "tree-sitter test" + }, + "tree-sitter": [ + { + "file-types": [ + "objdump" + ], + "injection-regex": "objdump", + "scope": "source.objdump" + } + ], + "version": "1.0.0" +} diff --git a/queries/highlights.scm b/queries/highlights.scm new file mode 100644 index 0000000..98310b0 --- /dev/null +++ b/queries/highlights.scm @@ -0,0 +1,20 @@ +(address) @number +(byte) @constant +(hexadecimal) @number +(integer) @number +(section_address) @number + +(disassembly_section_label) @text.title +[(file_offset) (discriminator)] @field +(file_path) @string +(identifier) @namespace +(instruction) @text +(label) @label +(machine_code_bytes) @field +(section_name) @namespace + +["<" ">"] @punctuation.special +["(" ")"] @punctuation.bracket +["+" ":"] @delimiter + +(comment) @comment.documentation diff --git a/src/grammar.json b/src/grammar.json new file mode 100644 index 0000000..ede75e1 --- /dev/null +++ b/src/grammar.json @@ -0,0 +1,513 @@ +{ + "name": "objdump", + "rules": { + "source": { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_line" + } + }, + "_line": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "disassembly_section_label" + }, + { + "type": "SYMBOL", + "name": "disassembly_section" + }, + { + "type": "SYMBOL", + "name": "header" + }, + { + "type": "SYMBOL", + "name": "label_line" + }, + { + "type": "SYMBOL", + "name": "memory_offset" + }, + { + "type": "SYMBOL", + "name": "source_location" + } + ] + }, + "header": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "file_path" + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "STRING", + "value": "file" + }, + { + "type": "STRING", + "value": "format" + }, + { + "type": "SYMBOL", + "name": "identifier" + } + ] + }, + "disassembly_section": { + "type": "SEQ", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "address" + }, + "named": true, + "value": "section_address" + }, + { + "type": "ALIAS", + "content": { + "type": "PATTERN", + "value": "<.+>" + }, + "named": true, + "value": "identifier" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "file_offset" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "REPEAT1", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "memory_offset" + }, + { + "type": "SYMBOL", + "name": "source_location" + }, + { + "type": "SYMBOL", + "name": "label_line" + } + ] + } + } + ] + }, + "source_location": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "file_path" + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "discriminator" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "discriminator": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "STRING", + "value": "discriminator" + }, + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "memory_offset": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "address" + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "machine_code_bytes" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_whitespace_no_newline" + }, + { + "type": "SEQ", + "members": [ + { + "type": "PATTERN", + "value": "[^\\n]" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_instruction_and_comment" + }, + { + "type": "SYMBOL", + "name": "_instruction_and_location" + } + ] + } + ] + } + ] + } + ] + }, + "_instruction_and_comment": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "instruction" + }, + { + "type": "SYMBOL", + "name": "comment" + } + ] + }, + "_instruction_and_location": { + "type": "PREC_LEFT", + "value": 2, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "instruction" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "code_location" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "file_offset" + }, + { + "type": "BLANK" + } + ] + } + ] + } + }, + "comment": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "#" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_comment_with_address" + }, + { + "type": "SYMBOL", + "name": "_comment_with_label" + } + ] + } + ] + }, + "_comment_with_label": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "address" + }, + { + "type": "SYMBOL", + "name": "code_location" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "file_offset" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "_comment_with_address": { + "type": "SYMBOL", + "name": "hexadecimal" + }, + "code_location": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "<" + }, + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "code_identifier" + }, + "named": true, + "value": "identifier" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "+" + }, + { + "type": "SYMBOL", + "name": "hexadecimal" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ">" + } + ] + }, + "label_line": { + "type": "SEQ", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "_label_identifier" + }, + "named": true, + "value": "label" + }, + { + "type": "STRING", + "value": ":" + } + ] + }, + "hexadecimal": { + "type": "PATTERN", + "value": "0[xh][0-9a-fA-F]+" + }, + "byte": { + "type": "PATTERN", + "value": "[0-9a-fA-F]{2}" + }, + "machine_code_bytes": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "byte" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": " " + }, + { + "type": "SYMBOL", + "name": "byte" + } + ] + } + } + ] + }, + "address": { + "type": "PATTERN", + "value": "[0-9a-fA-F]+" + }, + "file_offset": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "STRING", + "value": "File" + }, + { + "type": "STRING", + "value": "Offset:" + }, + { + "type": "SYMBOL", + "name": "hexadecimal" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "disassembly_section_label": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "Disassembly of section " + }, + { + "type": "SYMBOL", + "name": "section_name" + }, + { + "type": "STRING", + "value": ":" + } + ] + }, + "integer": { + "type": "PATTERN", + "value": "\\d+" + }, + "file_path": { + "type": "PATTERN", + "value": "[\\/\\w\\-\\.\\+]+" + }, + "_label_identifier": { + "type": "PATTERN", + "value": "[A-Za-z.@_][A-Za-z0-9.@_$-\\(\\)]*" + }, + "identifier": { + "type": "PATTERN", + "value": "[^\\n]+" + }, + "section_name": { + "type": "PATTERN", + "value": "\\.[^:]+" + } + }, + "extras": [ + { + "type": "PATTERN", + "value": "\\s" + } + ], + "conflicts": [ + [ + "disassembly_section" + ] + ], + "precedences": [], + "externals": [ + { + "type": "SYMBOL", + "name": "code_identifier" + }, + { + "type": "SYMBOL", + "name": "instruction" + }, + { + "type": "SYMBOL", + "name": "_whitespace_no_newline" + } + ], + "inline": [], + "supertypes": [] +} + diff --git a/src/node-types.json b/src/node-types.json new file mode 100644 index 0000000..f1f5048 --- /dev/null +++ b/src/node-types.json @@ -0,0 +1,366 @@ +[ + { + "type": "code_location", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "hexadecimal", + "named": true + }, + { + "type": "identifier", + "named": true + } + ] + } + }, + { + "type": "comment", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "address", + "named": true + }, + { + "type": "code_location", + "named": true + }, + { + "type": "file_offset", + "named": true + }, + { + "type": "hexadecimal", + "named": true + } + ] + } + }, + { + "type": "disassembly_section", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "file_offset", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "label_line", + "named": true + }, + { + "type": "memory_offset", + "named": true + }, + { + "type": "section_address", + "named": true + }, + { + "type": "source_location", + "named": true + } + ] + } + }, + { + "type": "disassembly_section_label", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "section_name", + "named": true + } + ] + } + }, + { + "type": "discriminator", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "integer", + "named": true + } + ] + } + }, + { + "type": "file_offset", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "hexadecimal", + "named": true + } + ] + } + }, + { + "type": "header", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "file_path", + "named": true + }, + { + "type": "identifier", + "named": true + } + ] + } + }, + { + "type": "label_line", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "label", + "named": true + } + ] + } + }, + { + "type": "machine_code_bytes", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "byte", + "named": true + } + ] + } + }, + { + "type": "memory_offset", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "address", + "named": true + }, + { + "type": "code_location", + "named": true + }, + { + "type": "comment", + "named": true + }, + { + "type": "file_offset", + "named": true + }, + { + "type": "instruction", + "named": true + }, + { + "type": "machine_code_bytes", + "named": true + } + ] + } + }, + { + "type": "source", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "disassembly_section", + "named": true + }, + { + "type": "disassembly_section_label", + "named": true + }, + { + "type": "header", + "named": true + }, + { + "type": "label_line", + "named": true + }, + { + "type": "memory_offset", + "named": true + }, + { + "type": "source_location", + "named": true + } + ] + } + }, + { + "type": "source_location", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "discriminator", + "named": true + }, + { + "type": "file_path", + "named": true + }, + { + "type": "integer", + "named": true + } + ] + } + }, + { + "type": " ", + "named": false + }, + { + "type": "#", + "named": false + }, + { + "type": "(", + "named": false + }, + { + "type": ")", + "named": false + }, + { + "type": "+", + "named": false + }, + { + "type": ":", + "named": false + }, + { + "type": "<", + "named": false + }, + { + "type": ">", + "named": false + }, + { + "type": "Disassembly of section ", + "named": false + }, + { + "type": "File", + "named": false + }, + { + "type": "Offset:", + "named": false + }, + { + "type": "address", + "named": true + }, + { + "type": "byte", + "named": true + }, + { + "type": "discriminator", + "named": false + }, + { + "type": "file", + "named": false + }, + { + "type": "file_path", + "named": true + }, + { + "type": "format", + "named": false + }, + { + "type": "hexadecimal", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "instruction", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "label", + "named": true + }, + { + "type": "section_address", + "named": true + }, + { + "type": "section_name", + "named": true + } +] \ No newline at end of file diff --git a/src/parser.c b/src/parser.c new file mode 100644 index 0000000..e8358b3 --- /dev/null +++ b/src/parser.c @@ -0,0 +1,1955 @@ +#include + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#define LANGUAGE_VERSION 14 +#define STATE_COUNT 63 +#define LARGE_STATE_COUNT 2 +#define SYMBOL_COUNT 48 +#define ALIAS_COUNT 1 +#define TOKEN_COUNT 28 +#define EXTERNAL_TOKEN_COUNT 3 +#define FIELD_COUNT 0 +#define MAX_ALIAS_SEQUENCE_LENGTH 5 +#define PRODUCTION_ID_COUNT 2 + +enum { + anon_sym_COLON = 1, + anon_sym_file = 2, + anon_sym_format = 3, + aux_sym_disassembly_section_token1 = 4, + anon_sym_LPAREN = 5, + anon_sym_discriminator = 6, + anon_sym_RPAREN = 7, + aux_sym_memory_offset_token1 = 8, + anon_sym_POUND = 9, + anon_sym_LT = 10, + anon_sym_PLUS = 11, + anon_sym_GT = 12, + sym_hexadecimal = 13, + sym_byte = 14, + anon_sym_ = 15, + sym_address = 16, + anon_sym_File = 17, + anon_sym_Offset_COLON = 18, + anon_sym_Disassemblyofsection = 19, + sym_integer = 20, + sym_file_path = 21, + sym__label_identifier = 22, + sym_identifier = 23, + sym_section_name = 24, + sym_code_identifier = 25, + sym_instruction = 26, + sym__whitespace_no_newline = 27, + sym_source = 28, + sym__line = 29, + sym_header = 30, + sym_disassembly_section = 31, + sym_source_location = 32, + sym_discriminator = 33, + sym_memory_offset = 34, + sym__instruction_and_comment = 35, + sym__instruction_and_location = 36, + sym_comment = 37, + sym__comment_with_label = 38, + sym__comment_with_address = 39, + sym_code_location = 40, + sym_label_line = 41, + sym_machine_code_bytes = 42, + sym_file_offset = 43, + sym_disassembly_section_label = 44, + aux_sym_source_repeat1 = 45, + aux_sym_disassembly_section_repeat1 = 46, + aux_sym_machine_code_bytes_repeat1 = 47, + alias_sym_section_address = 48, +}; + +static const char * const ts_symbol_names[] = { + [ts_builtin_sym_end] = "end", + [anon_sym_COLON] = ":", + [anon_sym_file] = "file", + [anon_sym_format] = "format", + [aux_sym_disassembly_section_token1] = "identifier", + [anon_sym_LPAREN] = "(", + [anon_sym_discriminator] = "discriminator", + [anon_sym_RPAREN] = ")", + [aux_sym_memory_offset_token1] = "memory_offset_token1", + [anon_sym_POUND] = "#", + [anon_sym_LT] = "<", + [anon_sym_PLUS] = "+", + [anon_sym_GT] = ">", + [sym_hexadecimal] = "hexadecimal", + [sym_byte] = "byte", + [anon_sym_] = " ", + [sym_address] = "address", + [anon_sym_File] = "File", + [anon_sym_Offset_COLON] = "Offset:", + [anon_sym_Disassemblyofsection] = "Disassembly of section ", + [sym_integer] = "integer", + [sym_file_path] = "file_path", + [sym__label_identifier] = "label", + [sym_identifier] = "identifier", + [sym_section_name] = "section_name", + [sym_code_identifier] = "identifier", + [sym_instruction] = "instruction", + [sym__whitespace_no_newline] = "_whitespace_no_newline", + [sym_source] = "source", + [sym__line] = "_line", + [sym_header] = "header", + [sym_disassembly_section] = "disassembly_section", + [sym_source_location] = "source_location", + [sym_discriminator] = "discriminator", + [sym_memory_offset] = "memory_offset", + [sym__instruction_and_comment] = "_instruction_and_comment", + [sym__instruction_and_location] = "_instruction_and_location", + [sym_comment] = "comment", + [sym__comment_with_label] = "_comment_with_label", + [sym__comment_with_address] = "_comment_with_address", + [sym_code_location] = "code_location", + [sym_label_line] = "label_line", + [sym_machine_code_bytes] = "machine_code_bytes", + [sym_file_offset] = "file_offset", + [sym_disassembly_section_label] = "disassembly_section_label", + [aux_sym_source_repeat1] = "source_repeat1", + [aux_sym_disassembly_section_repeat1] = "disassembly_section_repeat1", + [aux_sym_machine_code_bytes_repeat1] = "machine_code_bytes_repeat1", + [alias_sym_section_address] = "section_address", +}; + +static const TSSymbol ts_symbol_map[] = { + [ts_builtin_sym_end] = ts_builtin_sym_end, + [anon_sym_COLON] = anon_sym_COLON, + [anon_sym_file] = anon_sym_file, + [anon_sym_format] = anon_sym_format, + [aux_sym_disassembly_section_token1] = sym_identifier, + [anon_sym_LPAREN] = anon_sym_LPAREN, + [anon_sym_discriminator] = anon_sym_discriminator, + [anon_sym_RPAREN] = anon_sym_RPAREN, + [aux_sym_memory_offset_token1] = aux_sym_memory_offset_token1, + [anon_sym_POUND] = anon_sym_POUND, + [anon_sym_LT] = anon_sym_LT, + [anon_sym_PLUS] = anon_sym_PLUS, + [anon_sym_GT] = anon_sym_GT, + [sym_hexadecimal] = sym_hexadecimal, + [sym_byte] = sym_byte, + [anon_sym_] = anon_sym_, + [sym_address] = sym_address, + [anon_sym_File] = anon_sym_File, + [anon_sym_Offset_COLON] = anon_sym_Offset_COLON, + [anon_sym_Disassemblyofsection] = anon_sym_Disassemblyofsection, + [sym_integer] = sym_integer, + [sym_file_path] = sym_file_path, + [sym__label_identifier] = sym__label_identifier, + [sym_identifier] = sym_identifier, + [sym_section_name] = sym_section_name, + [sym_code_identifier] = sym_identifier, + [sym_instruction] = sym_instruction, + [sym__whitespace_no_newline] = sym__whitespace_no_newline, + [sym_source] = sym_source, + [sym__line] = sym__line, + [sym_header] = sym_header, + [sym_disassembly_section] = sym_disassembly_section, + [sym_source_location] = sym_source_location, + [sym_discriminator] = sym_discriminator, + [sym_memory_offset] = sym_memory_offset, + [sym__instruction_and_comment] = sym__instruction_and_comment, + [sym__instruction_and_location] = sym__instruction_and_location, + [sym_comment] = sym_comment, + [sym__comment_with_label] = sym__comment_with_label, + [sym__comment_with_address] = sym__comment_with_address, + [sym_code_location] = sym_code_location, + [sym_label_line] = sym_label_line, + [sym_machine_code_bytes] = sym_machine_code_bytes, + [sym_file_offset] = sym_file_offset, + [sym_disassembly_section_label] = sym_disassembly_section_label, + [aux_sym_source_repeat1] = aux_sym_source_repeat1, + [aux_sym_disassembly_section_repeat1] = aux_sym_disassembly_section_repeat1, + [aux_sym_machine_code_bytes_repeat1] = aux_sym_machine_code_bytes_repeat1, + [alias_sym_section_address] = alias_sym_section_address, +}; + +static const TSSymbolMetadata ts_symbol_metadata[] = { + [ts_builtin_sym_end] = { + .visible = false, + .named = true, + }, + [anon_sym_COLON] = { + .visible = true, + .named = false, + }, + [anon_sym_file] = { + .visible = true, + .named = false, + }, + [anon_sym_format] = { + .visible = true, + .named = false, + }, + [aux_sym_disassembly_section_token1] = { + .visible = true, + .named = true, + }, + [anon_sym_LPAREN] = { + .visible = true, + .named = false, + }, + [anon_sym_discriminator] = { + .visible = true, + .named = false, + }, + [anon_sym_RPAREN] = { + .visible = true, + .named = false, + }, + [aux_sym_memory_offset_token1] = { + .visible = false, + .named = false, + }, + [anon_sym_POUND] = { + .visible = true, + .named = false, + }, + [anon_sym_LT] = { + .visible = true, + .named = false, + }, + [anon_sym_PLUS] = { + .visible = true, + .named = false, + }, + [anon_sym_GT] = { + .visible = true, + .named = false, + }, + [sym_hexadecimal] = { + .visible = true, + .named = true, + }, + [sym_byte] = { + .visible = true, + .named = true, + }, + [anon_sym_] = { + .visible = true, + .named = false, + }, + [sym_address] = { + .visible = true, + .named = true, + }, + [anon_sym_File] = { + .visible = true, + .named = false, + }, + [anon_sym_Offset_COLON] = { + .visible = true, + .named = false, + }, + [anon_sym_Disassemblyofsection] = { + .visible = true, + .named = false, + }, + [sym_integer] = { + .visible = true, + .named = true, + }, + [sym_file_path] = { + .visible = true, + .named = true, + }, + [sym__label_identifier] = { + .visible = true, + .named = true, + }, + [sym_identifier] = { + .visible = true, + .named = true, + }, + [sym_section_name] = { + .visible = true, + .named = true, + }, + [sym_code_identifier] = { + .visible = true, + .named = true, + }, + [sym_instruction] = { + .visible = true, + .named = true, + }, + [sym__whitespace_no_newline] = { + .visible = false, + .named = true, + }, + [sym_source] = { + .visible = true, + .named = true, + }, + [sym__line] = { + .visible = false, + .named = true, + }, + [sym_header] = { + .visible = true, + .named = true, + }, + [sym_disassembly_section] = { + .visible = true, + .named = true, + }, + [sym_source_location] = { + .visible = true, + .named = true, + }, + [sym_discriminator] = { + .visible = true, + .named = true, + }, + [sym_memory_offset] = { + .visible = true, + .named = true, + }, + [sym__instruction_and_comment] = { + .visible = false, + .named = true, + }, + [sym__instruction_and_location] = { + .visible = false, + .named = true, + }, + [sym_comment] = { + .visible = true, + .named = true, + }, + [sym__comment_with_label] = { + .visible = false, + .named = true, + }, + [sym__comment_with_address] = { + .visible = false, + .named = true, + }, + [sym_code_location] = { + .visible = true, + .named = true, + }, + [sym_label_line] = { + .visible = true, + .named = true, + }, + [sym_machine_code_bytes] = { + .visible = true, + .named = true, + }, + [sym_file_offset] = { + .visible = true, + .named = true, + }, + [sym_disassembly_section_label] = { + .visible = true, + .named = true, + }, + [aux_sym_source_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_disassembly_section_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_machine_code_bytes_repeat1] = { + .visible = false, + .named = false, + }, + [alias_sym_section_address] = { + .visible = true, + .named = true, + }, +}; + +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { + [0] = {0}, + [1] = { + [0] = alias_sym_section_address, + }, +}; + +static const uint16_t ts_non_terminal_alias_map[] = { + 0, +}; + +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 8, + [9] = 9, + [10] = 10, + [11] = 11, + [12] = 12, + [13] = 13, + [14] = 14, + [15] = 15, + [16] = 16, + [17] = 17, + [18] = 18, + [19] = 19, + [20] = 20, + [21] = 21, + [22] = 22, + [23] = 23, + [24] = 24, + [25] = 25, + [26] = 26, + [27] = 27, + [28] = 28, + [29] = 29, + [30] = 30, + [31] = 31, + [32] = 32, + [33] = 33, + [34] = 34, + [35] = 35, + [36] = 36, + [37] = 37, + [38] = 38, + [39] = 39, + [40] = 40, + [41] = 41, + [42] = 42, + [43] = 43, + [44] = 44, + [45] = 45, + [46] = 46, + [47] = 47, + [48] = 48, + [49] = 49, + [50] = 50, + [51] = 51, + [52] = 52, + [53] = 53, + [54] = 54, + [55] = 55, + [56] = 56, + [57] = 57, + [58] = 58, + [59] = 59, + [60] = 60, + [61] = 61, + [62] = 62, +}; + +static bool ts_lex(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + if (eof) ADVANCE(64); + if (lookahead == '#') ADVANCE(75); + if (lookahead == '(') ADVANCE(69); + if (lookahead == ')') ADVANCE(71); + if (lookahead == '+') ADVANCE(78); + if (lookahead == '.') ADVANCE(62); + if (lookahead == '0') ADVANCE(90); + if (lookahead == ':') ADVANCE(65); + if (lookahead == '<') ADVANCE(77); + if (lookahead == '>') ADVANCE(79); + if (lookahead == 'D') ADVANCE(85); + if (lookahead == 'F') ADVANCE(86); + if (lookahead == 'O') ADVANCE(23); + if (lookahead == 'd') ADVANCE(88); + if (lookahead == 'f') ADVANCE(89); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(0) + if (('A' <= lookahead && lookahead <= 'E') || + ('a' <= lookahead && lookahead <= 'e')) ADVANCE(95); + if (('1' <= lookahead && lookahead <= '9')) ADVANCE(93); + END_STATE(); + case 1: + if (lookahead == '\n') SKIP(1) + if (lookahead == ' ') ADVANCE(84); + if (lookahead == '\t' || + lookahead == '\r') ADVANCE(73); + if (lookahead != 0) ADVANCE(72); + END_STATE(); + case 2: + if (lookahead == '\n') SKIP(2) + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(74); + if (lookahead != 0) ADVANCE(72); + END_STATE(); + case 3: + if (lookahead == '\n') SKIP(3) + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(115); + if (lookahead != 0) ADVANCE(116); + END_STATE(); + case 4: + if (lookahead == ' ') ADVANCE(100); + END_STATE(); + case 5: + if (lookahead == ' ') ADVANCE(43); + END_STATE(); + case 6: + if (lookahead == ' ') ADVANCE(52); + END_STATE(); + case 7: + if (lookahead == '0') ADVANCE(91); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(7) + if (('1' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 8: + if (lookahead == ':') ADVANCE(65); + if (lookahead == '<') ADVANCE(61); + if (lookahead == '@') ADVANCE(114); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(8) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(96); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(92); + if (lookahead == '.' || + ('G' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('g' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 9: + if (lookahead == ':') ADVANCE(99); + END_STATE(); + case 10: + if (lookahead == '>') ADVANCE(68); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(10); + END_STATE(); + case 11: + if (lookahead == 'F') ADVANCE(27); + if (lookahead == 'd') ADVANCE(29); + if (lookahead == 'f') ADVANCE(41); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(11) + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'E') || + ('a' <= lookahead && lookahead <= 'e')) ADVANCE(60); + END_STATE(); + case 12: + if (lookahead == 'a') ADVANCE(55); + END_STATE(); + case 13: + if (lookahead == 'a') ADVANCE(56); + END_STATE(); + case 14: + if (lookahead == 'a') ADVANCE(53); + END_STATE(); + case 15: + if (lookahead == 'b') ADVANCE(34); + END_STATE(); + case 16: + if (lookahead == 'c') ADVANCE(46); + END_STATE(); + case 17: + if (lookahead == 'c') ADVANCE(57); + END_STATE(); + case 18: + if (lookahead == 'e') ADVANCE(98); + END_STATE(); + case 19: + if (lookahead == 'e') ADVANCE(66); + END_STATE(); + case 20: + if (lookahead == 'e') ADVANCE(54); + END_STATE(); + case 21: + if (lookahead == 'e') ADVANCE(17); + END_STATE(); + case 22: + if (lookahead == 'e') ADVANCE(36); + END_STATE(); + case 23: + if (lookahead == 'f') ADVANCE(25); + END_STATE(); + case 24: + if (lookahead == 'f') ADVANCE(6); + END_STATE(); + case 25: + if (lookahead == 'f') ADVANCE(50); + END_STATE(); + case 26: + if (lookahead == 'f') ADVANCE(32); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(26) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(101); + END_STATE(); + case 27: + if (lookahead == 'i') ADVANCE(33); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(81); + END_STATE(); + case 28: + if (lookahead == 'i') ADVANCE(40); + END_STATE(); + case 29: + if (lookahead == 'i') ADVANCE(49); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(81); + END_STATE(); + case 30: + if (lookahead == 'i') ADVANCE(38); + END_STATE(); + case 31: + if (lookahead == 'i') ADVANCE(42); + END_STATE(); + case 32: + if (lookahead == 'i') ADVANCE(35); + END_STATE(); + case 33: + if (lookahead == 'l') ADVANCE(18); + END_STATE(); + case 34: + if (lookahead == 'l') ADVANCE(58); + END_STATE(); + case 35: + if (lookahead == 'l') ADVANCE(19); + END_STATE(); + case 36: + if (lookahead == 'm') ADVANCE(15); + END_STATE(); + case 37: + if (lookahead == 'm') ADVANCE(12); + END_STATE(); + case 38: + if (lookahead == 'm') ADVANCE(28); + END_STATE(); + case 39: + if (lookahead == 'n') ADVANCE(4); + END_STATE(); + case 40: + if (lookahead == 'n') ADVANCE(13); + END_STATE(); + case 41: + if (lookahead == 'o') ADVANCE(45); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(81); + END_STATE(); + case 42: + if (lookahead == 'o') ADVANCE(39); + END_STATE(); + case 43: + if (lookahead == 'o') ADVANCE(24); + END_STATE(); + case 44: + if (lookahead == 'o') ADVANCE(47); + END_STATE(); + case 45: + if (lookahead == 'r') ADVANCE(37); + END_STATE(); + case 46: + if (lookahead == 'r') ADVANCE(30); + END_STATE(); + case 47: + if (lookahead == 'r') ADVANCE(70); + END_STATE(); + case 48: + if (lookahead == 's') ADVANCE(14); + END_STATE(); + case 49: + if (lookahead == 's') ADVANCE(16); + END_STATE(); + case 50: + if (lookahead == 's') ADVANCE(20); + END_STATE(); + case 51: + if (lookahead == 's') ADVANCE(22); + END_STATE(); + case 52: + if (lookahead == 's') ADVANCE(21); + END_STATE(); + case 53: + if (lookahead == 's') ADVANCE(51); + END_STATE(); + case 54: + if (lookahead == 't') ADVANCE(9); + END_STATE(); + case 55: + if (lookahead == 't') ADVANCE(67); + END_STATE(); + case 56: + if (lookahead == 't') ADVANCE(44); + END_STATE(); + case 57: + if (lookahead == 't') ADVANCE(31); + END_STATE(); + case 58: + if (lookahead == 'y') ADVANCE(5); + END_STATE(); + case 59: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(80); + END_STATE(); + case 60: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(81); + END_STATE(); + case 61: + if (lookahead != 0 && + lookahead != '\n') ADVANCE(10); + END_STATE(); + case 62: + if (lookahead != 0 && + lookahead != ':') ADVANCE(117); + END_STATE(); + case 63: + if (eof) ADVANCE(64); + if (lookahead == '#') ADVANCE(75); + if (lookahead == '(') ADVANCE(69); + if (lookahead == ':') ADVANCE(65); + if (lookahead == '<') ADVANCE(76); + if (lookahead == '@') ADVANCE(114); + if (lookahead == 'D') ADVANCE(87); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(63) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(96); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(92); + if (lookahead == '.' || + ('G' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('g' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 64: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + case 65: + ACCEPT_TOKEN(anon_sym_COLON); + END_STATE(); + case 66: + ACCEPT_TOKEN(anon_sym_file); + END_STATE(); + case 67: + ACCEPT_TOKEN(anon_sym_format); + END_STATE(); + case 68: + ACCEPT_TOKEN(aux_sym_disassembly_section_token1); + if (lookahead == '>') ADVANCE(68); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(10); + END_STATE(); + case 69: + ACCEPT_TOKEN(anon_sym_LPAREN); + END_STATE(); + case 70: + ACCEPT_TOKEN(anon_sym_discriminator); + END_STATE(); + case 71: + ACCEPT_TOKEN(anon_sym_RPAREN); + END_STATE(); + case 72: + ACCEPT_TOKEN(aux_sym_memory_offset_token1); + END_STATE(); + case 73: + ACCEPT_TOKEN(aux_sym_memory_offset_token1); + if (lookahead == ' ') ADVANCE(84); + if (lookahead == '\t' || + lookahead == '\r') ADVANCE(73); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(72); + END_STATE(); + case 74: + ACCEPT_TOKEN(aux_sym_memory_offset_token1); + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(74); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(72); + END_STATE(); + case 75: + ACCEPT_TOKEN(anon_sym_POUND); + END_STATE(); + case 76: + ACCEPT_TOKEN(anon_sym_LT); + END_STATE(); + case 77: + ACCEPT_TOKEN(anon_sym_LT); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(10); + END_STATE(); + case 78: + ACCEPT_TOKEN(anon_sym_PLUS); + END_STATE(); + case 79: + ACCEPT_TOKEN(anon_sym_GT); + END_STATE(); + case 80: + ACCEPT_TOKEN(sym_hexadecimal); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(80); + END_STATE(); + case 81: + ACCEPT_TOKEN(sym_byte); + END_STATE(); + case 82: + ACCEPT_TOKEN(sym_byte); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(94); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 83: + ACCEPT_TOKEN(sym_byte); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 84: + ACCEPT_TOKEN(anon_sym_); + if (lookahead == ' ') ADVANCE(84); + if (lookahead == '\t' || + lookahead == '\r') ADVANCE(73); + END_STATE(); + case 85: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'i') ADVANCE(48); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 86: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'i') ADVANCE(33); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 87: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'i') ADVANCE(108); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(92); + if (lookahead == '.' || + ('G' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('g' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 88: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'i') ADVANCE(49); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 89: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'i') ADVANCE(35); + if (lookahead == 'o') ADVANCE(45); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 90: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'h' || + lookahead == 'x') ADVANCE(59); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(82); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 91: + ACCEPT_TOKEN(sym_address); + if (lookahead == 'h' || + lookahead == 'x') ADVANCE(59); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 92: + ACCEPT_TOKEN(sym_address); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(92); + if (lookahead == '.' || + ('G' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('g' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 93: + ACCEPT_TOKEN(sym_address); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(82); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 94: + ACCEPT_TOKEN(sym_address); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(94); + if (('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 95: + ACCEPT_TOKEN(sym_address); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(83); + END_STATE(); + case 96: + ACCEPT_TOKEN(sym_address); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(96); + if (lookahead == '+' || + ('-' <= lookahead && lookahead <= '/') || + ('G' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('g' <= lookahead && lookahead <= 'z')) ADVANCE(113); + END_STATE(); + case 97: + ACCEPT_TOKEN(sym_address); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(97); + END_STATE(); + case 98: + ACCEPT_TOKEN(anon_sym_File); + END_STATE(); + case 99: + ACCEPT_TOKEN(anon_sym_Offset_COLON); + END_STATE(); + case 100: + ACCEPT_TOKEN(anon_sym_Disassemblyofsection); + END_STATE(); + case 101: + ACCEPT_TOKEN(sym_integer); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(101); + END_STATE(); + case 102: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == ' ') ADVANCE(43); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 103: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'a') ADVANCE(110); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('b' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 104: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'b') ADVANCE(106); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 105: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'e') ADVANCE(107); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 106: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'l') ADVANCE(111); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 107: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'm') ADVANCE(104); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 108: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 's') ADVANCE(103); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 109: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 's') ADVANCE(105); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 110: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 's') ADVANCE(109); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 111: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == 'y') ADVANCE(102); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 112: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == '+' || + lookahead == '-' || + lookahead == '/') ADVANCE(113); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '@') ADVANCE(114); + if (('.' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(112); + END_STATE(); + case 113: + ACCEPT_TOKEN(sym_file_path); + if (lookahead == '+' || + ('-' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(113); + END_STATE(); + case 114: + ACCEPT_TOKEN(sym__label_identifier); + if (('$' <= lookahead && lookahead <= ')') || + lookahead == '.' || + ('0' <= lookahead && lookahead <= '9') || + ('@' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(114); + END_STATE(); + case 115: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') ADVANCE(115); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(116); + END_STATE(); + case 116: + ACCEPT_TOKEN(sym_identifier); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(116); + END_STATE(); + case 117: + ACCEPT_TOKEN(sym_section_name); + if (lookahead != 0 && + lookahead != ':') ADVANCE(117); + END_STATE(); + default: + return false; + } +} + +static const TSLexMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0, .external_lex_state = 1}, + [1] = {.lex_state = 63}, + [2] = {.lex_state = 63}, + [3] = {.lex_state = 63}, + [4] = {.lex_state = 63}, + [5] = {.lex_state = 63}, + [6] = {.lex_state = 63}, + [7] = {.lex_state = 63}, + [8] = {.lex_state = 63}, + [9] = {.lex_state = 8}, + [10] = {.lex_state = 63}, + [11] = {.lex_state = 63}, + [12] = {.lex_state = 8}, + [13] = {.lex_state = 63}, + [14] = {.lex_state = 63}, + [15] = {.lex_state = 63}, + [16] = {.lex_state = 63}, + [17] = {.lex_state = 63}, + [18] = {.lex_state = 63}, + [19] = {.lex_state = 63}, + [20] = {.lex_state = 63}, + [21] = {.lex_state = 63}, + [22] = {.lex_state = 63}, + [23] = {.lex_state = 63}, + [24] = {.lex_state = 63}, + [25] = {.lex_state = 63}, + [26] = {.lex_state = 63}, + [27] = {.lex_state = 63}, + [28] = {.lex_state = 7}, + [29] = {.lex_state = 1, .external_lex_state = 2}, + [30] = {.lex_state = 1, .external_lex_state = 2}, + [31] = {.lex_state = 1, .external_lex_state = 2}, + [32] = {.lex_state = 0}, + [33] = {.lex_state = 0, .external_lex_state = 3}, + [34] = {.lex_state = 1, .external_lex_state = 2}, + [35] = {.lex_state = 0}, + [36] = {.lex_state = 2, .external_lex_state = 2}, + [37] = {.lex_state = 8}, + [38] = {.lex_state = 11}, + [39] = {.lex_state = 26}, + [40] = {.lex_state = 63}, + [41] = {.lex_state = 0}, + [42] = {.lex_state = 7}, + [43] = {.lex_state = 26}, + [44] = {.lex_state = 0}, + [45] = {.lex_state = 0, .external_lex_state = 4}, + [46] = {.lex_state = 11}, + [47] = {.lex_state = 0}, + [48] = {.lex_state = 11}, + [49] = {.lex_state = 0}, + [50] = {.lex_state = 0}, + [51] = {.lex_state = 11}, + [52] = {.lex_state = 11}, + [53] = {.lex_state = 0}, + [54] = {.lex_state = 0}, + [55] = {.lex_state = 3}, + [56] = {.lex_state = 26}, + [57] = {.lex_state = 0}, + [58] = {.lex_state = 7}, + [59] = {.lex_state = 0}, + [60] = {.lex_state = 0}, + [61] = {.lex_state = 0}, + [62] = {.lex_state = 0}, +}; + +enum { + ts_external_token_code_identifier = 0, + ts_external_token_instruction = 1, + ts_external_token__whitespace_no_newline = 2, +}; + +static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { + [ts_external_token_code_identifier] = sym_code_identifier, + [ts_external_token_instruction] = sym_instruction, + [ts_external_token__whitespace_no_newline] = sym__whitespace_no_newline, +}; + +static const bool ts_external_scanner_states[5][EXTERNAL_TOKEN_COUNT] = { + [1] = { + [ts_external_token_code_identifier] = true, + [ts_external_token_instruction] = true, + [ts_external_token__whitespace_no_newline] = true, + }, + [2] = { + [ts_external_token__whitespace_no_newline] = true, + }, + [3] = { + [ts_external_token_instruction] = true, + }, + [4] = { + [ts_external_token_code_identifier] = true, + }, +}; + +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { + [0] = { + [ts_builtin_sym_end] = ACTIONS(1), + [anon_sym_COLON] = ACTIONS(1), + [anon_sym_file] = ACTIONS(1), + [anon_sym_format] = ACTIONS(1), + [aux_sym_disassembly_section_token1] = ACTIONS(1), + [anon_sym_LPAREN] = ACTIONS(1), + [anon_sym_discriminator] = ACTIONS(1), + [anon_sym_RPAREN] = ACTIONS(1), + [anon_sym_POUND] = ACTIONS(1), + [anon_sym_LT] = ACTIONS(1), + [anon_sym_PLUS] = ACTIONS(1), + [anon_sym_GT] = ACTIONS(1), + [sym_hexadecimal] = ACTIONS(1), + [sym_byte] = ACTIONS(1), + [sym_address] = ACTIONS(1), + [anon_sym_File] = ACTIONS(1), + [anon_sym_Offset_COLON] = ACTIONS(1), + [anon_sym_Disassemblyofsection] = ACTIONS(1), + [sym_integer] = ACTIONS(1), + [sym_section_name] = ACTIONS(1), + [sym_code_identifier] = ACTIONS(1), + [sym_instruction] = ACTIONS(1), + [sym__whitespace_no_newline] = ACTIONS(1), + }, + [1] = { + [sym_source] = STATE(57), + [sym__line] = STATE(3), + [sym_header] = STATE(3), + [sym_disassembly_section] = STATE(3), + [sym_source_location] = STATE(3), + [sym_memory_offset] = STATE(3), + [sym_label_line] = STATE(3), + [sym_disassembly_section_label] = STATE(3), + [aux_sym_source_repeat1] = STATE(3), + [ts_builtin_sym_end] = ACTIONS(3), + [sym_address] = ACTIONS(5), + [anon_sym_Disassemblyofsection] = ACTIONS(7), + [sym_file_path] = ACTIONS(9), + [sym__label_identifier] = ACTIONS(11), + }, +}; + +static const uint16_t ts_small_parse_table[] = { + [0] = 6, + ACTIONS(13), 1, + ts_builtin_sym_end, + ACTIONS(15), 1, + sym_address, + ACTIONS(18), 1, + anon_sym_Disassemblyofsection, + ACTIONS(21), 1, + sym_file_path, + ACTIONS(24), 1, + sym__label_identifier, + STATE(2), 8, + sym__line, + sym_header, + sym_disassembly_section, + sym_source_location, + sym_memory_offset, + sym_label_line, + sym_disassembly_section_label, + aux_sym_source_repeat1, + [26] = 6, + ACTIONS(5), 1, + sym_address, + ACTIONS(7), 1, + anon_sym_Disassemblyofsection, + ACTIONS(9), 1, + sym_file_path, + ACTIONS(11), 1, + sym__label_identifier, + ACTIONS(27), 1, + ts_builtin_sym_end, + STATE(2), 8, + sym__line, + sym_header, + sym_disassembly_section, + sym_source_location, + sym_memory_offset, + sym_label_line, + sym_disassembly_section_label, + aux_sym_source_repeat1, + [52] = 8, + ACTIONS(31), 1, + anon_sym_LPAREN, + ACTIONS(33), 1, + anon_sym_POUND, + ACTIONS(35), 1, + anon_sym_LT, + STATE(8), 1, + sym_code_location, + STATE(18), 1, + sym_file_offset, + STATE(20), 1, + sym_comment, + ACTIONS(29), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(37), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [80] = 5, + ACTIONS(41), 1, + sym_address, + ACTIONS(44), 1, + sym_file_path, + ACTIONS(47), 1, + sym__label_identifier, + ACTIONS(39), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + STATE(5), 4, + sym_source_location, + sym_memory_offset, + sym_label_line, + aux_sym_disassembly_section_repeat1, + [100] = 5, + ACTIONS(52), 1, + sym_address, + ACTIONS(55), 1, + sym_file_path, + ACTIONS(58), 1, + sym__label_identifier, + ACTIONS(50), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + STATE(5), 4, + sym_source_location, + sym_memory_offset, + sym_label_line, + aux_sym_disassembly_section_repeat1, + [120] = 5, + ACTIONS(63), 1, + sym_address, + ACTIONS(66), 1, + sym_file_path, + ACTIONS(69), 1, + sym__label_identifier, + ACTIONS(61), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + STATE(5), 4, + sym_source_location, + sym_memory_offset, + sym_label_line, + aux_sym_disassembly_section_repeat1, + [140] = 4, + ACTIONS(31), 1, + anon_sym_LPAREN, + STATE(16), 1, + sym_file_offset, + ACTIONS(72), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(74), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [156] = 4, + ACTIONS(11), 1, + sym__label_identifier, + ACTIONS(76), 1, + sym_address, + ACTIONS(78), 1, + sym_file_path, + STATE(7), 4, + sym_source_location, + sym_memory_offset, + sym_label_line, + aux_sym_disassembly_section_repeat1, + [172] = 4, + ACTIONS(31), 1, + anon_sym_LPAREN, + STATE(26), 1, + sym_file_offset, + ACTIONS(80), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(82), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [188] = 4, + ACTIONS(86), 1, + anon_sym_LPAREN, + STATE(27), 1, + sym_discriminator, + ACTIONS(84), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(88), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [204] = 4, + ACTIONS(11), 1, + sym__label_identifier, + ACTIONS(76), 1, + sym_address, + ACTIONS(78), 1, + sym_file_path, + STATE(6), 4, + sym_source_location, + sym_memory_offset, + sym_label_line, + aux_sym_disassembly_section_repeat1, + [220] = 2, + ACTIONS(90), 3, + ts_builtin_sym_end, + anon_sym_COLON, + anon_sym_Disassemblyofsection, + ACTIONS(92), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [231] = 2, + ACTIONS(94), 3, + ts_builtin_sym_end, + anon_sym_LPAREN, + anon_sym_Disassemblyofsection, + ACTIONS(96), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [242] = 2, + ACTIONS(98), 3, + ts_builtin_sym_end, + anon_sym_LPAREN, + anon_sym_Disassemblyofsection, + ACTIONS(100), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [253] = 2, + ACTIONS(102), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(104), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [263] = 2, + ACTIONS(106), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(108), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [273] = 2, + ACTIONS(72), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(74), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [283] = 2, + ACTIONS(110), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(112), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [293] = 2, + ACTIONS(114), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(116), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [303] = 2, + ACTIONS(118), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(120), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [313] = 2, + ACTIONS(122), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(124), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [323] = 2, + ACTIONS(126), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(128), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [333] = 2, + ACTIONS(130), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(132), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [343] = 2, + ACTIONS(134), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(136), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [353] = 2, + ACTIONS(138), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(140), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [363] = 2, + ACTIONS(142), 2, + ts_builtin_sym_end, + anon_sym_Disassemblyofsection, + ACTIONS(144), 3, + sym_address, + sym_file_path, + sym__label_identifier, + [373] = 3, + ACTIONS(146), 1, + sym_hexadecimal, + ACTIONS(148), 1, + sym_address, + STATE(17), 2, + sym__comment_with_label, + sym__comment_with_address, + [384] = 4, + ACTIONS(150), 1, + aux_sym_memory_offset_token1, + ACTIONS(152), 1, + anon_sym_, + ACTIONS(155), 1, + sym__whitespace_no_newline, + STATE(29), 1, + aux_sym_machine_code_bytes_repeat1, + [397] = 4, + ACTIONS(157), 1, + aux_sym_memory_offset_token1, + ACTIONS(159), 1, + anon_sym_, + ACTIONS(161), 1, + sym__whitespace_no_newline, + STATE(31), 1, + aux_sym_machine_code_bytes_repeat1, + [410] = 4, + ACTIONS(159), 1, + anon_sym_, + ACTIONS(163), 1, + aux_sym_memory_offset_token1, + ACTIONS(165), 1, + sym__whitespace_no_newline, + STATE(29), 1, + aux_sym_machine_code_bytes_repeat1, + [423] = 3, + ACTIONS(31), 1, + anon_sym_LPAREN, + ACTIONS(167), 1, + anon_sym_COLON, + STATE(44), 1, + sym_file_offset, + [433] = 2, + ACTIONS(169), 1, + sym_instruction, + STATE(24), 2, + sym__instruction_and_comment, + sym__instruction_and_location, + [441] = 2, + ACTIONS(155), 1, + sym__whitespace_no_newline, + ACTIONS(150), 2, + aux_sym_memory_offset_token1, + anon_sym_, + [449] = 2, + ACTIONS(171), 1, + anon_sym_PLUS, + ACTIONS(173), 1, + anon_sym_GT, + [456] = 2, + ACTIONS(175), 1, + aux_sym_memory_offset_token1, + ACTIONS(177), 1, + sym__whitespace_no_newline, + [463] = 2, + ACTIONS(179), 1, + anon_sym_COLON, + ACTIONS(181), 1, + aux_sym_disassembly_section_token1, + [470] = 2, + ACTIONS(183), 1, + sym_byte, + STATE(36), 1, + sym_machine_code_bytes, + [477] = 2, + ACTIONS(185), 1, + anon_sym_file, + ACTIONS(187), 1, + sym_integer, + [484] = 2, + ACTIONS(35), 1, + anon_sym_LT, + STATE(10), 1, + sym_code_location, + [491] = 1, + ACTIONS(189), 1, + anon_sym_Offset_COLON, + [495] = 1, + ACTIONS(191), 1, + sym_hexadecimal, + [499] = 1, + ACTIONS(193), 1, + sym_integer, + [503] = 1, + ACTIONS(195), 1, + anon_sym_COLON, + [507] = 1, + ACTIONS(197), 1, + sym_code_identifier, + [511] = 1, + ACTIONS(199), 1, + anon_sym_File, + [515] = 1, + ACTIONS(179), 1, + anon_sym_COLON, + [519] = 1, + ACTIONS(201), 1, + anon_sym_discriminator, + [523] = 1, + ACTIONS(203), 1, + anon_sym_RPAREN, + [527] = 1, + ACTIONS(205), 1, + anon_sym_RPAREN, + [531] = 1, + ACTIONS(207), 1, + sym_byte, + [535] = 1, + ACTIONS(209), 1, + anon_sym_format, + [539] = 1, + ACTIONS(211), 1, + anon_sym_COLON, + [543] = 1, + ACTIONS(213), 1, + anon_sym_COLON, + [547] = 1, + ACTIONS(215), 1, + sym_identifier, + [551] = 1, + ACTIONS(187), 1, + sym_integer, + [555] = 1, + ACTIONS(217), 1, + ts_builtin_sym_end, + [559] = 1, + ACTIONS(219), 1, + sym_hexadecimal, + [563] = 1, + ACTIONS(221), 1, + anon_sym_COLON, + [567] = 1, + ACTIONS(223), 1, + anon_sym_COLON, + [571] = 1, + ACTIONS(225), 1, + anon_sym_GT, + [575] = 1, + ACTIONS(227), 1, + sym_section_name, +}; + +static const uint32_t ts_small_parse_table_map[] = { + [SMALL_STATE(2)] = 0, + [SMALL_STATE(3)] = 26, + [SMALL_STATE(4)] = 52, + [SMALL_STATE(5)] = 80, + [SMALL_STATE(6)] = 100, + [SMALL_STATE(7)] = 120, + [SMALL_STATE(8)] = 140, + [SMALL_STATE(9)] = 156, + [SMALL_STATE(10)] = 172, + [SMALL_STATE(11)] = 188, + [SMALL_STATE(12)] = 204, + [SMALL_STATE(13)] = 220, + [SMALL_STATE(14)] = 231, + [SMALL_STATE(15)] = 242, + [SMALL_STATE(16)] = 253, + [SMALL_STATE(17)] = 263, + [SMALL_STATE(18)] = 273, + [SMALL_STATE(19)] = 283, + [SMALL_STATE(20)] = 293, + [SMALL_STATE(21)] = 303, + [SMALL_STATE(22)] = 313, + [SMALL_STATE(23)] = 323, + [SMALL_STATE(24)] = 333, + [SMALL_STATE(25)] = 343, + [SMALL_STATE(26)] = 353, + [SMALL_STATE(27)] = 363, + [SMALL_STATE(28)] = 373, + [SMALL_STATE(29)] = 384, + [SMALL_STATE(30)] = 397, + [SMALL_STATE(31)] = 410, + [SMALL_STATE(32)] = 423, + [SMALL_STATE(33)] = 433, + [SMALL_STATE(34)] = 441, + [SMALL_STATE(35)] = 449, + [SMALL_STATE(36)] = 456, + [SMALL_STATE(37)] = 463, + [SMALL_STATE(38)] = 470, + [SMALL_STATE(39)] = 477, + [SMALL_STATE(40)] = 484, + [SMALL_STATE(41)] = 491, + [SMALL_STATE(42)] = 495, + [SMALL_STATE(43)] = 499, + [SMALL_STATE(44)] = 503, + [SMALL_STATE(45)] = 507, + [SMALL_STATE(46)] = 511, + [SMALL_STATE(47)] = 515, + [SMALL_STATE(48)] = 519, + [SMALL_STATE(49)] = 523, + [SMALL_STATE(50)] = 527, + [SMALL_STATE(51)] = 531, + [SMALL_STATE(52)] = 535, + [SMALL_STATE(53)] = 539, + [SMALL_STATE(54)] = 543, + [SMALL_STATE(55)] = 547, + [SMALL_STATE(56)] = 551, + [SMALL_STATE(57)] = 555, + [SMALL_STATE(58)] = 559, + [SMALL_STATE(59)] = 563, + [SMALL_STATE(60)] = 567, + [SMALL_STATE(61)] = 571, + [SMALL_STATE(62)] = 575, +}; + +static const TSParseActionEntry ts_parse_actions[] = { + [0] = {.entry = {.count = 0, .reusable = false}}, + [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), + [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source, 0), + [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT(37), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(62), + [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(60), + [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(59), + [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_repeat1, 2), + [15] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(37), + [18] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(62), + [21] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(60), + [24] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(59), + [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source, 1), + [29] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__instruction_and_location, 1), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), + [33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), + [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), + [37] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__instruction_and_location, 1), + [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_disassembly_section_repeat1, 2), + [41] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_disassembly_section_repeat1, 2), SHIFT_REPEAT(47), + [44] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_disassembly_section_repeat1, 2), SHIFT_REPEAT(53), + [47] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_disassembly_section_repeat1, 2), SHIFT_REPEAT(59), + [50] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_disassembly_section, 5, .production_id = 1), + [52] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 5, .production_id = 1), SHIFT(47), + [55] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 5, .production_id = 1), SHIFT(53), + [58] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 5, .production_id = 1), SHIFT(59), + [61] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_disassembly_section, 4, .production_id = 1), + [63] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 4, .production_id = 1), SHIFT(47), + [66] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 4, .production_id = 1), SHIFT(53), + [69] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_disassembly_section, 4, .production_id = 1), SHIFT(59), + [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__instruction_and_location, 2), + [74] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__instruction_and_location, 2), + [76] = {.entry = {.count = 1, .reusable = false}}, SHIFT(47), + [78] = {.entry = {.count = 1, .reusable = false}}, SHIFT(53), + [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__comment_with_label, 2), + [82] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__comment_with_label, 2), + [84] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_location, 3), + [86] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), + [88] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_source_location, 3), + [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_file_offset, 5), + [92] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_file_offset, 5), + [94] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_code_location, 5), + [96] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_code_location, 5), + [98] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_code_location, 3), + [100] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_code_location, 3), + [102] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__instruction_and_location, 3), + [104] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__instruction_and_location, 3), + [106] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comment, 2), + [108] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_comment, 2), + [110] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_label_line, 2), + [112] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_label_line, 2), + [114] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__instruction_and_comment, 2), + [116] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__instruction_and_comment, 2), + [118] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_discriminator, 4), + [120] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_discriminator, 4), + [122] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_header, 5), + [124] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_header, 5), + [126] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_disassembly_section_label, 3), + [128] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_disassembly_section_label, 3), + [130] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_offset, 5), + [132] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_memory_offset, 5), + [134] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_memory_offset, 4), + [136] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_memory_offset, 4), + [138] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__comment_with_label, 3), + [140] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__comment_with_label, 3), + [142] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_location, 4), + [144] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_source_location, 4), + [146] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), + [148] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), + [150] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_machine_code_bytes_repeat1, 2), + [152] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_machine_code_bytes_repeat1, 2), SHIFT_REPEAT(51), + [155] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_machine_code_bytes_repeat1, 2), + [157] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_machine_code_bytes, 1), + [159] = {.entry = {.count = 1, .reusable = false}}, SHIFT(51), + [161] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_machine_code_bytes, 1), + [163] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_machine_code_bytes, 2), + [165] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_machine_code_bytes, 2), + [167] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [169] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [171] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58), + [173] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [175] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), + [177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), + [179] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), + [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), + [185] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), + [187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), + [189] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), + [191] = {.entry = {.count = 1, .reusable = true}}, SHIFT(49), + [193] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), + [195] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [197] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), + [199] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [201] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), + [203] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [205] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), + [207] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [209] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), + [211] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), + [213] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), + [215] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), + [217] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [219] = {.entry = {.count = 1, .reusable = true}}, SHIFT(61), + [221] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [223] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), + [225] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [227] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), +}; + +#ifdef __cplusplus +extern "C" { +#endif +void *tree_sitter_objdump_external_scanner_create(void); +void tree_sitter_objdump_external_scanner_destroy(void *); +bool tree_sitter_objdump_external_scanner_scan(void *, TSLexer *, const bool *); +unsigned tree_sitter_objdump_external_scanner_serialize(void *, char *); +void tree_sitter_objdump_external_scanner_deserialize(void *, const char *, unsigned); + +#ifdef _WIN32 +#define extern __declspec(dllexport) +#endif + +extern const TSLanguage *tree_sitter_objdump(void) { + static const TSLanguage language = { + .version = LANGUAGE_VERSION, + .symbol_count = SYMBOL_COUNT, + .alias_count = ALIAS_COUNT, + .token_count = TOKEN_COUNT, + .external_token_count = EXTERNAL_TOKEN_COUNT, + .state_count = STATE_COUNT, + .large_state_count = LARGE_STATE_COUNT, + .production_id_count = PRODUCTION_ID_COUNT, + .field_count = FIELD_COUNT, + .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, + .parse_table = &ts_parse_table[0][0], + .small_parse_table = ts_small_parse_table, + .small_parse_table_map = ts_small_parse_table_map, + .parse_actions = ts_parse_actions, + .symbol_names = ts_symbol_names, + .symbol_metadata = ts_symbol_metadata, + .public_symbol_map = ts_symbol_map, + .alias_map = ts_non_terminal_alias_map, + .alias_sequences = &ts_alias_sequences[0][0], + .lex_modes = ts_lex_modes, + .lex_fn = ts_lex, + .external_scanner = { + &ts_external_scanner_states[0][0], + ts_external_scanner_symbol_map, + tree_sitter_objdump_external_scanner_create, + tree_sitter_objdump_external_scanner_destroy, + tree_sitter_objdump_external_scanner_scan, + tree_sitter_objdump_external_scanner_serialize, + tree_sitter_objdump_external_scanner_deserialize, + }, + .primary_state_ids = ts_primary_state_ids, + }; + return &language; +} +#ifdef __cplusplus +} +#endif diff --git a/src/scanner.cc b/src/scanner.cc new file mode 100644 index 0000000..9ab2845 --- /dev/null +++ b/src/scanner.cc @@ -0,0 +1,235 @@ +#include + +#include +#include + +enum TokenType { + CODE_IDENTIFIER, + ASSEMBLY_INSTRUCTION, + WHITESPACE_NO_NEWLINE, +}; + +extern "C" { + +bool is_hexadecimal_character(char character) +{ + switch (character) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'h': + case 'x': + return true; + default: + return false; + } +} + +void* tree_sitter_objdump_external_scanner_create() {} + + +void tree_sitter_objdump_external_scanner_deserialize( + void *payload, + const char *buffer, + unsigned length +) +{ +} + + +void tree_sitter_objdump_external_scanner_destroy(void *payload) {} + + +bool tree_sitter_objdump_external_scanner_scan( + void *payload, + TSLexer *lexer, + const bool *valid_symbols +) +{ + bool has_text = false; + + if (valid_symbols[ASSEMBLY_INSTRUCTION]) + { + while (true) + { + if (lexer->eof(lexer)) + { + return has_text; + } + + switch (lexer->lookahead) + { + case '\n': + case '<': + case '#': + lexer->result_symbol = ASSEMBLY_INSTRUCTION; + lexer->mark_end(lexer); + + return has_text; + case ' ': + case '\t': + break; + default: + has_text = true; + }; + + lexer->advance(lexer, false); + } + + return has_text; + } + + if (valid_symbols[WHITESPACE_NO_NEWLINE]) + { + while (true) + { + if (lexer->eof(lexer)) + { + return has_text; + } + + switch (lexer->lookahead) + { + case '\n': + return true; + case ' ': + case '\t': + has_text = true; + lexer->result_symbol = WHITESPACE_NO_NEWLINE; + lexer->mark_end(lexer); + + break; + default: + return false; + }; + + lexer->advance(lexer, false); + } + } + + + unsigned int offset_counter = -1; + bool has_hexadecimal_data = false; + bool possibly_in_next_hexadecimal_token = false; + bool possibly_in_next_file_offset_token = false; + char next_token_text[] = "(FileOffset:"; + unsigned int const size = (sizeof(next_token_text) / sizeof(char) - 1); + + while (true) + { + lexer->advance(lexer, false); + + if (lexer->lookahead == '\n' || lexer->eof(lexer)) { + lexer->result_symbol = CODE_IDENTIFIER; + + return true; + } + + if (lexer->lookahead != '\n' && std::iswspace(lexer->lookahead)) + { + // We could be in the token or just having exited it. Just keep trying + continue; + } + + if (possibly_in_next_hexadecimal_token) + { + if (is_hexadecimal_character(lexer->lookahead)) + { + has_hexadecimal_data = true; + } + else + { + // Reached the end of the (possibly) hexadecimal data + possibly_in_next_hexadecimal_token = false; + } + } + + has_text = true; + + if (!possibly_in_next_file_offset_token) + { + if (lexer->lookahead == '(') + { + possibly_in_next_file_offset_token = true; + ++offset_counter; + + continue; + } + } + else if (lexer->lookahead == next_token_text[offset_counter]) + { + if (offset_counter + 1 >= size) + { + lexer->result_symbol = CODE_IDENTIFIER; + + return true; + } + + ++offset_counter; + + continue; + } + else + { + possibly_in_next_file_offset_token = false; + + continue; + } + + switch (lexer->lookahead) + { + case '\n': + // The end of the token wasn't found so it cannot be a code identifier + return false; + case '>': + if (!has_hexadecimal_data && !possibly_in_next_hexadecimal_token) + { + // We might have reached the end. Or it could be some kind of + // C++ operator>>() signature. Not sure which, just yet + // + lexer->mark_end(lexer); + } + + break; + case '+': + // We might have reached the end. Or it could be some kind of + // C++ operator+() signature. Not sure which, just yet + // + lexer->mark_end(lexer); + + possibly_in_next_hexadecimal_token = true; + + break; + } + } + + return has_text; +} + + +unsigned tree_sitter_objdump_external_scanner_serialize(void *payload, char *buffer) +{ + return 0; +} + +} diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h new file mode 100644 index 0000000..2b14ac1 --- /dev/null +++ b/src/tree_sitter/parser.h @@ -0,0 +1,224 @@ +#ifndef TREE_SITTER_PARSER_H_ +#define TREE_SITTER_PARSER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define ts_builtin_sym_error ((TSSymbol)-1) +#define ts_builtin_sym_end 0 +#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 + +typedef uint16_t TSStateId; + +#ifndef TREE_SITTER_API_H_ +typedef uint16_t TSSymbol; +typedef uint16_t TSFieldId; +typedef struct TSLanguage TSLanguage; +#endif + +typedef struct { + TSFieldId field_id; + uint8_t child_index; + bool inherited; +} TSFieldMapEntry; + +typedef struct { + uint16_t index; + uint16_t length; +} TSFieldMapSlice; + +typedef struct { + bool visible; + bool named; + bool supertype; +} TSSymbolMetadata; + +typedef struct TSLexer TSLexer; + +struct TSLexer { + int32_t lookahead; + TSSymbol result_symbol; + void (*advance)(TSLexer *, bool); + void (*mark_end)(TSLexer *); + uint32_t (*get_column)(TSLexer *); + bool (*is_at_included_range_start)(const TSLexer *); + bool (*eof)(const TSLexer *); +}; + +typedef enum { + TSParseActionTypeShift, + TSParseActionTypeReduce, + TSParseActionTypeAccept, + TSParseActionTypeRecover, +} TSParseActionType; + +typedef union { + struct { + uint8_t type; + TSStateId state; + bool extra; + bool repetition; + } shift; + struct { + uint8_t type; + uint8_t child_count; + TSSymbol symbol; + int16_t dynamic_precedence; + uint16_t production_id; + } reduce; + uint8_t type; +} TSParseAction; + +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; +} TSLexMode; + +typedef union { + TSParseAction action; + struct { + uint8_t count; + bool reusable; + } entry; +} TSParseActionEntry; + +struct TSLanguage { + uint32_t version; + uint32_t symbol_count; + uint32_t alias_count; + uint32_t token_count; + uint32_t external_token_count; + uint32_t state_count; + uint32_t large_state_count; + uint32_t production_id_count; + uint32_t field_count; + uint16_t max_alias_sequence_length; + const uint16_t *parse_table; + const uint16_t *small_parse_table; + const uint32_t *small_parse_table_map; + const TSParseActionEntry *parse_actions; + const char * const *symbol_names; + const char * const *field_names; + const TSFieldMapSlice *field_map_slices; + const TSFieldMapEntry *field_map_entries; + const TSSymbolMetadata *symbol_metadata; + const TSSymbol *public_symbol_map; + const uint16_t *alias_map; + const TSSymbol *alias_sequences; + const TSLexMode *lex_modes; + bool (*lex_fn)(TSLexer *, TSStateId); + bool (*keyword_lex_fn)(TSLexer *, TSStateId); + TSSymbol keyword_capture_token; + struct { + const bool *states; + const TSSymbol *symbol_map; + void *(*create)(void); + void (*destroy)(void *); + bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); + unsigned (*serialize)(void *, char *); + void (*deserialize)(void *, const char *, unsigned); + } external_scanner; + const TSStateId *primary_state_ids; +}; + +/* + * Lexer Macros + */ + +#define START_LEXER() \ + bool result = false; \ + bool skip = false; \ + bool eof = false; \ + int32_t lookahead; \ + goto start; \ + next_state: \ + lexer->advance(lexer, skip); \ + start: \ + skip = false; \ + lookahead = lexer->lookahead; + +#define ADVANCE(state_value) \ + { \ + state = state_value; \ + goto next_state; \ + } + +#define SKIP(state_value) \ + { \ + skip = true; \ + state = state_value; \ + goto next_state; \ + } + +#define ACCEPT_TOKEN(symbol_value) \ + result = true; \ + lexer->result_symbol = symbol_value; \ + lexer->mark_end(lexer); + +#define END_STATE() return result; + +/* + * Parse Table Macros + */ + +#define SMALL_STATE(id) id - LARGE_STATE_COUNT + +#define STATE(id) id + +#define ACTIONS(id) id + +#define SHIFT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = state_value \ + } \ + }} + +#define SHIFT_REPEAT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = state_value, \ + .repetition = true \ + } \ + }} + +#define SHIFT_EXTRA() \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .extra = true \ + } \ + }} + +#define REDUCE(symbol_val, child_count_val, ...) \ + {{ \ + .reduce = { \ + .type = TSParseActionTypeReduce, \ + .symbol = symbol_val, \ + .child_count = child_count_val, \ + __VA_ARGS__ \ + }, \ + }} + +#define RECOVER() \ + {{ \ + .type = TSParseActionTypeRecover \ + }} + +#define ACCEPT_INPUT() \ + {{ \ + .type = TSParseActionTypeAccept \ + }} + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_PARSER_H_ diff --git a/test/corpus/comment.txt b/test/corpus/comment.txt new file mode 100644 index 0000000..d4e36dd --- /dev/null +++ b/test/corpus/comment.txt @@ -0,0 +1,59 @@ +================================================================================ +Inline Comment +================================================================================ + +0000000000400d60 : + 40112c: 48 39 1d 55 06 0c 00 cmp QWORD PTR [rip+0xc0655],rbx # 0x4c1788 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte) + (byte) + (byte)) + (instruction) + (comment + (hexadecimal))))) + + +================================================================================ +Comment With Address Information +================================================================================ + +0000000000400d60 : + 129: 48 8d 3d 00 00 00 00 lea rdi,[rip+0x0] # 130 >::_M_realloc_insert(__gnu_cxx::__normal_iterator > >, engine::entity::Entity const&)+0x130> (File Offset: 0x40c) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte) + (byte) + (byte)) + (instruction) + (comment + (address) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal)))))) diff --git a/test/corpus/header.txt b/test/corpus/header.txt new file mode 100644 index 0000000..b8a1bfb --- /dev/null +++ b/test/corpus/header.txt @@ -0,0 +1,16 @@ +================================================================================ +Normal Header +================================================================================ + +/home/foo/things/blah_engine.dir/lib/world.cpp.o: file format elf64-x86-64 +/home/foo/things/blah_engine.dir////lib/world.cpp.o: file format elf64-x86-64 + +-------------------------------------------------------------------------------- + +(source + (header + (file_path) + (identifier)) + (header + (file_path) + (identifier))) diff --git a/test/corpus/path.txt b/test/corpus/path.txt new file mode 100644 index 0000000..e2ed24b --- /dev/null +++ b/test/corpus/path.txt @@ -0,0 +1,64 @@ +================================================================================ +Relative Path Bug Fix +================================================================================ + +0000000000400530 : +_Z1av(): +./a.cpp:1 + 400530: 55 push rbp + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte)) + (instruction)))) + + +================================================================================ +Implicit Relative Path Bug Fix +================================================================================ + +00000000004005c0 : +_Z2f1v(): +Output/split-dwarf-test.cc:1 + 4005c0: 55 push rbp + 4005c1: 48 89 e5 mov rbp,rsp +Output/split-dwarf-test.cc:2 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte)) + (instruction)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)) + (source_location + (file_path) + (integer)))) diff --git a/test/corpus/sample.txt b/test/corpus/sample.txt new file mode 100644 index 0000000..75679c6 --- /dev/null +++ b/test/corpus/sample.txt @@ -0,0 +1,216 @@ +================================================================================ +Example, Simple +================================================================================ + +/home/selecaoone/repositories/jumpy/engine/build/src/CMakeFiles/jumpy_engine.dir/lib/world.cpp.o: file format elf64-x86-64 + + +0000000000000000 (File Offset: 0x70): +_ZN6engine5world5World12createEntityEv(): +/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:14 + 0: 48 89 f8 mov rax,rdi +_ZNKSt15__uniq_ptr_implIN6engine13entityManager13EntityManagerESt14default_deleteIS2_EE6_M_ptrEv(): +/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:154 + 3: 48 8b 4f 40 mov rcx,QWORD PTR [rdi+0x40] +_ZN6engine13entityManager13EntityManager12getNextIndexEv(): +/home/selecaoone/repositories/jumpy/engine/src/include/jumpy_engine/entityManager.h:15 + 7: 8b 31 mov esi,DWORD PTR [rcx] + 9: 8d 56 01 lea edx,[rsi+0x1] + +-------------------------------------------------------------------------------- + +(source + (header + (file_path) + (identifier)) + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte)) + (instruction)) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Multi-Hexadecimal Instruction Line +================================================================================ + +0000000000000000 (File Offset: 0x70): + 70: f2 0f 11 44 24 08 movsd QWORD PTR [rsp+0x8],xmm0 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Instruction With Only Two Letters Bug-Fix +================================================================================ + +0000000000000000 (File Offset: 0x70): + 23: 74 12 je 37 (File Offset: 0xa7) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))))) + + +================================================================================ +Concise Whitespace Between Bytes And Instructions +================================================================================ + +0000000000000000 (File Offset: 0x70): + 40031a: 69 62 36 34 2f 6c 64 imul esp,DWORD PTR [rdx+0x36],0x646c2f34 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Templated C++ Code Location +================================================================================ + + +0000000000000000 (File Offset: 0x70): + 409f80: ff 25 ba 11 24 00 jmp QWORD PTR [rip+0x2411ba] # 64b140 , QMessageBox::StandardButton)@Qt_5> + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte) + (byte)) + (instruction) + (comment + (address) + (code_location + (identifier)))))) + + +================================================================================ +Instruction With + Sign +================================================================================ + +0000000000000000 (File Offset: 0x70): + 23: 74 12 je 37 (File Offset: 0xa7) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))))) diff --git a/test/corpus/scan.txt b/test/corpus/scan.txt new file mode 100644 index 0000000..95aed8a --- /dev/null +++ b/test/corpus/scan.txt @@ -0,0 +1,130 @@ +================================================================================ +C++ Code Location Permutations +================================================================================ + +0000000000000000 (File Offset: 0x70): + 23: 74 12 je 37 (File Offset: 0xa7) + 23: 74 12 je 37 + 23: 74 12 je 37 + 23: 74 12 je 37 + 23: 74 12 je 37 + 23: 74 12 je 37 + 23: 74 12 je 37 (File Offset: 0xa7) + 23: 74 12 je 37 (File Offset: 0xa7) + 23: 74 12 je 37 (File Offset: 0xa7) + 23: 74 12 je 37 (File Offset: 0xa7) + 23: 74 12 je 37 (File Offset: 0xa7) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier)) + (file_offset + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier)) + (file_offset + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier)) + (file_offset + (hexadecimal))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))))) diff --git a/test/corpus/sections.txt b/test/corpus/sections.txt new file mode 100644 index 0000000..0b8213e --- /dev/null +++ b/test/corpus/sections.txt @@ -0,0 +1,399 @@ +================================================================================ +Disassembly Section Label +================================================================================ + +Disassembly of section .text: + +0000000000000000 (File Offset: 0x70): + 0: 41 55 push r13 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section_label + (section_name)) + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Disassembly Section With Complex Labels +================================================================================ + +0000000000000000 (File Offset: 0x70): + 0: 48 89 f8 mov rax,rdi +00000000000000a2 >)> (File Offset: 0x112): + 0: 48 89 f8 mov rax,rdi + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction))) + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Disassembly @ Section +================================================================================ + +0000000000400d60 : + 0: 41 55 push r13 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Discriminator Source Location +================================================================================ + + +0000000000400d60 : +/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:48 (discriminator 3) + 1f0: 48 83 c3 08 add rbx,0x8 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (source_location + (file_path) + (integer) + (discriminator + (integer))) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +File Offset +================================================================================ + +0000000000400d60 : + 23: 74 12 je 37 (File Offset: 0xa7) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))))) + + +================================================================================ +Abnormal Instruction Ending +================================================================================ + +0000000000000000 (File Offset: 0x70): + 4c: 48 39 eb cmp rbx,rbp # ffffffffa0400635 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction) + (comment + (address) + (code_location + (identifier) + (hexadecimal)))))) + + +================================================================================ +Instruction, Location, And Offset +================================================================================ + +0000000000400d60 : + 23: 74 12 je 37 (File Offset: 0xa7) + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction) + (code_location + (identifier) + (hexadecimal)) + (file_offset + (hexadecimal))))) + + +================================================================================ +Disassembly Section And Code Simple +================================================================================ + +0000000000000000 (File Offset: 0x70): + 0: 48 89 f8 mov rax,rdi + 3: 48 8b 4f 40 mov rcx,QWORD PTR [rdi+0x40] + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Disassembly Section And Code With Labels And Instructions +================================================================================ + +Disassembly of section .text: + +0000000000000000 (File Offset: 0x70): +_ZN6engine5world5World12createEntityEv(): +/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:14 + 0: 48 89 f8 mov rax,rdi +_ZNKSt15__uniq_ptr_implIN6engine13entityManager13EntityManagerESt14default_deleteIS2_EE6_M_ptrEv(): +/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:154 + 3: 48 8b 4f 40 mov rcx,QWORD PTR [rdi+0x40] + +-------------------------------------------------------------------------------- + +(source + (disassembly_section_label + (section_name)) + (disassembly_section + (section_address) + (identifier) + (file_offset + (hexadecimal)) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte)) + (instruction)) + (label_line + (label)) + (source_location + (file_path) + (integer)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte)) + (instruction)))) + + +================================================================================ +Empty Assembly Instruction, Single Sections +================================================================================ + +Disassembly of section .interp: + +0000000000400238 <.interp>: + 4004ff: 00 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section_label + (section_name)) + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte))))) + + +================================================================================ +Empty Assembly Instruction, Multiple Sections +================================================================================ + + 0000000000400540 <__do_global_dtors_aux>: + 4005ab: 00 00 00 00 00 + + 00000000004005b0 : + 4005b0: 55 push rbp + +-------------------------------------------------------------------------------- + +(source + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte) + (byte) + (byte) + (byte)))) + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte)) + (instruction)))) + + +================================================================================ +Empty Assembly Instruction, Infixed With Other Instructions +================================================================================ + +Disassembly of section .debug_line: + +0000000000000000 <.debug_line>: + + 3d: 01 + 3e: 01 .byte 0x1 + +-------------------------------------------------------------------------------- + +(source + (disassembly_section_label + (section_name)) + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte))) + (memory_offset + (address) + (machine_code_bytes + (byte)) + (instruction)))) + + + +================================================================================ +Empty Assembly Instruction, EOF +================================================================================ + +Disassembly of section .debug_line: + +0000000000000000 <.debug_line>: + 60d1e6: 00 00 add BYTE PTR [rax],al + 60d1e8: 00 00 add + +-------------------------------------------------------------------------------- + +(source + (disassembly_section_label + (section_name)) + (disassembly_section + (section_address) + (identifier) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction)) + (memory_offset + (address) + (machine_code_bytes + (byte) + (byte)) + (instruction)))) diff --git a/test/highlight/header.objdump b/test/highlight/header.objdump new file mode 100644 index 0000000..03885ff --- /dev/null +++ b/test/highlight/header.objdump @@ -0,0 +1,5 @@ +/home/foo/things/blah_engine.dir/lib/world.cpp.o: file format elf64-x86-64 +# <- string +/home/foo/things/blah_engine.dir////lib/world.cpp.o: file format elf64-x86-64 +# <- string +# ^ namespace diff --git a/test/highlight/sample.objdump b/test/highlight/sample.objdump new file mode 100644 index 0000000..f69b191 --- /dev/null +++ b/test/highlight/sample.objdump @@ -0,0 +1,26 @@ +0000000000000000 (File Offset: 0x70): +# <- number +# ^ namespace +# ^ number + +_ZN6engine5world5World12createEntityEv(): +# <- label + +/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:14 +# <- string +# ^ number + + 0: 48 89 f8 mov rax,rdi + # <- number + # ^ field + # ^ field + +_ZNKSt15__uniq_ptr_implIN6engine13entityManager13EntityManagerESt14default_deleteIS2_EE6_M_ptrEv(): +# <- label +# ^ label + + 23: 74 12 je 37 (File Offset: 0xa7) + # <- number + # ^ constant + # ^ text + # ^ field diff --git a/test/highlight/sections.objdump b/test/highlight/sections.objdump new file mode 100644 index 0000000..673c5aa --- /dev/null +++ b/test/highlight/sections.objdump @@ -0,0 +1,34 @@ +Disassembly of section .text: +# <- text.title + +Disassembly of section .text._ZNSt6vectorIN6engine6entity6EntityESaIS2_EE17_M_realloc_insertIJRKS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_: +# <- text.title +# ^ namespace +# ^ namespace + +0000000000000000 (File Offset: 0x70): +# <- number +# ^ namespace +# ^ field +# ^ number + +00000000000000a2 >)> (File Offset: 0x112): +# <- number +# ^ namespace + +/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:48 (discriminator 3) +# <- string +# ^ number +# ^ field +# ^ number + +1f0: 48 83 c3 08 add rbx,0x8 +# <- number +# ^ constant +# ^ constant +# ^ constant + +23: 74 12 je 37 (File Offset: 0xa7) +# <- number +# ^ constant +# ^ punctuation.special