Skip to content

Commit

Permalink
TRY instead of OPT/MAYBE in PARSE
Browse files Browse the repository at this point in the history
TRY is as short as OPT and is a "real" word.

MAYBE is also reclaimed for future use.
  • Loading branch information
hostilefork committed Aug 3, 2023
1 parent c2505c6 commit 963e0fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion main.reb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export main: adapt :console [
;
let autorun: null
let importing: false
parse system.options.args [maybe some [
parse system.options.args [try some [
start: <here>
||
; local, remote, tracing_on, git_commit not passed through by the
Expand Down
6 changes: 3 additions & 3 deletions replpad.reb
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ replpad-write: func [
; https://developer.mozilla.org/en-US/docs/Web/CSS/white-space

let url-rule: [
"http" opt "s" ":" to ["]" | ")" | {"} | "'" | space | newline | end]
"http" try "s" ":" to ["]" | ")" | {"} | "'" | space | newline | end]
]

; UPARSE is still orders of magnitude slower than native PARSE. Until that
; is remedied, don't use it for main printing output.

let url
parse3 param: copy param [
maybe some [
try some [
change '< ("&lt;")
| change '> ("&gt;")
| change '& ("&amp;")
Expand Down Expand Up @@ -393,7 +393,7 @@ CORSify-gitlab-port: func [
"/"
emit user: between <here> "/"
emit repo: between <here> "/"
[opt "-/"] ; TBD: figure out what this is for, but skip for now
[try "-/"] ; TBD: figure out what this is for, but skip for now
"raw/"
emit branch: between <here> "/"
emit file_path: between <here> <end>
Expand Down
4 changes: 2 additions & 2 deletions tests/interactive.test.reb
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ k: ok: okay: function [

steps: parse steps [
label: issue!
opt bug: integer! ; optional GitHub issue number
try bug: integer! ; optional GitHub issue number
description: across [some text!] (print description)
opt [code: group! (do as block! code)]
try [code: group! (do as block! code)]
accept <here>
] else [
fail "Problem in STEPS parsing"
Expand Down

0 comments on commit 963e0fc

Please sign in to comment.