factor/library/syntax/parser.factor

21 lines
521 B
Factor
Raw Normal View History

! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
2004-07-16 02:26:21 -04:00
IN: parser
USING: kernel lists namespaces sequences words ;
: parse-loop ( -- )
scan-word [
dup parsing? [ execute ] [ swons ] ifte parse-loop
] when* ;
: (parse) ( str -- )
"line" set 0 "col" set
parse-loop
"line" off "col" off ;
2004-07-18 19:52:01 -04:00
: parse ( str -- code )
2004-07-16 02:26:21 -04:00
#! Parse the string into a parse tree that can be executed.
2005-03-25 21:43:06 -05:00
[ f swap (parse) reverse ] with-parser ;
2005-03-25 21:43:06 -05:00
: eval ( "X" -- X ) parse call ;