Skip to content

Commit 89caec2

Browse files
authored
jq (#528)
1 parent 79ec2f3 commit 89caec2

File tree

6 files changed

+63
-6
lines changed

6 files changed

+63
-6
lines changed

LANGUAGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ JavaScript (js,mjs)
140140
JavaServer Pages (jsp)
141141
Jenkins Buildfile (jenkinsfile)
142142
Jinja (jinja,j2,jinja2)
143+
jq (jq)
143144
JSON (json)
144145
JSONC (jsonc)
145146
JSONL (jsonl)

SCC-OUTPUT-REPORT.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<th>447</th>
1919
<th>7659</th>
2020
<th>1529</th>
21-
<th>254636</th>
21+
<th>254716</th>
2222
<th>4067</th>
2323
</tr><tr>
2424
<td>processor/formatters.go</td>
@@ -288,7 +288,7 @@
288288
<td>0</td>
289289
<td>4</td>
290290
<td>0</td>
291-
<td>22297</td>
291+
<td>22377</td>
292292
<td>5</td>
293293
</tr></tbody>
294294
<tfoot><tr>
@@ -299,7 +299,7 @@
299299
<th>447</th>
300300
<th>7659</th>
301301
<th>1529</th>
302-
<th>254636</th>
302+
<th>254716</th>
303303
<th>4067</th>
304304
</tr>
305305
<tr>

examples/language/jq.jq

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Use gojq for infinite precision integer arithmetic
2+
def tobase($b):
3+
def digit: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[.:.+1];
4+
def mod: . % $b;
5+
def div: ((. - mod) / $b);
6+
def digits: recurse( select(. >= $b) | div) | mod ;
7+
8+
select(2 <= $b and $b <= 36)
9+
| [digits | digit] | reverse | add;
10+
11+
def send_more_money:
12+
def choose(m;n;used): ([range(m;n+1)] - used)[];
13+
def num(a;b;c;d): 1000*a + 100*b + 10*c + d;
14+
def num(a;b;c;d;e): 10*num(a;b;c;d) + e;
15+
first(
16+
1 as $m
17+
| 0 as $o
18+
| choose(8;9;[]) as $s
19+
| choose(2;9;[$s]) as $e
20+
| choose(2;9;[$s,$e]) as $n
21+
| choose(2;9;[$s,$e,$n]) as $d
22+
| choose(2;9;[$s,$e,$n,$d]) as $r
23+
| choose(2;9;[$s,$e,$n,$d,$r]) as $y
24+
| select(num($s;$e;$n;$d) + num($m;$o;$r;$e) ==
25+
num($m;$o;$n;$e;$y))
26+
| [$s,$e,$n,$d,$m,$o,$r,$e,$m,$o,$n,$e,$y] );

languages.json

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4546,8 +4546,8 @@
45464546
"multi_line": [["=pod", "=cut"]],
45474547
"quotes": [
45484548
{
4549-
"end": "\\\"",
4550-
"start": "\\\""
4549+
"end": "\"",
4550+
"start": "\""
45514551
},
45524552
{
45534553
"end": "'",
@@ -7319,6 +7319,35 @@
73197319
"multi_line": [],
73207320
"quotes": []
73217321
},
7322+
"jq": {
7323+
"complexitychecks": [
7324+
".",
7325+
"if ",
7326+
"elif ",
7327+
"else ",
7328+
"!= ",
7329+
"== ",
7330+
">= ",
7331+
"<= ",
7332+
"< ",
7333+
"> ",
7334+
"and ",
7335+
"or ",
7336+
"not ",
7337+
"// ",
7338+
"try ",
7339+
"break "
7340+
],
7341+
"extensions": ["jq"],
7342+
"line_comment": ["#"],
7343+
"multi_line": [],
7344+
"quotes": [
7345+
{
7346+
"end": "\"",
7347+
"start": "\""
7348+
}
7349+
]
7350+
},
73227351
"m4": {
73237352
"complexitychecks": [],
73247353
"extensions": ["m4"],

processor/constants.go

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ specificLanguages=(
960960
'INI '
961961
'Java '
962962
'JSONC '
963+
'jq '
963964
'Korn Shell '
964965
'LALRPOP '
965966
'License '

0 commit comments

Comments
 (0)