1# -*- tcl -*-
2# -- $Id: reader_hb.tcl,v 1.1 2005/09/28 04:51:22 andreas_kupries Exp $ ---
3#
4# PAGE plugin - reader - HB ~ Half baked PEG Container
5#
6
7# ### ### ### ######### ######### #########
8## Imported API
9
10# -----------------+--
11# page_read        | Access to the input stream.
12# page_read_done   |
13# page_eof         |
14# -----------------+--
15# page_info        | Reporting to the user.
16# page_warning     |
17# page_error       |
18# -----------------+--
19# page_log_error   | Reporting of internals.
20# page_log_warning |
21# page_log_info    |
22# -----------------+--
23
24# ### ### ### ######### ######### #########
25## Exported API
26
27# -----------------+--
28# page_rfeature    | Query for special plugin features page might wish to use.
29# page_rtime       | Activate collection of timing statistics.
30# page_rgettime    | Return the collected timing statistics.
31# page_rlabel      | User readable label for the plugin.
32# page_rhelp       | Doctools help text for plugin.
33# page_roptions    | Options understood by plugin.
34# page_rconfigure  | Option (re)configuration.
35# page_rdata       | External access to processed input stream.
36# page_rrun        | Process input stream per plugin configuration and hardwiring.
37# -----------------+--
38
39# ### ### ### ######### ######### #########
40## Requisites
41
42package require struct::tree         ; # Data structure.
43package require page::parse::peghb
44
45global usec
46global timed
47set    timed 0
48
49# ### ### ### ######### ######### #########
50## Implementation of exported API
51
52proc page_rlabel {} {
53    return {Halfbaked PEG Container}
54}
55
56proc page_rfeature {key} {
57    return [string eq $key timeable]
58}
59
60proc page_rtime {} {
61    global timed
62    set    timed 1
63    return
64}
65
66proc page_rgettime {} {
67    global  usec
68    return $usec
69}
70
71proc page_rhelp {} {
72    return {}
73}
74
75proc page_roptions {} {
76    return {}
77}
78
79proc page_rconfigure {option value} {
80    return -code error "Cannot set value of unknown option \"$option\""
81}
82
83## proc page_rdata {} {}
84## Created in 'Initialize'
85
86proc page_rrun {} {
87    global timed usec
88    page_log_info "reader/hb/run/parse"
89
90    struct::tree ::tree
91
92    if {$timed} {
93	set usec [lindex [time {
94	    page::parse::peghb [page_read] ::tree
95	}] 0] ; #{}
96    } else {
97	page::parse::peghb [page_read] ::tree
98    }
99    page_read_done
100
101    set ast [::tree serialize]
102    ::tree destroy
103
104    page_log_info "reader/hb/run/ok"
105    return $ast
106}
107
108# ### ### ### ######### ######### #########
109## Internal helper code.
110
111# ### ### ### ######### ######### #########
112## Initialization
113
114package provide page::reader::hb 0.1
115