File: yencode.pcx

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (78 lines) | stat: -rw-r--r-- 2,926 bytes parent folder | download | duplicates (9)
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
# -*- tcl -*- yencode.pcx
# Syntax of the commands provided by package yencode.
#
# For use by TclDevKit's static syntax checker.
# See http://www.activestate.com/solutions/tcl/
# See http://aspn.activestate.com/ASPN/docs/Tcl_Dev_Kit/4.0/Checker.html#pcx_api
# for the documentation describing the format of the code contained in this file
#

package require pcx
pcx::register yencode
pcx::tcldep   1.1.1 needs tcl 8.2

namespace eval ::yencode {}

# Using the indirections below looks to be quite pointless, given that
# they simply substitute the commands for others. I am doing this for
# two reasons.

# First, the rules coming after become self-commenting, i.e. a
# maintainer can immediately see what an argument is supposed to be,
# instead of having to search elsewhere (like the documentation and
# implementation). In this manner our definitions here are a type of
# semantic markup.

# The second reason is that while we have no special checks now we
# cannot be sure if such will (have to) be added in the future. With
# all checking routed through our definitions we now already have the
# basic infrastructure (i.e. hooks) in place in which we can easily
# add any new checks by simply redefining the relevant command, and
# all the rules update on their own. Mostly. This should cover 90% of
# the cases. Sometimes new checks will require to create deeper
# distinctions between different calls of the same thing. For such we
# may have to update the rules as well, to provide the necessary
# information to the checker.

interp alias {} yencode::checkMode        {} checkWord    ; #
interp alias {} yencode::checkDstFilename {} checkWord    ; #
interp alias {} yencode::checkData        {} checkWord    ; #
interp alias {} yencode::checkLineLength  {} checkInt     ; #
interp alias {} yencode::checkCrc32Flag   {} checkBoolean ; #

#pcx::message FOO {... text ...} type
#pcx::scan <VERSION> <NAME> <RULE>

pcx::check 1.1.1 std ::yencode::ydecode \
    {checkConstrained {checkSimpleArgs 1 -1 {
	{checkSwitches 1 {
	    {-filename {checkSetConstraint hasfilename checkFileName}}
	    --
	} {checkConstraint {
	    {hasfilename  {checkSimpleArgs 0 0 {}}}
	    {!hasfilename {checkSimpleArgs 1 1 {
		yencode::checkData
	    }}}
	} {}}}
    }}}
# TODO: Limit -mode to a octal numbers (file permissions)
pcx::check 1.1.1 std ::yencode::yencode \
    {checkConstrained {checkSimpleArgs 1 -1 {
	{checkSwitches 1 {
	    {-crc32    yencode::checkCrc32Flag}
	    {-line     yencode::checkLineLength}
	    {-mode     yencode::checkMode}
	    {-name     yencode::checkDstFilename}
	    {-filename {checkSetConstraint hasfilename checkFileName}}
	    --
	} {checkConstraint {
	    {hasfilename  {checkSimpleArgs 0 0 {}}}
	    {!hasfilename {checkSimpleArgs 1 1 {
		yencode::checkData
	    }}}
	} {}}}
    }}}

# Initialization via pcx::init.
# Use a ::yencode::init procedure for non-standard initialization.
pcx::complete