Print ebnf quotation on error. Fix generated local quotation
parent
f1219c906a
commit
dfa4926a84
|
@ -3,7 +3,8 @@
|
||||||
USING: kernel compiler.units parser words arrays strings math.parser sequences
|
USING: kernel compiler.units parser words arrays strings math.parser sequences
|
||||||
quotations vectors namespaces math assocs continuations peg
|
quotations vectors namespaces math assocs continuations peg
|
||||||
peg.parsers unicode.categories multiline combinators combinators.lib
|
peg.parsers unicode.categories multiline combinators combinators.lib
|
||||||
splitting accessors effects sequences.deep peg.search inference ;
|
splitting accessors effects sequences.deep peg.search inference
|
||||||
|
io.streams.string io prettyprint ;
|
||||||
IN: peg.ebnf
|
IN: peg.ebnf
|
||||||
|
|
||||||
TUPLE: ebnf-non-terminal symbol ;
|
TUPLE: ebnf-non-terminal symbol ;
|
||||||
|
@ -324,7 +325,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
|
||||||
] 2each
|
] 2each
|
||||||
" | " %
|
" | " %
|
||||||
%
|
%
|
||||||
" ]" %
|
" nip ]" %
|
||||||
] "" make
|
] "" make
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
@ -334,7 +335,7 @@ M: ebnf-var build-locals ( code ast -- )
|
||||||
name>> % " [ dup ] " %
|
name>> % " [ dup ] " %
|
||||||
" | " %
|
" | " %
|
||||||
%
|
%
|
||||||
" ]" %
|
" nip ]" %
|
||||||
] "" make ;
|
] "" make ;
|
||||||
|
|
||||||
M: object build-locals ( code ast -- )
|
M: object build-locals ( code ast -- )
|
||||||
|
@ -344,7 +345,12 @@ M: object build-locals ( code ast -- )
|
||||||
dup infer {
|
dup infer {
|
||||||
{ [ dup (( a -- b )) effect<= ] [ drop ] }
|
{ [ dup (( a -- b )) effect<= ] [ drop ] }
|
||||||
{ [ dup (( -- b )) effect<= ] [ drop [ drop ] prepose ] }
|
{ [ dup (( -- b )) effect<= ] [ drop [ drop ] prepose ] }
|
||||||
[ "Bad effect: " swap effect>string append throw ]
|
[
|
||||||
|
[
|
||||||
|
"Bad effect: " write effect>string write
|
||||||
|
" for quotation " write pprint
|
||||||
|
] with-string-writer throw
|
||||||
|
]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
M: ebnf-action (transform) ( ast -- parser )
|
M: ebnf-action (transform) ( ast -- parser )
|
||||||
|
|
Loading…
Reference in New Issue