From c7239b2906abb48110e3d41a18e94810af8ab915 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 22 Jan 2026 01:44:22 +0100 Subject: Add JavaScript grammar --- queries/javascript.h | 28 ++++++++++++++++++++++++++++ queries/javascript.scm | 12 ++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 queries/javascript.h create mode 100644 queries/javascript.scm (limited to 'queries') diff --git a/queries/javascript.h b/queries/javascript.h new file mode 100644 index 0000000..81152e3 --- /dev/null +++ b/queries/javascript.h @@ -0,0 +1,28 @@ +unsigned char query_javascript[] = { + 0x28, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65, + 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, + 0x22, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x20, 0x40, + 0x66, 0x74, 0x79, 0x70, 0x65, 0x0a, 0x20, 0x20, 0x6e, 0x61, 0x6d, 0x65, + 0x3a, 0x20, 0x28, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x29, 0x20, 0x40, 0x66, 0x6e, 0x61, 0x6d, 0x65, 0x0a, 0x20, 0x20, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x3a, 0x20, + 0x28, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x5f, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x29, 0x20, 0x40, 0x66, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x29, 0x0a, 0x0a, 0x28, 0x6d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x0a, 0x20, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x20, 0x5b, 0x28, + 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x29, 0x20, 0x28, 0x69, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x29, 0x5d, 0x20, 0x40, + 0x66, 0x6e, 0x61, 0x6d, 0x65, 0x0a, 0x20, 0x20, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x3a, 0x20, 0x28, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x6c, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x73, 0x29, 0x20, 0x40, 0x66, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x29, 0x0a, 0x0a, 0x28, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x5f, 0x64, 0x65, + 0x63, 0x6c, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, + 0x22, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x20, 0x40, 0x66, 0x74, 0x79, + 0x70, 0x65, 0x0a, 0x20, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x20, 0x28, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x29, 0x20, + 0x40, 0x66, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a +}; +unsigned int query_javascript_len = 296; diff --git a/queries/javascript.scm b/queries/javascript.scm new file mode 100644 index 0000000..fb0b755 --- /dev/null +++ b/queries/javascript.scm @@ -0,0 +1,12 @@ +(function_declaration + "function" @ftype + name: (identifier) @fname + parameters: (formal_parameters) @fparams) + +(method_definition + name: [(property_identifier) (identifier)] @fname + parameters: (formal_parameters) @fparams) + +(class_declaration + "class" @ftype + name: (identifier) @fname) -- cgit v1.2.3