1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: lexer sets sequences kernel splitting effects
4 combinators arrays vocabs.parser classes ;
11 : parse-effect-token ( end -- token/f )
12 scan [ nip ] [ = ] 2bi [ drop f ] [
13 dup { f "(" "((" } member? [ bad-effect ] [
16 { [ dup "(" = ] [ drop ")" parse-effect ] }
17 { [ dup search class? ] [ search ] }
18 { [ dup f = ] [ ")" unexpected-eof ] }
25 : parse-effect-tokens ( end -- tokens )
26 [ parse-effect-token dup ] curry [ ] produce nip ;
28 ERROR: stack-effect-omits-dashes effect ;
30 : parse-effect ( end -- effect )
31 parse-effect-tokens { "--" } split1 dup
32 [ <effect> ] [ drop stack-effect-omits-dashes ] if ;
34 : complete-effect ( -- effect )
35 "(" expect ")" parse-effect ;
37 : parse-call( ( accum word -- accum )
38 [ ")" parse-effect ] dip 2array append! ;