Handbook
Glossary
(transform) ( ast -- parser )
Vocabulary
peg
.
ebnf
.
private
Inputs
ast
an
object
Outputs
parser
an
object
Definition
IN:
peg.ebnf.private
GENERIC:
(transform)
( ast -- parser )
Methods
USING:
peg
peg.ebnf.private
;
M:
ebnf-action
(transform)
ebnf-transform
check-action-effect
action
;
USING:
accessors
combinators
kernel
peg.ebnf.private
;
M:
ebnf-any-character
(transform)
drop
tokenizer
any>>
( -- parser )
call-effect
;
USING:
accessors
peg
peg.ebnf.private
sequences
;
M:
ebnf-choice
(transform)
options>>
[
(transform)
]
map
choice
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-ensure-not
(transform)
transform-group
ensure-not
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-ensure
(transform)
transform-group
ensure
;
USING:
accessors
combinators
kernel
peg.ebnf
peg.ebnf.private
vocabs.parser
;
M:
ebnf-foreign
(transform)
dup
word>>
search
[
word>>
ebnf-foreign-not-found
]
unless*
swap
rule>>
[
main
]
unless*
over
rule
[
nip
]
[
( -- parser )
execute-effect
]
if*
;
USING:
kernel
peg
peg.ebnf.private
;
M:
ebnf-ignore
(transform)
transform-group
[
drop
ignore
]
action
;
USING:
accessors
assocs
kernel
namespaces
peg
peg.ebnf.private
;
M:
ebnf-non-terminal
(transform)
symbol>>
parser
get
[
[
dup
]
curry
]
dip
[
at
[
parser-not-found
]
unless*
nip
]
curry
compose
box
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-optional
(transform)
transform-group
optional
;
USING:
accessors
peg.ebnf.private
peg.parsers
;
M:
ebnf-range
(transform)
pattern>>
range-pattern
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-repeat0
(transform)
transform-group
repeat0
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-repeat1
(transform)
transform-group
repeat1
;
USING:
accessors
kernel
namespaces
peg
peg.ebnf.private
;
M:
ebnf-rule
(transform)
dup
elements>>
(transform)
[
swap
symbol>>
dup
get
parser?
[
redefined-rule
]
[
set
]
if
]
keep
;
USING:
peg
peg.ebnf.private
;
M:
ebnf-semantic
(transform)
ebnf-transform
semantic
;
USING:
accessors
kernel
namespaces
peg
peg.ebnf.private
sequences
;
M:
ebnf-sequence
(transform)
elements>>
[
f
ignore-ws
[
(transform)
]
with-variable
ignore-ws
get
[
sp
]
when
]
map
seq
[
dup
length
1
=
[
first
]
when
]
action
;
USING:
accessors
combinators
peg.ebnf.private
;
M:
ebnf-terminal
(transform)
symbol>>
tokenizer
one>>
( symbol -- parser )
call-effect
;
USING:
accessors
kernel
namespaces
peg.ebnf.private
peg.parsers
;
M:
ebnf-tokenizer
(transform)
elements>>
dup
"default"
=
[
drop
default-tokenizer
\
tokenizer
set-global
any-char
]
[
(transform)
dup
parser-tokenizer
\
tokenizer
set-global
]
if
;
USING:
accessors
peg.ebnf.private
;
M:
ebnf-var
(transform)
parser>>
(transform)
;
USING:
namespaces
peg.ebnf.private
;
M:
ebnf-whitespace
(transform)
t
ignore-ws
[
transform-group
]
with-variable
;
USING:
accessors
peg.ebnf.private
sequences
;
M:
ebnf
(transform)
rules>>
[
(transform)
]
map
last
;