Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scope-queries for cobol #1196

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/bleep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev
tree-sitter-ruby = "0.20.0"
tree-sitter-r = "0.19.5"
tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php" }
tree-sitter-COBOL = { git = "https://github.com/nerdypepper/tree-sitter-cobol" }
petgraph = { version = "0.6.4", default-features = false, features = ["serde-1"] }

# webserver
Expand Down
2 changes: 2 additions & 0 deletions server/bleep/src/intelligence/language.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod c;
mod c_sharp;
mod cobol;
mod cpp;
mod go;
mod java;
Expand Down Expand Up @@ -32,6 +33,7 @@ pub static ALL_LANGUAGES: &[&TSLanguageConfig] = &[
&ruby::RUBY,
&r::R,
&php::PHP,
&cobol::COBOL,
];

/// A generic language wrapper type.
Expand Down
16 changes: 16 additions & 0 deletions server/bleep/src/intelligence/language/cobol/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::intelligence::{MemoizedQuery, TSLanguageConfig};

pub static COBOL: TSLanguageConfig = TSLanguageConfig {
language_ids: &["COBOL"],
file_extensions: &["cbl", "cpy", "cob", "ccp", "cobol"],
grammar: tree_sitter_COBOL::language,
scope_query: MemoizedQuery::new(include_str!("./scopes.scm")),
hoverable_query: MemoizedQuery::new(
r"
[(program_name)
(entry_name)
(WORD)] @hoverable
",
),
namespaces: &[&["program", "file", "data", "paragraph"]],
};
273 changes: 273 additions & 0 deletions server/bleep/src/intelligence/language/cobol/scopes.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
;; there are no scopes to a cobol program

(program_name) @local.definition.program

;; defs
(file_description
(file_description_entry
(WORD) @local.definition.file))
(data_description
(entry_name) @local.definition.data)
(paragraph_header
name: (_) @local.definition.paragraph)

;; refs
(select_statement
file_name: (_) @local.reference)
(select_statement
(assign_clause
to: (qualified_word
(WORD) @local.reference)))

(copy_statement
book: (_) @local.reference)

(record_key_clause
reference: (qualified_word
(WORD) @local.reference))

(file_status_clause
reference: (qualified_word
(WORD) @local.reference))

(read_statement
file_name: (_) @local.reference)

(read_statement
into: (qualified_word
(WORD) @local.reference))

(release_statement
record: (qualified_word
(WORD) @local.reference))

(release_statement
from: (qualified_word
(WORD) @local.reference))

(return_statement
file_name: (WORD) @local.reference)

(return_statement
into: (qualified_word
(WORD) @local.reference))

(rewrite_statement
record: (qualified_word
(WORD) @local.reference)
from: (qualified_word
(WORD) @local.reference))

(search_statement
table_name: (qualified_word
(WORD) @local.reference))

(search_statement
varying: (qualified_word
(WORD) @local.reference))

(set_statement
(set_environment
(qualified_word
(WORD) @local.reference)))

(set_statement
(set_to
(qualified_word
(WORD) @local.reference)))

(set_statement
(set_up_down
(qualified_word
(WORD) @local.reference)))

(move_statement
(qualified_word
(WORD) @local.reference))

(perform_statement_call_proc
procedure: (perform_procedure
(label
(qualified_word
(WORD) @local.reference))))

(display_statement
(qualified_word
(WORD) @local.reference))

(accept_statement
(qualified_word
(WORD) @local.reference))

(add_statement
(qualified_word
(WORD) @local.reference))

(multiply_statement
(qualified_word
(WORD) @local.reference))

(subtract_statement
(qualified_word
(WORD) @local.reference))

(allocate_statement
x: (WORD) @local.reference)

(allocate_statement
returning: (qualified_word
(WORD) @local.reference))

(alter_statement
(alter_option
proc_name: (qualified_word
(WORD) @local.reference)))

(alter_statement
(alter_option
to: (qualified_word
(WORD) @local.reference)))

(call_statement
x: (qualified_word
(WORD) @local.reference))

;; todo GIVING FOO returns
(call_statement
returning: (qualified_word
(WORD) @local.reference))

(call_param_arg
(qualified_word
(WORD) @local.reference))

(cancel_statement
(qualified_word
(WORD) @local.reference))

(close_statement
(close_arg
(WORD) @local.reference))

(delete_statement
file_name: (_) @local.reference)

(divide_statement
x: (qualified_word
(WORD) @local.reference))

(goto_statement
to: (label
(qualified_word
(WORD) @local.reference)))

(initialize_statement
(qualified_word
(WORD) @local.reference))

(inspect_statement
send: (qualified_word
(WORD) @local.reference))

(inspect_converting
(qualified_word
(WORD) @local.reference))

(inspect_tallying
(qualified_word
(WORD) @local.reference))

(inspect_replacing
(replacing_item
(replacing_region
(qualified_word
(WORD) @local.reference))))

(merge_statement
x: (qualified_word
(WORD) @local.reference))

(merge_statement
collating: (qualified_word
(WORD) @local.reference))

(merge_statement
output: (sort_output_giving
(WORD) @local.reference))

(merge_statement
output: (sort_output_procedure
(perform_procedure
(label
(qualified_word
(WORD) @local.reference)))))

(start_statement
file_name: (WORD) @local.reference)

(sort_key
key_list: (qualified_word
(WORD) @local.reference))

; todo call this key list
(start_key
keys: (qualified_word
(WORD) @local.reference))

(stop_statement
(qualified_word
(WORD) @local.reference))

(string_statement
(qualified_word
(WORD) @local.reference))

(unstring_statement
(qualified_word
(WORD) @local.reference))

(string_statement
(string_item
(qualified_word
(WORD) @local.reference)))

(unstring_statement
(unstring_delimited
(unstring_delimited_item
(qualified_word
(WORD) @local.reference))))

(unstring_statement
(unstring_into_item
(qualified_word
(WORD) @local.reference)))

(use_statement
(WORD) @local.reference)

(use_statement
(qualified_word
(WORD) @local.reference))

(write_statement
(qualified_word
(WORD) @local.reference))

(use_statement
(label
(qualified_word
(WORD) @local.reference)))

(open_statement
(open_arg
(WORD) @local.reference))

(expr
(qualified_word
(WORD) @local.reference))

(arithmetic_x
(qualified_word
(WORD) @local.reference))