Snipped : a package PARSER.

From: Charles Melice <3d_at_forthcad.com>
Date: Thu, 22 Jun 2006 20:55:37 +0200

\ =====================================================================
\ PARSER compile/execute a word in a wordlist context.
\ =====================================================================

\ It is sometimes risky to open two packages because there is sometimes
\ a possibility to have synonyms.

\ Used in a wordlist context X, the word PARSER define a word which will
\ allow to compile/interpret definitions of this context X.

: PARSER ( "method" -- )
    create context @ , immediate
  does>
    @ bl word count
    rot search-wordlist dup
    0= ABORT" no found in parser context."
    0< state @ and IF compile, ELSE execute THEN ;

\ test

package pack-test

    : i ( n -- ) . ;
    : z ( z -- ) zcount type ;
    : s ( a n -- ) type ;

public

    parser dot>

end-package

\\ test

: test
    3 0 DO
        i dot> i
        z" hello " dot> z
        s" bye " dot> s
        cr
    LOOP ;

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Jun 22 2006 - 11:56:41 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 07-Feb-2012. Archive updated nightly.