1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-16 16:27:40 +00:00

Initial peg implementation. Tree walk interpretted with

no captures, so not yet ready.
This commit is contained in:
Calvin Rose
2019-01-11 19:22:24 -05:00
parent 84fb07dd5a
commit 40845b5c1b
4 changed files with 291 additions and 0 deletions

View File

@@ -153,4 +153,17 @@
(buffer/blit b2 "abcdefg" 5 6)
(assert (= (string b2) "joytogjoyto") "buffer/blit 3")
# Peg
(def ip-address
'{:d (range "09")
:0-4 (range "04")
:0-5 (range "05")
:block (+ (* "25" :0-5) (* "2" :0-4 :d) (* "1" :d :d) (* :d (at-most 1 :d)))
:main (* :block (between 3 3 (* "." :block)))})
(assert (peg/match ip-address "0.0.0.0") "peg/match 1")
(assert (peg/match ip-address "1.2.3.4") "peg/match 2")
(assert (not (peg/match ip-address "256.2.3.4")) "peg/match 3")
(end-suite)