FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pixie/tests/pixie/tests/test-parser.pxi at master · pixie-lang/pixie · GitHub
pixie-lang
/
pixie
Public
Notifications
You must be signed in to change notification settings
Fork
127
Star
2.4k
Code
Issues
46
Pull requests
9
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pixie
/
tests
/
pixie
/
tests
/
test-parser.pxi
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (39 loc) · 1.19 KB
Breadcrumbs
pixie
/
tests
/
pixie
/
tests
/
test-parser.pxi
Copy path
File metadata and controls
46 lines (39 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(ns pixie.tests.test
-
parser
(:require [pixie.test :refer :
all
]
[pixie.parser :refer :
all
]))
(deftest test
-
and
(let [p (parser []
ENTRY (
and
\
a \b <- [\a \b]))
c (string
-
cursor
"
abc
"
)]
(
assert
=
((:ENTRY p) c) [\
a \b])
(
assert
=
(current c) \
c)
(
assert
=
2
(snapshot c))))
(deftest test
-
or
(let [p (parser []
ENTRY (
or
\
b \a))
c (string
-
cursor
"
abc
"
)]
(
assert
=
((:ENTRY p) c) \
a)
(
assert
=
(current c) \
b)
(
assert
=
1
(snapshot c))))
(defparser
as
-
and
-
bs []
ENTRY (
and
S
-
>
value
end
<
-
value)
S (one
+
AB)
<
-
`[:S
~
@value]
AB (
and
A
-
>
a
B
-
>
b
<
-
[:AB a b])
A (one
+
\
a) <- `[:A ~@value]
B (one
+
\
b) <- `[:B ~@value])
(deftest test
-
as
-
and
-
bs
(let [c (string
-
cursor
"
aabbaa
"
)]
(
assert
=
((:S
as
-
and
-
bs) c) [:S [:AB
[:A \
a \a]
[:B \
b \b]]])
(
assert
(
not
(at
-
end? c)))
(
assert
=
(snapshot c)
4
)
(
assert
(failure? ((:S
as
-
and
-
bs) c))))
(let [c (string
-
cursor
"
aabbaa
"
)]
(
assert
(failure? ((:ENTRY
as
-
and
-
bs) c)) )
(
assert
(
not
(at
-
end? c)))
(
assert
=
(snapshot c)
0
)))
Back
|
FazBrowse Home
|
New Git URL