just-bash 2.5.5 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/AGENTS.md +2 -2
- package/dist/ast/types.d.ts +100 -11
- package/dist/bin/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{shell/chunks/echo-WSKTON6U.js → chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{shell/chunks/find-CBEJ35BR.js → chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{shell/chunks/grep-IIVQXFNI.js → chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{shell/chunks/jq-XXZPU5CA.js → chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/just-bash.js +659 -135
- package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/shell/shell.js +664 -140
- package/dist/bundle/browser.js +1251 -606
- package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
- package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
- package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
- package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
- package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
- package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
- package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
- package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
- package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
- package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
- package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
- package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
- package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
- package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
- package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
- package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
- package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
- package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
- package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
- package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
- package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
- package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
- package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
- package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
- package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
- package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
- package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
- package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
- package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
- package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
- package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
- package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
- package/dist/bundle/index.js +657 -133
- package/dist/commands/awk/ast.d.ts +1 -0
- package/dist/commands/awk/interpreter/context.d.ts +14 -0
- package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
- package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
- package/dist/commands/awk/parser2-print.d.ts +35 -0
- package/dist/commands/awk/parser2.d.ts +42 -34
- package/dist/commands/printf/strftime.d.ts +9 -0
- package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
- package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/index.d.ts +17 -0
- package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
- package/dist/commands/query-engine/evaluator.d.ts +10 -2
- package/dist/commands/query-engine/parser-types.d.ts +171 -0
- package/dist/commands/query-engine/parser.d.ts +2 -132
- package/dist/commands/query-engine/path-operations.d.ts +15 -0
- package/dist/commands/query-engine/value-operations.d.ts +39 -0
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/rmdir/rmdir.d.ts +2 -0
- package/dist/commands/sed/lexer.d.ts +12 -0
- package/dist/commands/sed/parser.d.ts +9 -0
- package/dist/commands/sed/sed-regex.d.ts +23 -0
- package/dist/commands/sed/types.d.ts +13 -1
- package/dist/commands/tar/tar-options.d.ts +36 -0
- package/dist/commands/time/time.d.ts +25 -0
- package/dist/commands/whoami/whoami.d.ts +9 -0
- package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
- package/dist/fs/interface.d.ts +16 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
- package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
- package/dist/interpreter/alias-expansion.d.ts +23 -0
- package/dist/interpreter/arithmetic.d.ts +1 -6
- package/dist/interpreter/assignment-expansion.d.ts +24 -0
- package/dist/interpreter/builtin-dispatch.d.ts +39 -0
- package/dist/interpreter/builtins/compgen.d.ts +26 -0
- package/dist/interpreter/builtins/complete.d.ts +17 -0
- package/dist/interpreter/builtins/compopt.d.ts +28 -0
- package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
- package/dist/interpreter/builtins/declare-print.d.ts +39 -0
- package/dist/interpreter/builtins/declare.d.ts +10 -4
- package/dist/interpreter/builtins/dirs.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +1 -1
- package/dist/interpreter/builtins/export.d.ts +1 -0
- package/dist/interpreter/builtins/getopts.d.ts +18 -0
- package/dist/interpreter/builtins/hash.d.ts +19 -0
- package/dist/interpreter/builtins/help.d.ts +12 -0
- package/dist/interpreter/builtins/index.d.ts +9 -1
- package/dist/interpreter/builtins/local.d.ts +1 -1
- package/dist/interpreter/builtins/read.d.ts +1 -1
- package/dist/interpreter/builtins/set.d.ts +3 -0
- package/dist/interpreter/builtins/shift.d.ts +3 -0
- package/dist/interpreter/builtins/shopt.d.ts +7 -0
- package/dist/interpreter/builtins/unset.d.ts +5 -1
- package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
- package/dist/interpreter/command-resolution.d.ts +43 -0
- package/dist/interpreter/conditionals.d.ts +1 -1
- package/dist/interpreter/errors.d.ts +36 -1
- package/dist/interpreter/expansion/analysis.d.ts +15 -17
- package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
- package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
- package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
- package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
- package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
- package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
- package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
- package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
- package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
- package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
- package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
- package/dist/interpreter/expansion/pattern.d.ts +2 -1
- package/dist/interpreter/expansion/positional-params.d.ts +59 -0
- package/dist/interpreter/expansion/prompt.d.ts +39 -0
- package/dist/interpreter/expansion/quoting.d.ts +13 -0
- package/dist/interpreter/expansion/tilde.d.ts +12 -0
- package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
- package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
- package/dist/interpreter/expansion/variable.d.ts +10 -1
- package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
- package/dist/interpreter/expansion/word-split.d.ts +11 -6
- package/dist/interpreter/expansion.d.ts +30 -4
- package/dist/interpreter/functions.d.ts +1 -1
- package/dist/interpreter/helpers/array.d.ts +20 -0
- package/dist/interpreter/helpers/ifs.d.ts +66 -5
- package/dist/interpreter/helpers/nameref.d.ts +65 -0
- package/dist/interpreter/helpers/quoting.d.ts +24 -0
- package/dist/interpreter/helpers/readonly.d.ts +28 -4
- package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
- package/dist/interpreter/helpers/shellopts.d.ts +28 -0
- package/dist/interpreter/helpers/string-compare.d.ts +3 -1
- package/dist/interpreter/helpers/tilde.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
- package/dist/interpreter/helpers/word-matching.d.ts +26 -0
- package/dist/interpreter/helpers/xtrace.d.ts +18 -0
- package/dist/interpreter/interpreter.d.ts +13 -14
- package/dist/interpreter/pipeline-execution.d.ts +16 -0
- package/dist/interpreter/redirections.d.ts +38 -1
- package/dist/interpreter/simple-command-assignments.d.ts +29 -0
- package/dist/interpreter/subshell-group.d.ts +32 -0
- package/dist/interpreter/type-command.d.ts +37 -0
- package/dist/interpreter/types.d.ts +255 -21
- package/dist/parser/arithmetic-parser.d.ts +2 -4
- package/dist/parser/arithmetic-primaries.d.ts +45 -0
- package/dist/parser/compound-parser.d.ts +21 -7
- package/dist/parser/expansion-parser.d.ts +7 -1
- package/dist/parser/lexer.d.ts +57 -0
- package/dist/parser/parser-substitution.d.ts +62 -0
- package/dist/parser/parser.d.ts +39 -2
- package/dist/parser/types.d.ts +1 -0
- package/dist/types.d.ts +17 -0
- package/package.json +4 -1
- package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
- package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
- package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
- package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
- package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
- package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
- package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
- package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
- package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
- package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
- package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
- package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
- package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
- package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
- package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
- package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
- package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
- /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
- /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
- /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
- /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
- /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
|
@@ -9,6 +9,7 @@ export interface AwkRuntimeContext {
|
|
|
9
9
|
FS: string;
|
|
10
10
|
OFS: string;
|
|
11
11
|
ORS: string;
|
|
12
|
+
OFMT: string;
|
|
12
13
|
NR: number;
|
|
13
14
|
NF: number;
|
|
14
15
|
FNR: number;
|
|
@@ -20,8 +21,10 @@ export interface AwkRuntimeContext {
|
|
|
20
21
|
line: string;
|
|
21
22
|
vars: Record<string, AwkValue>;
|
|
22
23
|
arrays: Record<string, Record<string, AwkValue>>;
|
|
24
|
+
arrayAliases: Map<string, string>;
|
|
23
25
|
ARGC: number;
|
|
24
26
|
ARGV: Record<string, string>;
|
|
27
|
+
ENVIRON: Record<string, string>;
|
|
25
28
|
functions: Map<string, AwkFunctionDef>;
|
|
26
29
|
lines?: string[];
|
|
27
30
|
lineIndex?: number;
|
|
@@ -37,11 +40,17 @@ export interface AwkRuntimeContext {
|
|
|
37
40
|
loopContinue: boolean;
|
|
38
41
|
returnValue?: AwkValue;
|
|
39
42
|
hasReturn: boolean;
|
|
43
|
+
inEndBlock: boolean;
|
|
40
44
|
output: string;
|
|
41
45
|
fs?: AwkFileSystem;
|
|
42
46
|
cwd?: string;
|
|
43
47
|
openedFiles: Set<string>;
|
|
44
48
|
random?: () => number;
|
|
49
|
+
exec?: (cmd: string) => Promise<{
|
|
50
|
+
stdout: string;
|
|
51
|
+
stderr: string;
|
|
52
|
+
exitCode: number;
|
|
53
|
+
}>;
|
|
45
54
|
}
|
|
46
55
|
export interface CreateContextOptions {
|
|
47
56
|
fieldSep?: RegExp;
|
|
@@ -49,5 +58,10 @@ export interface CreateContextOptions {
|
|
|
49
58
|
maxRecursionDepth?: number;
|
|
50
59
|
fs?: AwkFileSystem;
|
|
51
60
|
cwd?: string;
|
|
61
|
+
exec?: (cmd: string) => Promise<{
|
|
62
|
+
stdout: string;
|
|
63
|
+
stderr: string;
|
|
64
|
+
exitCode: number;
|
|
65
|
+
}>;
|
|
52
66
|
}
|
|
53
67
|
export declare function createRuntimeContext(options?: CreateContextOptions): AwkRuntimeContext;
|
|
@@ -25,6 +25,8 @@ export declare class AwkInterpreter {
|
|
|
25
25
|
executeLine(line: string): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Execute all END blocks.
|
|
28
|
+
* END blocks run even after exit is called, but exit from within
|
|
29
|
+
* an END block stops further END block execution.
|
|
28
30
|
*/
|
|
29
31
|
executeEnd(): Promise<void>;
|
|
30
32
|
/**
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
import type { AwkValue } from "./types.js";
|
|
7
7
|
/**
|
|
8
8
|
* Check if a value is truthy in AWK.
|
|
9
|
-
* Numbers
|
|
9
|
+
* - Numbers: truthy if non-zero
|
|
10
|
+
* - Empty string: falsy
|
|
11
|
+
* - String "0": falsy (canonical string representation of zero)
|
|
12
|
+
* - All other non-empty strings: truthy (including "00", "0.0", etc.)
|
|
10
13
|
*/
|
|
11
14
|
export declare function isTruthy(val: AwkValue): boolean;
|
|
12
15
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWK Parser Print Context Helpers
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing in print/printf context where > and >> are redirection
|
|
5
|
+
* operators rather than comparison operators.
|
|
6
|
+
*/
|
|
7
|
+
import type { AwkExpr, AwkStmt } from "./ast.js";
|
|
8
|
+
import type { Token, TokenType } from "./lexer.js";
|
|
9
|
+
/**
|
|
10
|
+
* Interface for parser methods needed by print parsing helpers.
|
|
11
|
+
* Used to avoid circular dependencies.
|
|
12
|
+
*/
|
|
13
|
+
export interface PrintParserContext {
|
|
14
|
+
tokens: Token[];
|
|
15
|
+
pos: number;
|
|
16
|
+
current(): Token;
|
|
17
|
+
advance(): Token;
|
|
18
|
+
match(...types: TokenType[]): boolean;
|
|
19
|
+
check(type: TokenType): boolean;
|
|
20
|
+
expect(type: TokenType, message?: string): Token;
|
|
21
|
+
skipNewlines(): void;
|
|
22
|
+
parseExpression(): AwkExpr;
|
|
23
|
+
parseTernary(): AwkExpr;
|
|
24
|
+
parsePrimary(): AwkExpr;
|
|
25
|
+
parseAddSub(): AwkExpr;
|
|
26
|
+
setPos(pos: number): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a print statement.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parsePrintStatement(p: PrintParserContext): AwkStmt;
|
|
32
|
+
/**
|
|
33
|
+
* Parse a printf statement.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parsePrintfStatement(p: PrintParserContext): AwkStmt;
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Recursive descent parser that builds an AST from tokens.
|
|
5
5
|
*/
|
|
6
|
-
import type { AwkProgram } from "./ast.js";
|
|
6
|
+
import type { AwkExpr, AwkProgram } from "./ast.js";
|
|
7
|
+
import { type Token, TokenType } from "./lexer.js";
|
|
7
8
|
export declare class AwkParser {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
tokens: Token[];
|
|
10
|
+
pos: number;
|
|
10
11
|
parse(input: string): AwkProgram;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
setPos(newPos: number): void;
|
|
13
|
+
current(): Token;
|
|
14
|
+
advance(): Token;
|
|
15
|
+
match(...types: TokenType[]): boolean;
|
|
16
|
+
check(type: TokenType): boolean;
|
|
17
|
+
expect(type: TokenType, message?: string): Token;
|
|
18
|
+
skipNewlines(): void;
|
|
17
19
|
private skipTerminators;
|
|
18
20
|
private parseProgram;
|
|
19
21
|
private parseFunction;
|
|
@@ -24,29 +26,14 @@ export declare class AwkParser {
|
|
|
24
26
|
private parseWhile;
|
|
25
27
|
private parseDoWhile;
|
|
26
28
|
private parseFor;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* (not inside ternary) as redirection rather than comparison operators.
|
|
31
|
-
*/
|
|
32
|
-
private parsePrintArg;
|
|
33
|
-
/**
|
|
34
|
-
* Look ahead to see if there's a ternary ? operator before the next statement terminator.
|
|
35
|
-
* This tells us whether > is comparison (in ternary condition) or redirection.
|
|
36
|
-
*/
|
|
37
|
-
private lookAheadForTernary;
|
|
38
|
-
private parsePrintOr;
|
|
39
|
-
private parsePrintAnd;
|
|
40
|
-
private parsePrintIn;
|
|
41
|
-
private parsePrintMatch;
|
|
29
|
+
parseExpression(): AwkExpr;
|
|
30
|
+
private parseAssignment;
|
|
31
|
+
parseTernary(): AwkExpr;
|
|
42
32
|
/**
|
|
43
|
-
*
|
|
33
|
+
* Parse command pipe getline: "cmd" | getline [var]
|
|
34
|
+
* This has lower precedence than logical OR but higher than ternary.
|
|
44
35
|
*/
|
|
45
|
-
private
|
|
46
|
-
private parsePrintf;
|
|
47
|
-
private parseExpression;
|
|
48
|
-
private parseAssignment;
|
|
49
|
-
private parseTernary;
|
|
36
|
+
private parsePipeGetline;
|
|
50
37
|
private parseOr;
|
|
51
38
|
/**
|
|
52
39
|
* Continue parsing a logical OR/AND expression from a given left-hand side.
|
|
@@ -59,15 +46,36 @@ export declare class AwkParser {
|
|
|
59
46
|
private parseLogicalAndRest;
|
|
60
47
|
private parseAnd;
|
|
61
48
|
private parseIn;
|
|
49
|
+
private parseConcatenation;
|
|
62
50
|
private parseMatch;
|
|
63
51
|
private parseComparison;
|
|
64
|
-
private parseConcatenation;
|
|
65
52
|
private canStartExpression;
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Check if the current token terminates a concatenation.
|
|
55
|
+
* These are tokens that indicate we've reached a higher-level operator
|
|
56
|
+
* or end of expression.
|
|
57
|
+
*/
|
|
58
|
+
private isConcatTerminator;
|
|
59
|
+
parseAddSub(): AwkExpr;
|
|
68
60
|
private parseMulDiv;
|
|
69
61
|
private parseUnary;
|
|
70
62
|
private parsePower;
|
|
71
63
|
private parsePostfix;
|
|
72
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Parse a field index expression. This is like parseUnary but does NOT allow
|
|
66
|
+
* postfix operators, so that $i++ parses as ($i)++ rather than $(i++).
|
|
67
|
+
* Allows: $1, $i, $++i, $--i, $(expr), $-1
|
|
68
|
+
* Does NOT consume postfix ++ or -- (those apply to the field, not the index)
|
|
69
|
+
*/
|
|
70
|
+
private parseFieldIndex;
|
|
71
|
+
/**
|
|
72
|
+
* Parse power expression for field index (no postfix on base)
|
|
73
|
+
*/
|
|
74
|
+
private parseFieldIndexPower;
|
|
75
|
+
/**
|
|
76
|
+
* Parse primary expression for field index - like parsePrimary but returns
|
|
77
|
+
* without checking for postfix operators
|
|
78
|
+
*/
|
|
79
|
+
private parseFieldIndexPrimary;
|
|
80
|
+
parsePrimary(): AwkExpr;
|
|
73
81
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strftime Formatting Functions
|
|
3
|
+
*
|
|
4
|
+
* Handles date/time formatting for printf's %(...)T directive.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Format a timestamp using strftime-like format string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatStrftime(format: string, timestamp: number, tz?: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles array manipulation functions like sort, sort_by, group_by, max, min, add, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type EvalWithPartialFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
11
|
+
type CompareFn = (a: QueryValue, b: QueryValue) => number;
|
|
12
|
+
type IsTruthyFn = (v: QueryValue) => boolean;
|
|
13
|
+
type ContainsDeepFn = (a: QueryValue, b: QueryValue) => boolean;
|
|
14
|
+
type ExecutionLimitErrorClass = new (message: string, kind: "recursion" | "commands" | "iterations") => Error;
|
|
15
|
+
/**
|
|
16
|
+
* Handle array builtins that need evaluate function for arguments.
|
|
17
|
+
* Returns null if the builtin name is not an array builtin handled here.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evalArrayBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, evaluateWithPartialResults: EvalWithPartialFn, compareJq: CompareFn, isTruthy: IsTruthyFn, containsDeep: ContainsDeepFn, ExecutionLimitError: ExecutionLimitErrorClass): QueryValue[] | null;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control flow jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles first, last, nth, range, limit, isempty, isvalid, skip, until, while, repeat.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type EvalWithPartialFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
11
|
+
type IsTruthyFn = (v: QueryValue) => boolean;
|
|
12
|
+
type ExecutionLimitErrorClass = new (message: string, kind: "recursion" | "commands" | "iterations") => Error;
|
|
13
|
+
/**
|
|
14
|
+
* Handle control flow builtins.
|
|
15
|
+
* Returns null if the builtin name is not a control builtin handled here.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evalControlBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, evaluateWithPartialResults: EvalWithPartialFn, isTruthy: IsTruthyFn, ExecutionLimitError: ExecutionLimitErrorClass): QueryValue[] | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date/time-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles date and time functions like now, gmtime, mktime, strftime, strptime, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Handle date builtins that need evaluate function for arguments.
|
|
12
|
+
* Returns null if the builtin name is not a date builtin handled here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evalDateBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn): QueryValue[] | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format-related jq builtins (@ prefixed)
|
|
3
|
+
*
|
|
4
|
+
* Handles encoding/formatting functions like @base64, @uri, @csv, @json, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { QueryValue } from "../value-operations.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handle format builtins (those starting with @).
|
|
9
|
+
* Returns null if the builtin name is not a format builtin handled here.
|
|
10
|
+
*/
|
|
11
|
+
export declare function evalFormatBuiltin(value: QueryValue, name: string, maxDepth?: number): QueryValue[] | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles index, rindex, and indices functions for finding positions in arrays/strings.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type DeepEqualFn = (a: QueryValue, b: QueryValue) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Handle index builtins that need evaluate function for arguments.
|
|
13
|
+
* Returns null if the builtin name is not an index builtin handled here.
|
|
14
|
+
*/
|
|
15
|
+
export declare function evalIndexBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, deepEqual: DeepEqualFn): QueryValue[] | null;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jq builtin functions index
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all builtin handlers from category-specific modules.
|
|
5
|
+
*/
|
|
6
|
+
export { evalArrayBuiltin } from "./array-builtins.js";
|
|
7
|
+
export { evalControlBuiltin } from "./control-builtins.js";
|
|
8
|
+
export { evalDateBuiltin } from "./date-builtins.js";
|
|
9
|
+
export { evalFormatBuiltin } from "./format-builtins.js";
|
|
10
|
+
export { evalIndexBuiltin } from "./index-builtins.js";
|
|
11
|
+
export { evalMathBuiltin } from "./math-builtins.js";
|
|
12
|
+
export { evalNavigationBuiltin } from "./navigation-builtins.js";
|
|
13
|
+
export { evalObjectBuiltin } from "./object-builtins.js";
|
|
14
|
+
export { evalPathBuiltin } from "./path-builtins.js";
|
|
15
|
+
export { evalSqlBuiltin } from "./sql-builtins.js";
|
|
16
|
+
export { evalStringBuiltin } from "./string-builtins.js";
|
|
17
|
+
export { evalTypeBuiltin } from "./type-builtins.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Math-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles mathematical functions like abs, pow, exp, trig functions, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Handle math builtins that need evaluate function for arguments.
|
|
12
|
+
* Returns null if the builtin name is not a math builtin handled here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evalMathBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn): QueryValue[] | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation and traversal jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles recurse, recurse_down, walk, transpose, combinations, parent, parents, root.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type IsTruthyFn = (v: QueryValue) => boolean;
|
|
11
|
+
type GetValueAtPathFn = (obj: QueryValue, path: (string | number)[]) => QueryValue;
|
|
12
|
+
type EvalBuiltinFn = (value: QueryValue, name: string, args: AstNode[], ctx: EvalContext) => QueryValue[];
|
|
13
|
+
/**
|
|
14
|
+
* Handle navigation builtins that need evaluate function for arguments.
|
|
15
|
+
* Returns null if the builtin name is not a navigation builtin handled here.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evalNavigationBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, isTruthy: IsTruthyFn, getValueAtPath: GetValueAtPathFn, evalBuiltin: EvalBuiltinFn): QueryValue[] | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles object manipulation functions like keys, to_entries, from_entries, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import { type QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Handle object builtins that need evaluate function for arguments.
|
|
12
|
+
* Returns null if the builtin name is not an object builtin handled here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evalObjectBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn): QueryValue[] | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles path manipulation functions like getpath, setpath, delpaths, paths, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type IsTruthyFn = (v: QueryValue) => boolean;
|
|
11
|
+
type SetPathFn = (obj: QueryValue, path: (string | number)[], val: QueryValue) => QueryValue;
|
|
12
|
+
type DeletePathFn = (obj: QueryValue, path: (string | number)[]) => QueryValue;
|
|
13
|
+
type ApplyDelFn = (value: QueryValue, expr: AstNode, ctx: EvalContext) => QueryValue;
|
|
14
|
+
type CollectPathsFn = (value: QueryValue, expr: AstNode, ctx: EvalContext, currentPath: (string | number)[], paths: (string | number)[][]) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Handle path builtins that need evaluate function for arguments.
|
|
17
|
+
* Returns null if the builtin name is not a path builtin handled here.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evalPathBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, isTruthy: IsTruthyFn, setPath: SetPathFn, deletePath: DeletePathFn, applyDel: ApplyDelFn, collectPaths: CollectPathsFn): QueryValue[] | null;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQL-like jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles IN, INDEX, and JOIN functions.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
type DeepEqualFn = (a: QueryValue, b: QueryValue) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Handle SQL-like builtins that need evaluate function for arguments.
|
|
13
|
+
* Returns null if the builtin name is not a SQL builtin handled here.
|
|
14
|
+
*/
|
|
15
|
+
export declare function evalSqlBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn, deepEqual: DeepEqualFn): QueryValue[] | null;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles string manipulation functions like join, split, test, match, gsub, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { EvalContext } from "../evaluator.js";
|
|
7
|
+
import type { AstNode } from "../parser.js";
|
|
8
|
+
import type { QueryValue } from "../value-operations.js";
|
|
9
|
+
type EvalFn = (value: QueryValue, ast: AstNode, ctx: EvalContext) => QueryValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Handle string builtins that need evaluate function for arguments.
|
|
12
|
+
* Returns null if the builtin name is not a string builtin handled here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evalStringBuiltin(value: QueryValue, name: string, args: AstNode[], ctx: EvalContext, evaluate: EvalFn): QueryValue[] | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-related jq builtins
|
|
3
|
+
*
|
|
4
|
+
* Handles type checking and type filtering functions like type, numbers, strings, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { QueryValue } from "../value-operations.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handle type builtins.
|
|
9
|
+
* Returns null if the builtin name is not a type builtin handled here.
|
|
10
|
+
*/
|
|
11
|
+
export declare function evalTypeBuiltin(value: QueryValue, name: string): QueryValue[] | null;
|
|
@@ -5,18 +5,26 @@
|
|
|
5
5
|
* Used by jq, yq, and other query-based commands.
|
|
6
6
|
*/
|
|
7
7
|
import type { AstNode } from "./parser.js";
|
|
8
|
-
|
|
8
|
+
import { type QueryValue } from "./value-operations.js";
|
|
9
|
+
export type { QueryValue } from "./value-operations.js";
|
|
9
10
|
export interface QueryExecutionLimits {
|
|
10
11
|
maxIterations?: number;
|
|
12
|
+
maxDepth?: number;
|
|
11
13
|
}
|
|
12
14
|
export interface EvalContext {
|
|
13
15
|
vars: Map<string, QueryValue>;
|
|
14
|
-
limits: Required<QueryExecutionLimits
|
|
16
|
+
limits: Required<Pick<QueryExecutionLimits, "maxIterations">> & QueryExecutionLimits;
|
|
15
17
|
env?: Record<string, string | undefined>;
|
|
16
18
|
/** Original document root for parent/root navigation */
|
|
17
19
|
root?: QueryValue;
|
|
18
20
|
/** Current path from root for parent navigation */
|
|
19
21
|
currentPath?: (string | number)[];
|
|
22
|
+
funcs?: Map<string, {
|
|
23
|
+
params: string[];
|
|
24
|
+
body: AstNode;
|
|
25
|
+
closure?: Map<string, unknown>;
|
|
26
|
+
}>;
|
|
27
|
+
labels?: Set<string>;
|
|
20
28
|
}
|
|
21
29
|
export interface EvaluateOptions {
|
|
22
30
|
limits?: QueryExecutionLimits;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query expression parser types
|
|
3
|
+
*
|
|
4
|
+
* AST node types and token types for jq-style filter expressions.
|
|
5
|
+
*/
|
|
6
|
+
export type TokenType = "DOT" | "PIPE" | "COMMA" | "COLON" | "SEMICOLON" | "LPAREN" | "RPAREN" | "LBRACKET" | "RBRACKET" | "LBRACE" | "RBRACE" | "QUESTION" | "PLUS" | "MINUS" | "STAR" | "SLASH" | "PERCENT" | "EQ" | "NE" | "LT" | "LE" | "GT" | "GE" | "AND" | "OR" | "NOT" | "ALT" | "ASSIGN" | "UPDATE_ADD" | "UPDATE_SUB" | "UPDATE_MUL" | "UPDATE_DIV" | "UPDATE_MOD" | "UPDATE_ALT" | "UPDATE_PIPE" | "IDENT" | "NUMBER" | "STRING" | "IF" | "THEN" | "ELIF" | "ELSE" | "END" | "AS" | "TRY" | "CATCH" | "TRUE" | "FALSE" | "NULL" | "REDUCE" | "FOREACH" | "LABEL" | "BREAK" | "DEF" | "DOTDOT" | "EOF";
|
|
7
|
+
export interface Token {
|
|
8
|
+
type: TokenType;
|
|
9
|
+
value?: string | number;
|
|
10
|
+
pos: number;
|
|
11
|
+
}
|
|
12
|
+
export type AstNode = IdentityNode | FieldNode | IndexNode | SliceNode | IterateNode | PipeNode | CommaNode | LiteralNode | ArrayNode | ObjectNode | ParenNode | BinaryOpNode | UnaryOpNode | CondNode | TryNode | CallNode | VarBindNode | VarRefNode | RecurseNode | OptionalNode | StringInterpNode | UpdateOpNode | ReduceNode | ForeachNode | LabelNode | BreakNode | DefNode;
|
|
13
|
+
export interface IdentityNode {
|
|
14
|
+
type: "Identity";
|
|
15
|
+
}
|
|
16
|
+
export interface FieldNode {
|
|
17
|
+
type: "Field";
|
|
18
|
+
name: string;
|
|
19
|
+
base?: AstNode;
|
|
20
|
+
}
|
|
21
|
+
export interface IndexNode {
|
|
22
|
+
type: "Index";
|
|
23
|
+
index: AstNode;
|
|
24
|
+
base?: AstNode;
|
|
25
|
+
}
|
|
26
|
+
export interface SliceNode {
|
|
27
|
+
type: "Slice";
|
|
28
|
+
start?: AstNode;
|
|
29
|
+
end?: AstNode;
|
|
30
|
+
base?: AstNode;
|
|
31
|
+
}
|
|
32
|
+
export interface IterateNode {
|
|
33
|
+
type: "Iterate";
|
|
34
|
+
base?: AstNode;
|
|
35
|
+
}
|
|
36
|
+
export interface PipeNode {
|
|
37
|
+
type: "Pipe";
|
|
38
|
+
left: AstNode;
|
|
39
|
+
right: AstNode;
|
|
40
|
+
}
|
|
41
|
+
export interface CommaNode {
|
|
42
|
+
type: "Comma";
|
|
43
|
+
left: AstNode;
|
|
44
|
+
right: AstNode;
|
|
45
|
+
}
|
|
46
|
+
export interface LiteralNode {
|
|
47
|
+
type: "Literal";
|
|
48
|
+
value: unknown;
|
|
49
|
+
}
|
|
50
|
+
export interface ArrayNode {
|
|
51
|
+
type: "Array";
|
|
52
|
+
elements?: AstNode;
|
|
53
|
+
}
|
|
54
|
+
export interface ObjectNode {
|
|
55
|
+
type: "Object";
|
|
56
|
+
entries: {
|
|
57
|
+
key: AstNode | string;
|
|
58
|
+
value: AstNode;
|
|
59
|
+
}[];
|
|
60
|
+
}
|
|
61
|
+
export interface ParenNode {
|
|
62
|
+
type: "Paren";
|
|
63
|
+
expr: AstNode;
|
|
64
|
+
}
|
|
65
|
+
export interface BinaryOpNode {
|
|
66
|
+
type: "BinaryOp";
|
|
67
|
+
op: "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "and" | "or" | "//";
|
|
68
|
+
left: AstNode;
|
|
69
|
+
right: AstNode;
|
|
70
|
+
}
|
|
71
|
+
export interface UnaryOpNode {
|
|
72
|
+
type: "UnaryOp";
|
|
73
|
+
op: "-" | "not";
|
|
74
|
+
operand: AstNode;
|
|
75
|
+
}
|
|
76
|
+
export interface CondNode {
|
|
77
|
+
type: "Cond";
|
|
78
|
+
cond: AstNode;
|
|
79
|
+
then: AstNode;
|
|
80
|
+
elifs: {
|
|
81
|
+
cond: AstNode;
|
|
82
|
+
then: AstNode;
|
|
83
|
+
}[];
|
|
84
|
+
else?: AstNode;
|
|
85
|
+
}
|
|
86
|
+
export interface TryNode {
|
|
87
|
+
type: "Try";
|
|
88
|
+
body: AstNode;
|
|
89
|
+
catch?: AstNode;
|
|
90
|
+
}
|
|
91
|
+
export interface CallNode {
|
|
92
|
+
type: "Call";
|
|
93
|
+
name: string;
|
|
94
|
+
args: AstNode[];
|
|
95
|
+
}
|
|
96
|
+
export interface VarBindNode {
|
|
97
|
+
type: "VarBind";
|
|
98
|
+
name: string;
|
|
99
|
+
value: AstNode;
|
|
100
|
+
body: AstNode;
|
|
101
|
+
pattern?: DestructurePattern;
|
|
102
|
+
alternatives?: DestructurePattern[];
|
|
103
|
+
}
|
|
104
|
+
export type DestructurePattern = {
|
|
105
|
+
type: "var";
|
|
106
|
+
name: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "array";
|
|
109
|
+
elements: DestructurePattern[];
|
|
110
|
+
} | {
|
|
111
|
+
type: "object";
|
|
112
|
+
fields: {
|
|
113
|
+
key: string | AstNode;
|
|
114
|
+
pattern: DestructurePattern;
|
|
115
|
+
keyVar?: string;
|
|
116
|
+
}[];
|
|
117
|
+
};
|
|
118
|
+
export interface VarRefNode {
|
|
119
|
+
type: "VarRef";
|
|
120
|
+
name: string;
|
|
121
|
+
}
|
|
122
|
+
export interface RecurseNode {
|
|
123
|
+
type: "Recurse";
|
|
124
|
+
}
|
|
125
|
+
export interface OptionalNode {
|
|
126
|
+
type: "Optional";
|
|
127
|
+
expr: AstNode;
|
|
128
|
+
}
|
|
129
|
+
export interface StringInterpNode {
|
|
130
|
+
type: "StringInterp";
|
|
131
|
+
parts: (string | AstNode)[];
|
|
132
|
+
}
|
|
133
|
+
export interface UpdateOpNode {
|
|
134
|
+
type: "UpdateOp";
|
|
135
|
+
op: "+=" | "-=" | "*=" | "/=" | "%=" | "//=" | "=" | "|=";
|
|
136
|
+
path: AstNode;
|
|
137
|
+
value: AstNode;
|
|
138
|
+
}
|
|
139
|
+
export interface ReduceNode {
|
|
140
|
+
type: "Reduce";
|
|
141
|
+
expr: AstNode;
|
|
142
|
+
varName: string;
|
|
143
|
+
pattern?: DestructurePattern;
|
|
144
|
+
init: AstNode;
|
|
145
|
+
update: AstNode;
|
|
146
|
+
}
|
|
147
|
+
export interface ForeachNode {
|
|
148
|
+
type: "Foreach";
|
|
149
|
+
expr: AstNode;
|
|
150
|
+
varName: string;
|
|
151
|
+
pattern?: DestructurePattern;
|
|
152
|
+
init: AstNode;
|
|
153
|
+
update: AstNode;
|
|
154
|
+
extract?: AstNode;
|
|
155
|
+
}
|
|
156
|
+
export interface LabelNode {
|
|
157
|
+
type: "Label";
|
|
158
|
+
name: string;
|
|
159
|
+
body: AstNode;
|
|
160
|
+
}
|
|
161
|
+
export interface BreakNode {
|
|
162
|
+
type: "Break";
|
|
163
|
+
name: string;
|
|
164
|
+
}
|
|
165
|
+
export interface DefNode {
|
|
166
|
+
type: "Def";
|
|
167
|
+
name: string;
|
|
168
|
+
params: string[];
|
|
169
|
+
funcBody: AstNode;
|
|
170
|
+
body: AstNode;
|
|
171
|
+
}
|