1
0
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:
Calvin Rose
2019-01-14 22:17:13 -05:00
parent 1304f9263b
commit 3a9b50ea4a
3 changed files with 45 additions and 36 deletions

View File

@@ -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 " " @[" "])