]> gitweb.factorcode.org Git - factor.git/blob - basis/listener/listener-docs.factor
Solution to Project Euler problem 65
[factor.git] / basis / listener / listener-docs.factor
1 USING: help.markup help.syntax kernel io system prettyprint continuations ;
2 IN: listener
3
4 ARTICLE: "listener-watch" "Watching variables in the listener"
5 "The listener prints the concepts of the data and retain stacks after every expression. It can also print values of dynamic variables which are added to a watch list:"
6 { $subsection visible-vars }
7 "To add or remove a single variable:"
8 { $subsection show-var }
9 { $subsection hide-var }
10 "To add and remove multiple variables:"
11 { $subsection show-vars }
12 { $subsection hide-vars }
13 "Hiding all visible variables:"
14 { $subsection hide-all-vars } ;
15
16 HELP: only-use-vocabs
17 { $values { "vocabs" "a sequence of vocabulary specifiers" } }
18 { $description "Replaces the current manifest's vocabulary search path with the given set of vocabularies." } ;
19
20 HELP: show-var
21 { $values { "var" "a variable name" } }
22 { $description "Adds a variable to the watch list; its value will be printed by the listener after every expression." } ;
23
24 HELP: show-vars
25 { $values { "seq" "a sequence of variable names" } }
26 { $description "Adds a sequence of variables to the watch list; their values will be printed by the listener after every expression." } ;
27
28 HELP: hide-var
29 { $values { "var" "a variable name" } }
30 { $description "Removes a variable from the watch list." } ;
31
32 HELP: hide-vars
33 { $values { "seq" "a sequence of variable names" } }
34 { $description "Removes a sequence of variables from the watch list." } ;
35
36 HELP: hide-all-vars
37 { $description "Removes all variables from the watch list." } ;
38
39 ARTICLE: "listener" "The listener"
40 "The listener evaluates Factor expressions read from a stream. The listener is the primary interface to the Factor runtime. Typically, you write Factor code in a text editor, then load it using the listener and test it."
41 $nl
42 "The classical first program can be run in the listener:"
43 { $example "\"Hello, world\" print" "Hello, world" }
44 "Multi-line expressions are supported:"
45 { $example "{ 1 2 3 } [\n    .\n] each" "1\n2\n3" }
46 "The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them."
47 { $subsection "listener-watch" }
48 "To start a nested listener:"
49 { $subsection listener }
50 "To exit the listener, invoke the " { $link return } " word."
51 $nl
52 "Multi-line quotations can be read independently of the rest of the listener:"
53 { $subsection read-quot } ;
54
55 ABOUT: "listener"
56
57 HELP: read-quot
58 { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } }
59 { $description "Reads a Factor expression which possibly spans more than one line from " { $link input-stream } ". Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ;
60
61 HELP: listener
62 { $description "Prompts for expressions on " { $link input-stream } " and evaluates them until end of file is reached." } ;