aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-10-29 16:02:26 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-10-29 16:08:29 -0400
commit4aab121d1720ebb8ca2c59b82dc86beeb4593c6d (patch)
tree2bdce2a897cae82dd1ddbb0ce146b9e7b719df12
parent2214c609e2459c397dfa9431558e4770d4bde24c (diff)
Allow cjs.bqn to output source indices, with initial -i argument
-rwxr-xr-xsrc/cjs.bqn9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cjs.bqn b/src/cjs.bqn
index 47e65d04..abb16c47 100755
--- a/src/cjs.bqn
+++ b/src/cjs.bqn
@@ -1,7 +1,8 @@
#! /usr/bin/env dbqn
compile ← •Import "c.bqn"
-Comp ← ¯1 ↓ ((<"runtime["∾⍕∾"]"˙)¨↕62)⊸Compile
+useInd ← "-i"≡⊑args←•args ⋄ args↓˜↩useInd
+Comp ← (-¬useInd) ↓ ((<"runtime["∾⍕∾"]"˙)¨↕62)⊸Compile
FP ← ∞⊸=◶⟨⍕,"Infinity"⟩
Esc ← (⟨"\t","\n","\r","\'","\"""⟩∾<∘⥊)⊑˜("'"""∾˜@+9‿10‿13)⊑∘⊐⊢
Str ← "str("""∾(∾Esc¨)∾""")"˜
@@ -9,12 +10,12 @@ Char ← "'"(∾∾⊣)Esc
Fconst ← ≡◶⟨(⊑⍋)∘(∾⟜∞)◶⟨0⊸≤◶⟨"-"∾FP∘|,FP⟩,Char⟩⋄Str⋄⊑⟩
L ← "["∾"]"∾˜1↓·∾","⊸∾⟜⍕¨
J ← ∾∾⟜(@+10)¨
-Fout ← ⟨⊢,Fconst,L⟩ {L𝕎¨𝕩}¨ ⊢
+Fout ← (≠↑⟨⊢,Fconst,L,⊢⟩˙) {L𝕎¨𝕩}¨ ⊢
Frun ← ("provide.concat("∾∾⟜")")⌾(1⊸⊑) Fout
-Long ← ∾ (1‿2/⟨" new Uint8Array("∾∾⟜")"⋄((@+10)∾" ,")⊸∾⟩) {𝕎𝕩}¨ ⊢
+Long ← ∾ (≠↑1‿3/⟨" new Uint8Array("∾∾⟜")"⋄((@+10)∾" ,")⊸∾⟩˙) {𝕎𝕩}¨ ⊢
• ← (⊑"r"‿"c"‿"fmt"⊐⊏)◶⟨
{𝕩⋄ref‿len←•Import"pr.bqn"⋄Long Frun len⊸↓⌾(1⊸⊑)Comp ref}
{𝕩⋄Long Fout Comp J •LNS "c.bqn"}
{𝕩⋄Long Fout Comp J •LNS "fmt.bqn"}
¯1 ↓ · J L∘Fout∘Comp¨
-⟩ •args
+⟩ args