File: pt_tclparam_config_snit.tcl

package info (click to toggle)
tcllib 1.14-dfsg-3%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 33,036 kB
  • sloc: tcl: 148,302; ansic: 14,067; sh: 10,320; xml: 1,766; yacc: 753; pascal: 551; makefile: 129; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (141 lines) | stat: -rw-r--r-- 3,675 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*- tcl -*-
# Copyright (c) 2009-2010 Andreas Kupries <andreas_kupries@sourceforge.net>

# Canned configuration for the converter to Tcl/PARAM representation,
# causing generation of a proper snit class.

# The requirements of the embedded template are not our requirements.
# @mdgen NODEP: snit
# @mdgen NODEP: pt::rde

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5              ; # Required runtime.

# # ## ### ##### ######## ############# #####################
##

namespace eval ::pt::tclparam::configuration::snit {
    namespace export   def
    namespace ensemble create
}

# # ## ### ##### ######## #############
## Public API

# Check that the proposed serialization of an abstract syntax tree is
# indeed such.

proc ::pt::tclparam::configuration::snit::def {class pkg cmd} {

    # TODO :: See if we can consolidate the API for converters,
    # TODO :: plugins, export manager, and container in some way.
    # TODO :: Container may make exporter manager available through
    # TODO :: public method.

    # class : is actually the name of the package to generate, and
    #         will be prefixed with :: to make it a proper absolute
    #         class and Tcl namespace name.

    {*}$cmd -runtime-command {$myparser}
    #{*}$cmd -self-command    {$self}
    #{*}$cmd -proc-command    method
    {*}$cmd -self-command    {}
    {*}$cmd -proc-command    proc
    {*}$cmd -prelude         {upvar 1 myparser myparser}
    {*}$cmd -namespace       {}
    {*}$cmd -main            MAIN
    {*}$cmd -indent          4
    {*}$cmd -template        [string trim \
				  [string map \
				       [list \
					    @@PKG@@   $pkg \
					    @@CLASS@@ $class \
					    \n\t \n \
					   ] {
	## -*- tcl -*-
	##
	## Snit-based Tcl/PARAM implementation of the parsing
	## expression grammar
	##
	##	@name@
	##
	## Generated from file	@file@
	##            for user  @user@
	##
	# # ## ### ##### ######## ############# #####################
	## Requirements

	package require Tcl 8.5
	package require snit
	package require pt::rde ; # Implementation of the PARAM
				  # virtual machine underlying the
				  # Tcl/PARAM code used below.

	# # ## ### ##### ######## ############# #####################
	##

	snit::type ::@@CLASS@@ {
	    # # ## ### ##### ######## #############
	    ## Public API

	    constructor {} {
		# Create the runtime supporting the parsing process.
		set myparser [pt::rde ${selfns}::ENGINE]
		return
	    }

	    method parse {channel} {
		$myparser reset $channel
		MAIN ; # Entrypoint for the generated code.
		return [$myparser complete]
	    }

	    method parset {text} {
		$myparser reset
		$myparser data $text
		MAIN ; # Entrypoint for the generated code.
		return [$myparser complete]
	    }

	    # # ## ### ###### ######## #############
	    ## Configuration

	    pragma -hastypeinfo    0
	    pragma -hastypemethods 0
	    pragma -hasinfo        0
	    pragma -simpledispatch 1

	    # # ## ### ###### ######## #############
	    ## Data structures.

	    variable myparser {} ; # Our instantiation of the PARAM.

	    # # ## ### ###### ######## #############
	    ## BEGIN of GENERATED CODE. DO NOT EDIT.

@code@
	    ## END of GENERATED CODE. DO NOT EDIT.
	    # # ## ### ###### ######## #############
	}

	# # ## ### ##### ######## ############# #####################
	## Ready

	package provide @@PKG@@ 1
	return
    }]]

    return
}

# # ## ### ##### ######## #############

namespace eval ::pt::tclparam::configuration::snit {}

# # ## ### ##### ######## ############# #####################
## Ready

package provide pt::tclparam::configuration::snit 1.0.1
return