Hello,

As is usual with Factor hacks, the implementation of the syntax I demonstrated 
is concise; it comes in at under 20 lines of code over 5 words. It's included 
below.

Ed

----------------------------------------------------------------------
USING: kernel lexer parser effects.parser
       words namespaces sequences splitting
       accessors multi-methods ;

IN: method-syntax

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: name>word ( name -- word )
  dup in get lookup dup
    [ nip ]
    [ drop in get create ]
  if ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: string>class ( string -- type ) ":" split second search ;

: effect>signature ( effect -- signature ) in>> [ string>class ] map ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: define-method ( word effect quot -- )
  pick define-generic                 ! word effect    quot
  swap effect>signature swap          ! word signature quot
  >r swap create-method r>            ! method quot
  define ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: :
  scan name>word
  scan drop
  ")" parse-effect
  parse-definition
  define-method ;               parsing
----------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to