"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/docs/users_guide/parserInstructions.rst" (20 Apr 2021, 2182 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "parserInstructions.rst": 3-3.1.0_vs_3-3.2.0.

Instructions to the Parser/Compiler

#breakpoint

Syntax:

#breakpoint

{#breakpoint} is a debugging tool that tells the parser to stop parsing at a specific point. All source code from that point on will be ignored.

The difference between {#breakpoint} and {#stop} is that {#stop} occurs in normal templates (e.g., inside an {#if}) but {#breakpoint} is used only when debugging Cheetah. Another difference is that {#breakpoint} operates at compile time, while {#stop} is executed at run time while filling the template.

#compiler-settings

Syntax:

#compiler-settings
key = value    (no quotes)
#end compiler-settings

#compiler-settings reset

The {#compiler-settings} directive overrides Cheetah's standard settings, changing how it parses source code and generates Python code. This makes it possible to change the behaviour of Cheetah's parser/compiler for a certain template, or within a portion of the template.

The {reset} argument reverts to the default settings. With {reset}, there's no end tag.

Here are some examples of what you can do:

$myVar
#compiler-settings
cheetahVarStartToken = @
#end compiler-settings
@myVar
#compiler-settings reset
$myVar
## normal comment
#compiler-settings
commentStartToken = //
#end compiler-settings

// new style of comment

#compiler-settings reset

## back to normal comments
#slurp
#compiler-settings
directiveStartToken = %
#end compiler-settings

%slurp
%compiler-settings reset

#slurp

Here's a partial list of the settings you can change:

  1. syntax settings
    1. cheetahVarStartToken
    2. commentStartToken
    3. multilineCommentStartToken
    4. multilineCommentEndToken
    5. directiveStartToken
    6. directiveEndToken
  2. code generation settings
    1. commentOffset
    2. outputRowColComments
    3. defDocStrMsg
    4. useNameMapper
    5. useAutocalling
    6. reprShortStrConstants
    7. reprNewlineThreshold

The meaning of these settings and their default values will be documented in the future.