diff --git a/example.cfg b/example.cfg index e1c4785..6138d19 100644 --- a/example.cfg +++ b/example.cfg @@ -1,17 +1,22 @@ # A 'tconfpy' Example Configuration File # Copyright 2003-2004 TundraWare Inc. -# $Id: example.cfg,v 1.100 2004/04/21 20:39:21 tundra Exp $ +# $Id: example.cfg,v 1.101 2004/04/21 21:03:49 tundra Exp $ # # This is designed to illustrate the various features # of the 'tconfpy' configuration language. # -# Test this out by running the following command +# You can play with this using the 'test-tc.py' test driver +# program. For instance: # -# python test-tc.py debug litvars example.cfg -# OR python test-tc.py symtbl debug litvars example.cfg +# python test-tc.py debug litvars debug example.cfg +# python test-tc.py symtbl litvars debug example.cfg # -# Whitespace is ignored and used here for neatness -# Everything is case-sensitive except values for booleans +# See the 'test-tc.py' documentation for a description of +# the various options it supports. +# +# +# Whitespace is ignored and used here for neatness. +# Everything is case-sensitive except values for booleans. ##### @@ -109,15 +114,19 @@ # Comparison Conditionals ##### -.if .NS2.bar == 100 +# In these examples, notice that the left-hand-side of the comparison +# is a variable *reference*. We want to compare the *value* of the +# variable 'NS.2.bar' to the right-hand-side, not the name of the variable. - ifequ = yup +.if [.NS2.bar] == 100 + + ifequiv = yup .endif -.if .NS2.bar != 1000 +.if [.NS2.bar] != 1000 - ifnotequ = yup + ifnotequiv = yup .endif @@ -126,13 +135,17 @@ # Literal Text Processing ##### +# In this example, notice that any the variables references in the +# literal block ('[HASH]' and '[MyMsg]') only get replaced if you run +# 'test-tc.py' with the 'litvars' option. + MyMsg = Hello World! .ifall [foo] .literal /* Here is some C Code - Variable Refs below replaced only - if litvars option selected from test-tc.py */ + if 'litvars' option selected from test-tc.py */ [HASH]include @@ -144,3 +157,50 @@ .endliteral .endif + + +##### +# Type And Value Enforcement +#### + +# This illustrates 'tconfpy's ability to enforce type and value +# agreement. To make this work, you have to invoke 'test-tc.py' with +# the 'symtbl' argument. This will pass an initial symbol table with +# validation constraints defined for the variables used below. To see +# the permitted values and types of the variables passed when +# 'symbtbl' is used, look at the top part of the 'test-tc.py' source +# code. + +# Some of these examples purposely introduce a type/value +# error to illustrate how 'tconfpy' does validation. + +# Type Enforcement + +int1 = 4s # Error: 'int1' only accepts integers + + +# Value Enforcement + +int1 = 11 # Error: Value must be one of 1, 2, or 23 + + +# Value Enforcement For Namespace Names + +# You can make this fail if you supply 'test-tc.py' the 'limitns' option + +[XYZ] # Error: Namespaces are limited to strings starting with 'NS' +[] # But this always works because the root namespace is always legal + + +# Enforcing String Content + +str1 = box # Fine +str1 = bax # Also Fine +str1 = FunStuff # Error: Does not match any of the validation regular expressions + +# Enforcing String Lengths + +str1 = abc # This is OK +str1 = ab # Too short: must be at least 3 characters long +str1 = abcccccccccccc # Too long: must be 8 or less characters long +