1# -*- tcl -*- 2# Copyright (c) 2009-2010 Andreas Kupries <andreas_kupries@sourceforge.net> 3 4# Canned configuration for the converter to Tcl/PARAM representation, 5# causing generation of a proper snit class. 6 7# # ## ### ##### ######## ############# ##################### 8## Requirements 9 10package require Tcl 8.5 ; # Required runtime. 11 12# # ## ### ##### ######## ############# ##################### 13## 14 15namespace eval ::pt::tclparam::configuration::snit { 16 namespace export def 17 namespace ensemble create 18} 19 20# # ## ### ##### ######## ############# 21## Public API 22 23# Check that the proposed serialization of an abstract syntax tree is 24# indeed such. 25 26proc ::pt::tclparam::configuration::snit::def {class pkg cmd} { 27 28 # TODO :: See if we can consolidate the API for converters, 29 # TODO :: plugins, export manager, and container in some way. 30 # TODO :: Container may make exporter manager available through 31 # TODO :: public method. 32 33 # class : is actually the name of the package to generate, and 34 # will be prefixed with :: to make it a proper absolute 35 # class and Tcl namespace name. 36 37 {*}$cmd -runtime-command {$myparser} 38 #{*}$cmd -self-command {$self} 39 #{*}$cmd -proc-command method 40 {*}$cmd -self-command {} 41 {*}$cmd -proc-command proc 42 {*}$cmd -prelude {upvar 1 myparser myparser} 43 {*}$cmd -namespace {} 44 {*}$cmd -main MAIN 45 {*}$cmd -indent 4 46 {*}$cmd -template [string trim \ 47 [string map \ 48 [list \ 49 @@PKG@@ $pkg \ 50 @@CLASS@@ $class \ 51 \n\t \n \ 52 ] { 53 ## -*- tcl -*- 54 ## 55 ## Snit-based Tcl/PARAM implementation of the parsing 56 ## expression grammar 57 ## 58 ## @name@ 59 ## 60 ## Generated from file @file@ 61 ## for user @user@ 62 ## 63 # # ## ### ##### ######## ############# ##################### 64 ## Requirements 65 66 package require Tcl 8.5 67 package require snit 68 package require pt::rde ; # Implementation of the PARAM 69 # virtual machine underlying the 70 # Tcl/PARAM code used below. 71 72 # # ## ### ##### ######## ############# ##################### 73 ## 74 75 snit::type ::@@CLASS@@ { 76 # # ## ### ##### ######## ############# 77 ## Public API 78 79 constructor {} { 80 # Create the runtime supporting the parsing process. 81 set myparser [pt::rde ${selfns}::ENGINE] 82 return 83 } 84 85 method parse {channel} { 86 $myparser reset $channel 87 MAIN ; # Entrypoint for the generated code. 88 return [$myparser complete] 89 } 90 91 method parset {text} { 92 $myparser reset 93 $myparser data $text 94 MAIN ; # Entrypoint for the generated code. 95 return [$myparser complete] 96 } 97 98 # # ## ### ###### ######## ############# 99 ## Configuration 100 101 pragma -hastypeinfo 0 102 pragma -hastypemethods 0 103 pragma -hasinfo 0 104 pragma -simpledispatch 1 105 106 # # ## ### ###### ######## ############# 107 ## Data structures. 108 109 variable myparser {} ; # Our instantiation of the PARAM. 110 111 # # ## ### ###### ######## ############# 112 ## BEGIN of GENERATED CODE. DO NOT EDIT. 113 114@code@ 115 ## END of GENERATED CODE. DO NOT EDIT. 116 # # ## ### ###### ######## ############# 117 } 118 119 # # ## ### ##### ######## ############# ##################### 120 ## Ready 121 122 package provide @@PKG@@ 1 123 return 124 }]] 125 126 return 127} 128 129# # ## ### ##### ######## ############# 130 131namespace eval ::pt::tclparam::configuration::snit {} 132 133# # ## ### ##### ######## ############# ##################### 134## Ready 135 136package provide pt::tclparam::configuration::snit 1 137return 138