Skip to content

Commit

Permalink
add support for SurrealQL, #878
Browse files Browse the repository at this point in the history
  • Loading branch information
AlDanial committed Jan 7, 2025
1 parent fce9df6 commit 059f638
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 52 deletions.
65 changes: 39 additions & 26 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -9322,6 +9322,7 @@ sub set_constants { # {{{1
'rules' => 'Snakemake' ,
'smk' => 'Snakemake' ,
'styl' => 'Stylus' ,
'surql' => 'SurrealQL' ,
'i' => 'SWIG' ,
'svelte' => 'Svelte' ,
'sv' => 'Verilog-SystemVerilog' ,
Expand Down Expand Up @@ -9769,6 +9770,15 @@ sub set_constants { # {{{1
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
'BizTalk Pipeline' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'BizTalk Orchestration' => [
[ 'remove_matches' , '^\s*#' ],
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'Blade' => [
[ 'remove_between_general', '{{--', '--}}' ],
[ 'remove_html_comments', ],
Expand Down Expand Up @@ -10907,28 +10917,19 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*;' ],
],
'Squirrel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
'Smalltalk' => [
[ 'call_regexp_common' , 'Smalltalk' ],
],
'Starlark' => [
'Smarty' => [
[ 'smarty_to_C' ],
[ 'call_regexp_common' , 'C' ],
],
'Snakemake' => [
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
],
'BizTalk Pipeline' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'BizTalk Orchestration' => [
[ 'remove_matches' , '^\s*#' ],
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'Solidity' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
Expand All @@ -10948,6 +10949,19 @@ sub set_constants { # {{{1
[ 'rm_last_line' , ], # undo pre_post_fix addition
# of trailing line of just <'
],
'Squirrel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
'Starlark' => [
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
],
'SQL' => [
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*--' ],
Expand All @@ -10963,18 +10977,16 @@ sub set_constants { # {{{1
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Smalltalk' => [
[ 'call_regexp_common' , 'Smalltalk' ],
],
'Smarty' => [
[ 'smarty_to_C' ],
[ 'call_regexp_common' , 'C' ],
],
'Snakemake' => [
'SurrealQL' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'rm_comments_in_strings', '"', '--', '' ],
[ 'rm_comments_in_strings', '"', '#', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Standard ML' => [
[ 'remove_between_general', '(*', '*)' ],
Expand Down Expand Up @@ -11844,6 +11856,7 @@ sub set_constants { # {{{1
'Stata' => 3.00,
'Stylus' => 1.48,
'SugarSS' => 2.50,
'SurrealQL' => 2.50,
'Svelte' => 2.00,
'SVG' => 1.00,
'Swift' => 2.50,
Expand Down
5 changes: 5 additions & 0 deletions Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,11 @@ my @Tests = (
'ref' => '../tests/outputs/rules.sss.yaml',
'args' => '../tests/inputs/rules.sss',
},
{
'name' => 'SurrealQL',
'ref' => '../tests/outputs/ranges.surql.yaml',
'args' => '../tests/inputs/ranges.surql',
},
{
'name' => 'Svelte',
'ref' => '../tests/outputs/reactive.svelte.yaml',
Expand Down
65 changes: 39 additions & 26 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -9312,6 +9312,7 @@ sub set_constants { # {{{1
'rules' => 'Snakemake' ,
'smk' => 'Snakemake' ,
'styl' => 'Stylus' ,
'surql' => 'SurrealQL' ,
'i' => 'SWIG' ,
'svelte' => 'Svelte' ,
'sv' => 'Verilog-SystemVerilog' ,
Expand Down Expand Up @@ -9759,6 +9760,15 @@ sub set_constants { # {{{1
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
'BizTalk Pipeline' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'BizTalk Orchestration' => [
[ 'remove_matches' , '^\s*#' ],
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'Blade' => [
[ 'remove_between_general', '{{--', '--}}' ],
[ 'remove_html_comments', ],
Expand Down Expand Up @@ -10897,28 +10907,19 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*;' ],
],
'Squirrel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
'Smalltalk' => [
[ 'call_regexp_common' , 'Smalltalk' ],
],
'Starlark' => [
'Smarty' => [
[ 'smarty_to_C' ],
[ 'call_regexp_common' , 'C' ],
],
'Snakemake' => [
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
],
'BizTalk Pipeline' => [
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'BizTalk Orchestration' => [
[ 'remove_matches' , '^\s*#' ],
[ 'remove_html_comments', ],
[ 'call_regexp_common' , 'HTML' ],
],
'Solidity' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
Expand All @@ -10938,6 +10939,19 @@ sub set_constants { # {{{1
[ 'rm_last_line' , ], # undo pre_post_fix addition
# of trailing line of just <'
],
'Squirrel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'remove_inline' , '#.*$' ],
],
'Starlark' => [
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
],
'SQL' => [
[ 'call_regexp_common' , 'C' ],
[ 'remove_matches' , '^\s*--' ],
Expand All @@ -10953,18 +10967,16 @@ sub set_constants { # {{{1
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Smalltalk' => [
[ 'call_regexp_common' , 'Smalltalk' ],
],
'Smarty' => [
[ 'smarty_to_C' ],
[ 'call_regexp_common' , 'C' ],
],
'Snakemake' => [
'SurrealQL' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'rm_comments_in_strings', '"', '--', '' ],
[ 'rm_comments_in_strings', '"', '#', '' ],
[ 'call_regexp_common' , 'C++' ],
[ 'remove_matches' , '^\s*#' ],
[ 'docstring_to_C' ],
[ 'call_regexp_common' , 'C' ],
[ 'remove_inline' , '#.*$' ],
[ 'remove_matches' , '^\s*--' ],
[ 'remove_inline' , '--.*$' ],
],
'Standard ML' => [
[ 'remove_between_general', '(*', '*)' ],
Expand Down Expand Up @@ -11834,6 +11846,7 @@ sub set_constants { # {{{1
'Stata' => 3.00,
'Stylus' => 1.48,
'SugarSS' => 2.50,
'SurrealQL' => 2.50,
'Svelte' => 2.00,
'SVG' => 1.00,
'Swift' => 2.50,
Expand Down
13 changes: 13 additions & 0 deletions tests/inputs/ranges.surql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
https://surrealdb.com/docs/surrealql/statements/select#example-usage
*/
-- Select all person records with IDs between the given range
SELECT * FROM person:1..1000;
# Select all records for a particular location, inclusive
SELECT * FROM temperature:['London', NONE]..=['London', time::now()];
-- Select all temperature records with IDs less than a maximum value
SELECT * FROM temperature:..['London', '2022-08-29T08:09:31'];
-- Select all temperature records with IDs greater than a minimum value
SELECT * FROM temperature:['London', '2022-08-29T08:03:39']..;
-- Select all temperature records with IDs between the specified range
SELECT * FROM temperature:['London', '2022-08-29T08:03:39']..['London', '2022-08-29T08:09:31'];
21 changes: 21 additions & 0 deletions tests/outputs/ranges.surql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.03
elapsed_seconds : 0.0037388801574707
n_files : 1
n_lines : 13
files_per_second : 267.459762785359
lines_per_second : 3476.97691620967
report_file : ../outputs/ranges.surql.yaml
'SurrealQL' :
nFiles: 1
blank: 0
comment: 8
code: 5
SUM:
blank: 0
comment: 8
code: 5
nFiles: 1

0 comments on commit 059f638

Please sign in to comment.