mirror of
https://github.com/janet-lang/janet
synced 2025-10-24 12:17:41 +00:00
Update peg doc and remame some peg specials.
This commit is contained in:
@@ -222,7 +222,7 @@
|
||||
(file/flush stderr)
|
||||
(file/flush stdout)
|
||||
|
||||
(def grammar '(| (any (+ (/ "dog" "purple panda") 1))))
|
||||
(def grammar '(% (any (+ (/ "dog" "purple panda") 1))))
|
||||
(defn try-grammar [text]
|
||||
(assert (= (string/replace-all "dog" "purple panda" text) (0 (peg/match grammar text))) text))
|
||||
|
||||
@@ -238,8 +238,8 @@
|
||||
|
||||
(def csv
|
||||
'{:field (+
|
||||
(* `"` (| (any (+ (if-not `"` 1) (/ `""` `"`)))) `"`)
|
||||
(| (any (if-not (set ",\n") 1))))
|
||||
(* `"` (% (any (+ (if-not `"` 1) (/ `""` `"`)))) `"`)
|
||||
(% (any (if-not (set ",\n") 1))))
|
||||
:main (* :field (any (* "," :field)) (+ "\n" -1))})
|
||||
|
||||
(defn check-csv
|
||||
@@ -258,7 +258,7 @@
|
||||
|
||||
# Functions in grammar
|
||||
|
||||
(def grmr-triple ~(| (any (/ (<- 1) ,(fn [x] (string x x x))))))
|
||||
(def grmr-triple ~(% (any (/ (<- 1) ,(fn [x] (string x x x))))))
|
||||
(check-deep grmr-triple "abc" @["aaabbbccc"])
|
||||
(check-deep grmr-triple "" @[""])
|
||||
(check-deep grmr-triple " " @[" "])
|
||||
|
||||
Reference in New Issue
Block a user