peg.ebnf: fix and a better fix.
							parent
							
								
									63f2f22573
								
							
						
					
					
						commit
						7ab8a787b0
					
				| 
						 | 
					@ -4,7 +4,7 @@ USING: accessors assocs combinators combinators.short-circuit
 | 
				
			||||||
effects kernel make math.parser multiline namespaces parser peg
 | 
					effects kernel make math.parser multiline namespaces parser peg
 | 
				
			||||||
peg.parsers quotations sequences sequences.deep splitting
 | 
					peg.parsers quotations sequences sequences.deep splitting
 | 
				
			||||||
stack-checker strings strings.parser summary unicode.categories
 | 
					stack-checker strings strings.parser summary unicode.categories
 | 
				
			||||||
words ;
 | 
					vocabs.parser words ;
 | 
				
			||||||
FROM: vocabs.parser => search ;
 | 
					FROM: vocabs.parser => search ;
 | 
				
			||||||
FROM: peg.search => replace ;
 | 
					FROM: peg.search => replace ;
 | 
				
			||||||
IN: peg.ebnf
 | 
					IN: peg.ebnf
 | 
				
			||||||
| 
						 | 
					@ -429,7 +429,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
 | 
				
			||||||
            drop
 | 
					            drop
 | 
				
			||||||
        ] [
 | 
					        ] [
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                "FROM: locals => [let :> ; FROM: sequences => nth ; FROM: kernel => nip over ; [let " %
 | 
					                "[let " %
 | 
				
			||||||
                [
 | 
					                [
 | 
				
			||||||
                    over ebnf-var? [
 | 
					                    over ebnf-var? [
 | 
				
			||||||
                        " " % # " over nth :> " %
 | 
					                        " " % # " over nth :> " %
 | 
				
			||||||
| 
						 | 
					@ -447,8 +447,7 @@ M: ebnf-sequence build-locals ( code ast -- code )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
M: ebnf-var build-locals ( code ast -- code )
 | 
					M: ebnf-var build-locals ( code ast -- code )
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
        "FROM: locals => [let :> ; FROM: kernel => dup nip ; [let " %
 | 
					        "[let dup :> " % name>> %
 | 
				
			||||||
        " dup :> " % name>> %
 | 
					 | 
				
			||||||
        " " %
 | 
					        " " %
 | 
				
			||||||
        %
 | 
					        %
 | 
				
			||||||
        " nip ]" %
 | 
					        " nip ]" %
 | 
				
			||||||
| 
						 | 
					@ -470,9 +469,15 @@ ERROR: bad-effect quot effect ;
 | 
				
			||||||
    [ parser>> (transform) ]
 | 
					    [ parser>> (transform) ]
 | 
				
			||||||
    [ code>> insert-escapes ]
 | 
					    [ code>> insert-escapes ]
 | 
				
			||||||
    [ parser>> ] tri build-locals
 | 
					    [ 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
 | 
					    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
 | 
					    [ string-lines parse-lines ] dip
 | 
				
			||||||
    qualified-vocabs set-length ;
 | 
					    dup 3 + qualified-vocabs delete-slice ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
M: ebnf-action (transform) ( ast -- parser )
 | 
					M: ebnf-action (transform) ( ast -- parser )
 | 
				
			||||||
    ebnf-transform check-action-effect action ;
 | 
					    ebnf-transform check-action-effect action ;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue