literate: adding some literate programming ideas.

db4
John Benediktsson 2012-08-29 12:17:25 -07:00
parent aa7790c645
commit e623888a5f
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -0,0 +1,25 @@
! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: accessors combinators.short-circuit compiler.units kernel
lexer math multiline parser sequences splitting ;
IN: literate
TUPLE: literate-lexer < lexer ;
: <literate-lexer> ( text -- lexer ) literate-lexer new-lexer ;
M: literate-lexer skip-blank
dup column>> zero? [
dup line-text>> [
"> " head?
[ [ 2 + ] change-column call-next-method ]
[ [ nip length ] change-lexer-column ]
if
] [ drop ] if*
] [ call-next-method ] if ;
SYNTAX: <LITERATE
"LITERATE>" parse-multiline-string string-lines [
<literate-lexer> (parse-lines) over push-all
] with-nested-compilation-unit ;

View File

@ -0,0 +1 @@
Literate programming techniques