/unmaintained/multi-method-syntax/multi-method-syntax.factor

http://github.com/abeaumont/factor · Factor · 23 lines · 10 code · 9 blank · 4 comment · 0 complexity · a2a85710f6e7862fbe58e05ee180b0be MD5 · raw file

  1. USING: accessors effects.parser kernel lexer multi-methods
  2. parser sequences words ;
  3. IN: multi-method-syntax
  4. ! A nicer specializer syntax to hold us over till multi-methods go in
  5. ! officially.
  6. !
  7. ! Use both 'multi-methods' and 'multi-method-syntax' in that order.
  8. : scan-specializer ( -- specializer )
  9. scan drop ! eat opening parenthesis
  10. ")" parse-effect in>> [ search ] map ;
  11. : CREATE-METHOD ( -- method )
  12. scan-word scan-specializer swap create-method-in ;
  13. : (METHOD:) ( -- method def ) CREATE-METHOD parse-definition ;
  14. : METHOD: (METHOD:) define ; parsing