Skip to content

Commit

Permalink
CHANGE: **Switching map and construction syntax**
Browse files Browse the repository at this point in the history
`map!` values now use syntax like: `#[key: value]`
construction syntax now looks like: `#(true)` or `#(i32! [1 2 3])`

The included [`map-conv.reb` script](https://github.com/Oldes/Rebol3/blob/master/make/tools/map-conv.reb) can be used for converting existing code.

resolves: Oldes/Rebol-issues#2589
  • Loading branch information
Oldes committed Feb 17, 2024
1 parent cb64306 commit 3c2b93a
Show file tree
Hide file tree
Showing 70 changed files with 1,183 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.15.1
3.16.0
8 changes: 4 additions & 4 deletions make/r3-view.rc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
101 ICON "icon/r3.ico"

1 VERSIONINFO
FILEVERSION 3,15,1,0
PRODUCTVERSION 3,15,1,0
FILEVERSION 3,16,0,0
PRODUCTVERSION 3,16,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "Rebol Console"
VALUE "FileVersion", "3.15"
VALUE "FileVersion", "3.16"
VALUE "InternalName", "Rebol 3 (Oldes branch)"
VALUE "LegalCopyright", "2012 REBOL Technologies"
VALUE "OriginalFilename", "Rebol.exe"
VALUE "ProductName", "Rebol/View"
VALUE "ProductVersion", "3.15"
VALUE "ProductVersion", "3.16"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 4 additions & 4 deletions make/r3.rc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
101 ICON "icon/r3.ico"

1 VERSIONINFO
FILEVERSION 3,15,1,0
PRODUCTVERSION 3,15,1,0
FILEVERSION 3,16,0,0
PRODUCTVERSION 3,16,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "Rebol Console"
VALUE "FileVersion", "3.15"
VALUE "FileVersion", "3.16"
VALUE "InternalName", "Rebol 3 (Oldes branch)"
VALUE "LegalCopyright", "2012 REBOL Technologies"
VALUE "OriginalFilename", "Rebol.exe"
VALUE "ProductName", "Rebol"
VALUE "ProductVersion", "3.15"
VALUE "ProductVersion", "3.16"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion make/rebol3.nest
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ temp: %make/tmp/
stack-size: 4194304 ;= 4MB (4 * 1024 * 1024)
optimize: 2

version: 3.15.1
version: 3.16.0

#if Linux? [ defines: TO_LINUX ]
#if macOS? [ defines: TO_MACOS ]
Expand Down
16 changes: 8 additions & 8 deletions make/tools/make-boot.reb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REBOL [
Title: "Make primary boot files"
Rights: {
Copyright 2012 REBOL Technologies
Copyright 2012-2023 Rebol Open Source Contributors
Copyright 2012-2024 Rebol Open Source Contributors
REBOL is a trademark of REBOL Technologies
}
License: {
Expand Down Expand Up @@ -38,7 +38,7 @@ src: root-dir/src/core
Title:
{REBOL
Copyright 2012 REBOL Technologies
Copyright 2012-2021 Rebol Open Source Contributors
Copyright 2012-2024 Rebol Open Source Contributors
REBOL is a trademark of REBOL Technologies
Licensed under the Apache License, Version 2.0
}
Expand Down Expand Up @@ -924,7 +924,7 @@ foreach section [boot-base boot-sys boot-mezz] [
compose [
sys/load-module/delay (
append
mold/only compose/deep/only [
map-conv-if-needed mold/only compose/deep/only [
Rebol [
Version: (any [select hdr 'version 0.0.0])
Title: (select hdr 'title)
Expand All @@ -935,7 +935,7 @@ foreach section [boot-base boot-sys boot-mezz] [
Needs: (select hdr 'needs)
]
]
mold/only code
map-conv-if-needed mold/only code
)
]
][
Expand Down Expand Up @@ -976,7 +976,7 @@ foreach file first mezz-files [
compose [
sys/load-module/delay (
append
mold/only compose/deep/only [
map-conv-if-needed mold/only compose/deep/only [
Rebol [
Version: (any [select hdr 'version 0.0.0])
Title: (select hdr 'title)
Expand All @@ -987,7 +987,7 @@ foreach file first mezz-files [
Needs: (select hdr 'needs)
]
]
mold/only code
map-conv-if-needed mold/only code
)
]
][
Expand Down Expand Up @@ -1093,13 +1093,13 @@ boot-task: load-boot %task.reb
boot-ops: load-boot %ops.reb
;boot-script: load-boot %script.reb

write-generated gen-dir/gen-boot-code.reb mold reduce sections
write-generated gen-dir/gen-boot-code.reb entab mold reduce sections

data: mold reduce sections
insert data reduce ["; Copyright (C) REBOL Technologies " now newline]
insert tail data make char! 0 ; scanner requires zero termination

data: to binary! data
data: to binary! map-conv-if-needed data
comp-data: compress/level data 'zlib 9

emit [
Expand Down
120 changes: 120 additions & 0 deletions make/tools/map-conv.reb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
REBOL [
Title: "Map and construction syntax literal syntax migration script"
Author: "Oldes"
File: %map-conv.reb
Assert: [
probe "map: #[a: 1 b: #(none)]" == map-conv {map: #(a: 1 b: #[none])}
probe "blk: [#(none) #(true)]" == map-conv {blk: [#[none] #[true]]}
probe "vec: #(uint8! [1 2 3])" == map-conv {vec: #[uint8! [1 2 3]]}
probe "m: #[a: #(none)]#[b: 1]" == map-conv {m: #(a: #[none])#(b: 1)}
probe "#[a: #[b: #(false)]]" == map-conv {#(a: #(b: #[false]))}
probe "#{} #[unset!]" == map-conv {#{} #(unset!)}
probe {#[unset] #"^{" #[true]} == map-conv {#(unset) #"^{" #(true)}
probe {#[unset] "^{" #[true]} == map-conv {#(unset) "^{" #(true)}
probe "#[unset] {^^{} #[true]" == map-conv "#(unset) {^^{} #(true)"
]
Note: "The parser is simplified! Content inside strings and comments is ignored!"
]

map-conv: function/with [
"Swaps map! and construction syntax"
data [binary! string! file!] "(modified)"
][
either file? data [
either dir? data [
process-dir data
][ process-file data ]
][
swap-map-cs data
]
][
pos: none
ch_ignore: complement charset {[](){};#"}
ch_ignore_str1: complement charset "^^{}"
ch_ignore_str2: complement charset {^^"}
rl_paren: [#"(" rl_swap #")"]
rl_block: [#"[" rl_swap #"]"]

rl_in_string1: [any [some ch_ignore_str1 | #"^^" skip | rl_string1]]
rl_in_string2: [any [some ch_ignore_str2 | #"^^" skip]]
rl_string1: [#"{" rl_in_string1 #"}"]
rl_string2: [#"^"" rl_in_string2 #"^""]
rl_comment: [#";" [to LF | to end]]

rl_swap: [
any [
some ch_ignore
| rl_comment
| rl_block
| rl_paren
| rl_string1
| rl_string2
| #"#" pos: [
ahead #"[" (append cons_s index? pos) rl_block pos: (append append cons take/last cons_s index? pos)
| ahead #"(" (append maps_s index? pos) rl_paren pos: (append append maps take/last maps_s index? pos)
| ahead #"{" thru #"}" ;; ignore binaries
| #"^"" [#"^^" #"^"" #"^"" | thru #"^""] ;; ignore chars
| skip
]
| end
]
]

cons: make block! 1000
maps: make block! 1000

;; stacks..
maps_s: make block! 1000
cons_s: make block! 1000

process-dir: function [path [file!]][
foreach file read path [
if dir? file [process-dir path/:file]
all [
find [%.reb %.r3] suffix? file
process-file path/:file
]
]
]
process-file: function [file [file!]][
try/with [
print [as-green "File:" as-yellow file]
data: swap-map-cs read file
num-maps: (length? maps) / 2
num-cons: (length? cons) / 2
if any [num-maps > 0 num-cons > 0][
print ["maps:" as-yellow num-maps "cons:" as-yellow num-cons]
write file data
]
][
print as-purple "File conversion failed!"
print system/state/last-error
]
]

swap-map-cs: func[data][
clear cons
clear maps
clear cons_s
clear maps_s
if binary? data [data: to string! data]
unless parse data rl_swap [
print as-purple "File not fully parsed so not modified!"
return data
]
;?? cons
foreach [s e] cons [
change at data s #"("
change at data e - 1 #")"
]
;?? maps
foreach [s e] maps [
change at data s #"["
change at data e - 1 #"]"
]
;print data
data
]
]


13 changes: 12 additions & 1 deletion make/tools/utils.reb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ REBOL [
Title: "Common make-* code"
]


do %map-conv.reb
;-- UTILITIES ----------------------------------------------------------

needs-map-syntax-swap?: map? transcode/one/error "#()"
map-conv-if-needed: func[data][
if needs-map-syntax-swap? [map-conv data]
data
]

print-title: func[msg][if block? msg [msg: reform msg] print rejoin ["^/ [pre-make.r3] ^[[1;35m" msg "^[[m"]]
print-info: func[msg][if block? msg [msg: reform msg] print rejoin [ " [pre-make.r3] ^[[0;32m" msg "^[[m"]]
Expand All @@ -19,6 +24,7 @@ read-file: func[file [file!]][
load-file: func[file [file!] /header][
the-file: find/tail file root-dir ; shortened version
print rejoin [" [pre-make.r3] ^[[0;36mProcessing: ^[[0;31m" the-file "^[[m"]
if needs-map-syntax-swap? [ file: map-conv read file]
try/except [either header [load/header/all file][ load file ]][
sys/log/error 'pre-make.r3 system/state/last-error
quit/return 3
Expand All @@ -29,12 +35,17 @@ load-file: func[file [file!] /header][
write-generated: func[file data][
write file data
print-more ["Generated:^[[33m" to-local-file file]
if all [
needs-map-syntax-swap?
find [%.reb %.r3] suffix? file
][ map-conv file ]
]
save-generated: func[file data /header hdr][
either header [
save/header file data hdr
][ save file data ]
print-more ["Generated:^[[33m" to-local-file file]
if needs-map-syntax-swap? [ map-conv file]
]


Expand Down
2 changes: 1 addition & 1 deletion src/boot/natives.reb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REBOL [
Title: "Native function specs"
Rights: {
Copyright 2012 REBOL Technologies
Copyright 2012-2021 Rebol Open Source Developers
Copyright 2012-2024 Rebol Open Source Developers
REBOL is a trademark of REBOL Technologies
}
License: {
Expand Down
30 changes: 15 additions & 15 deletions src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REBOL [
Title: "System object"
Rights: {
Copyright 2012 REBOL Technologies
Copyright 2012-2023 Rebol Open Source Contributors
Copyright 2012-2024 Rebol Open Source Contributors
REBOL is a trademark of REBOL Technologies
}
License: {
Expand All @@ -26,7 +26,7 @@ build: object [os: os-version: abi: sys: arch: libc: vendor: target: compiler

user: construct [
name: none
data: #()
data: #[]
]

options: object [ ; Options supplied to REBOL during startup
Expand Down Expand Up @@ -61,13 +61,13 @@ options: object [ ; Options supplied to REBOL during startup

; verbosity of logs per service (codecs, schemes)
; 0 = nothing; 1 = info; 2 = more; 3 = debug
log: #[map! [
log: #[
rebol: 1
http: 1
tls: 1
zip: 1
tar: 1
]]
]
domain-name: none ; Specifies system's domain name (used in SMTP scheme so far)
]

Expand Down Expand Up @@ -95,18 +95,18 @@ catalog: object [
secure-min secure-max trace halt cgi boot-level no-window
]
bitsets: object [
crlf: #[bitset! #{0024}] ;charset "^/^M"
space: #[bitset! #{0040000080}] ;charset " ^-"
whitespace: #[bitset! #{0064000080}] ;charset "^/^M^- "
numeric: #[bitset! #{000000000000FFC0}] ;0-9
alpha: #[bitset! #{00000000000000007FFFFFE07FFFFFE0}] ;A-Z a-z
alpha-numeric: #[bitset! #{000000000000FFC07FFFFFE07FFFFFE0}] ;A-Z a-z 0-9
hex-digits: #[bitset! #{000000000000FFC07E0000007E}] ;A-F a-f 0-9
plus-minus: #[bitset! #{000000000014}] ;charset "+-"
crlf: #(bitset! #{0024}) ;charset "^/^M"
space: #(bitset! #{0040000080}) ;charset " ^-"
whitespace: #(bitset! #{0064000080}) ;charset "^/^M^- "
numeric: #(bitset! #{000000000000FFC0}) ;0-9
alpha: #(bitset! #{00000000000000007FFFFFE07FFFFFE0}) ;A-Z a-z
alpha-numeric: #(bitset! #{000000000000FFC07FFFFFE07FFFFFE0}) ;A-Z a-z 0-9
hex-digits: #(bitset! #{000000000000FFC07E0000007E}) ;A-F a-f 0-9
plus-minus: #(bitset! #{000000000014}) ;charset "+-"
; chars which does not have to be url-encoded:
uri: #[bitset! #{000000005BFFFFF5FFFFFFE17FFFFFE2}] ;A-Z a-z 0-9 !#$&'()*+,-./:;=?@_~
uri-component: #[bitset! #{0000000041E6FFC07FFFFFE17FFFFFE2}] ;A-Z a-z 0-9 !'()*-._~
quoted-printable: #[bitset! #{FFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFF}]
uri: #(bitset! #{000000005BFFFFF5FFFFFFE17FFFFFE2}) ;A-Z a-z 0-9 !#$&'()*+,-./:;=?@_~
uri-component: #(bitset! #{0000000041E6FFC07FFFFFE17FFFFFE2}) ;A-Z a-z 0-9 !'()*-._~
quoted-printable: #(bitset! #{FFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFF})
]
checksums: [
; will be filled on boot from `Init_Crypt` in `n-crypt.c
Expand Down
2 changes: 1 addition & 1 deletion src/boot/types.reb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ REBOL [
; Mold - mold format: - self, + type, * typeclass
; Form - form format: above, and f* for special form functions
; Path - it supports various path forms (* for same as typeclass)
; Make - It can be made with #[datatype] method
; Make - It can be made with #(datatype) method

; Datatype Evaluator Typeclass Mold Form Path Make Typesets
;------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/boot/words.reb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REBOL [
Title: "Canonical words"
Rights: {
Copyright 2012 REBOL Technologies
Copyright 2012-2022 Rebol Open Source Contributors
Copyright 2012-2024 Rebol Open Source Contributors
REBOL is a trademark of REBOL Technologies
}
License: {
Expand All @@ -28,7 +28,7 @@ any-object!
any-block!

;- numeric types (used for "short" vector! construction)
;- like: #[u8! 4] which is same like: make vector! [unsigned integer! 8 4]
;- like: #(u8! 4) which is same like: make vector! [unsigned integer! 8 4]
; these numeric files are used in l-types.c and t-vector.c sources
; and can be used for future struct! and routine! implementations
i8!
Expand Down
Loading

0 comments on commit 3c2b93a

Please sign in to comment.