Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Discussion posts for script json.r

1
ahmedsayeed1
12-Oct 15:19
json-ctx: context [
emit-type: object!
  make-objects?: does [object! = emit-type]
cache: copy []
https://www.webb-dev.co.uk/
push: func [val] [cache: insert/only cache val]
  pop: has [tmp] [tmp: first cache: back cache remove cache tmp]
out: res: s: none
emit: func [value][res: insert/only res value]

http://www-look-4.com/

  make-translate-func: func [
table [series!] "Escape table, as pairs of from/to string! or char! values."
/local make-rule rules
][
; There are some NEW-LINE calls in this function, which may seem
; superfluous.

https://komiya-dental.com/

It's true that it may be a rare case where you want to
; inspect the generated function if used dynamically, but this may also
      ; be used to generate static functions to be included. That is, you may
; use it as a code generator. In that case, the extra formatting helps.

make-rule: func [
"Returns a parse rule to translate one value to another in the input."
orig
http://www.iu-bloomington.com/
new
      ] [
orig: form orig
new: form new
new-line/all compose [
(orig)
https://waytowhatsnext.com/
(to-paren compose [pos: change/part pos (new) (length? orig)])
              :pos
] off
]
      ; Create a block of parse rules from the table of value translations.
rules: copy []
foreach [from to] table [
repend rules [make-rule from to '|]
]
append rules 'skip ; The final rule

http://www.wearelondonmade.com/

      ; Make the formatting of the generated code a little nicer, putting
; each parse rule on a separate line.
new-line rules on
new-line/skip next rules on 2

; Return a function that uses the parse rules we just generated from
; the map.
http://www.jopspeech.com/
func [
          "Return a copy of the input string, after translating values."
string [any-string!]
/local pos
] compose/deep [
parse/all string [any [pos: (rules)]]
string

http://joerg.li/

json-ctx: context [
emit-type: object!
  make-objects?: does [object! = emit-type]
cache: copy []
push: func [val] [cache: insert/only cache val]
pop: has [tmp] [tmp: first cache: back cache remove cache tmp]
out: res: s: none
emit: func [value][res: insert/only res value]

http://connstr.net/

  make-translate-func: func [
table [series!] "Escape table, as pairs of from/to string! or char! values."
/local make-rule rules
][
; There are some NEW-LINE calls in this function, which may seem
; superfluous.
http://embermanchester.uk/
It's true that it may be a rare case where you want to
      ; inspect the generated function if used dynamically, but this may also
; be used to generate static functions to be included. That is, you may
; use it as a code generator. In that case, the extra formatting helps.

make-rule: func [
http://www.slipstone.co.uk/
“Returns a parse rule to translate one value to another in the input.”
          orig
new
] [
orig: form orig
new: form new
new-line/all compose [
(orig)
(to-paren compose [pos: change/part pos (new) (length? orig)])
:pos
http://logoarts.co.uk/
] off
      ]
      ; Create a block of parse rules from the table of value translations.
rules: copy []
foreach [from to] table [
repend rules [make-rule from to '|]
]
append rules 'skip ; The final rule
http://acpirateradio.co.uk/
; Make the formatting of the generated code a little nicer, putting
      ; each parse rule on a separate line.
new-line rules on
new-line/skip next rules on 2

; Return a function that uses the parse rules we just generated from
; the map.
func [
"Return a copy of the input string, after translating values."
string [any-string!]
http://www.compilatori.com/
/local pos
      ] compose/deep [
parse/all string [any [pos: (rules)]]
string
2
ahmedsayeed1
12-Oct 15:56
3
mark214
20-Nov 20:11
REBOL

Great Post. Thanks for the information. electrician in redding

Contents:

MakeDoc2 by REBOL- 20-Nov-2021
4
richardsjenk
23-Nov 3:41
REBOL

Great! This script creates TAR archives, but how to untar?

Contents:

tree doctor orange county

MakeDoc2 by REBOL- 23-Nov-2021
Notes