peg.ebnf: fix and a better fix.

locals-and-roots
John Benediktsson 2016-03-28 17:03:40 -07:00
parent 63f2f22573
commit 7ab8a787b0
1 changed files with 10 additions and 5 deletions

View File

@ -4,7 +4,7 @@ USING: accessors assocs combinators combinators.short-circuit
effects kernel make math.parser multiline namespaces parser peg
peg.parsers quotations sequences sequences.deep splitting
stack-checker strings strings.parser summary unicode.categories
words ;
vocabs.parser words ;
FROM: vocabs.parser => search ;
FROM: peg.search => replace ;
IN: peg.ebnf
@ -429,7 +429,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
drop
] [
[
"FROM: locals => [let :> ; FROM: sequences => nth ; FROM: kernel => nip over ; [let " %
"[let " %
[
over ebnf-var? [
" " % # " over nth :> " %
@ -447,8 +447,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
M: ebnf-var build-locals ( code ast -- code )
[
"FROM: locals => [let :> ; FROM: kernel => dup nip ; [let " %
" dup :> " % name>> %
"[let dup :> " % name>> %
" " %
%
" nip ]" %
@ -470,9 +469,15 @@ ERROR: bad-effect quot effect ;
[ parser>> (transform) ]
[ code>> insert-escapes ]
[ parser>> ] tri build-locals
! Add words we need for build-locals, then remove them
! so we don't pollute the manifest qualified-vocabs
! and also so restarts don't add multiple times
qualified-vocabs length
"locals" { "[let" ":>" } add-words-from
"kernel" { "dup" "nip" "over" } add-words-from
"sequences" { "nth" } add-words-from
[ string-lines parse-lines ] dip
qualified-vocabs set-length ;
dup 3 + qualified-vocabs delete-slice ;
M: ebnf-action (transform) ( ast -- parser )
ebnf-transform check-action-effect action ;