1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-27 00:40:26 +00:00

Merge pull request #1116 from sogaiu/tweak-long-string-peg

Tweak long-string|bytes peg in test suite files
This commit is contained in:
Calvin Rose 2023-04-30 16:21:12 -05:00 committed by GitHub
commit 02c7cd0194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -349,7 +349,7 @@
(def janet-longstring (def janet-longstring
~{:delim (some "`") ~{:delim (some "`")
:open (capture :delim :n) :open (capture :delim :n)
:close (cmt (* (not (> -1 "`")) (-> :n) (<- :delim)) ,=) :close (cmt (* (not (> -1 "`")) (-> :n) (<- (backmatch :n))) ,=)
:main (* :open (any (if-not :close 1)) :close -1)}) :main (* :open (any (if-not :close 1)) :close -1)})
(check-match janet-longstring "`john" false) (check-match janet-longstring "`john" false)
@ -359,6 +359,7 @@
(check-match janet-longstring "`` ``" true) (check-match janet-longstring "`` ``" true)
(check-match janet-longstring "``` `` ```" true) (check-match janet-longstring "``` `` ```" true)
(check-match janet-longstring "`` ```" false) (check-match janet-longstring "`` ```" false)
(check-match janet-longstring "`a``b`" false)
# Line and column capture # Line and column capture

View File

@ -60,7 +60,7 @@
:buffer (/ '(* "@" :bytes) (constant :string)) :buffer (/ '(* "@" :bytes) (constant :string))
:long-bytes {:delim (some "`") :long-bytes {:delim (some "`")
:open (capture :delim :n) :open (capture :delim :n)
:close (cmt (* (not (> -1 "`")) (-> :n) ':delim) ,=) :close (cmt (* (not (> -1 "`")) (-> :n) '(backmatch :n)) ,=)
:main (drop (* :open (any (if-not :close 1)) :close))} :main (drop (* :open (any (if-not :close 1)) :close))}
:long-string (/ ':long-bytes (constant :string)) :long-string (/ ':long-bytes (constant :string))
:long-buffer (/ '(* "@" :long-bytes) (constant :string)) :long-buffer (/ '(* "@" :long-bytes) (constant :string))