adp-parser-procs.tcl

Routines for a pure-Tcl parser supporting an ADP-like syntax. Tags are registered with doc_register_adptag. To use the parser, either

  • Use doc_adp_execute -file to execute an ADP file, or
  • Compile an ADP using doc_adp_compile, and use doc_adp_execute to executed the compiled ADP.
Differences from the standard ADP parser include:
  • In handlers for balanced tags (<some-tag> ... </some-tag>), the second argument is not an ADP string, but rather with a handle to ADP code which should be executed with doc_adp_execute in order for the handler to recursively evaluate code.
  • ADPs are never evaluated in the same stack frame as when doc_adp_execute is invoked; each recursively executed ADP code receives its own stack frame as well. This can probably be worked around, if necessary, with a little uplevel magic.
Location:
packages/acs-tcl/tcl/adp-parser-procs.tcl
Created:
26 June 2000
Author:
Jon Salz <jsalz@mit.edu>
CVS Identification:
$Id: adp-parser-procs.tcl,v 1.7 2024/09/11 06:15:48 gustafn Exp $

Procedures in this file

Detailed information

doc_adp_abort (public)

 doc_adp_abort

Aborts evaluation of an ADP block.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

doc_adp_append_code (private)

 doc_adp_append_code line

Helper procedure to append a line of code to the Tcl translation of an ADP. Adds the line of code to the caller's $code variable, indenting depending on the size of the caller's $balanced_tag_stack.

Parameters:
line (required)

Partial Call Graph (max 5 caller/called nodes):
%3 doc_adp_compile doc_adp_compile (public) doc_adp_append_code doc_adp_append_code doc_adp_compile->doc_adp_append_code doc_adp_flush_text_buffer doc_adp_flush_text_buffer (private) doc_adp_flush_text_buffer->doc_adp_append_code

Testcases:
No testcase defined.

doc_adp_compile (public)

 doc_adp_compile adp

Compiles a block of ADP code.

Parameters:
adp (required)
Returns:
a value which can be passed to doc_adp_execute to run the ADP.

Partial Call Graph (max 5 caller/called nodes):
%3 doc_adp_execute_file doc_adp_execute_file (public) doc_adp_compile doc_adp_compile doc_adp_execute_file->doc_adp_compile doc_adp_append_code doc_adp_append_code (private) doc_adp_compile->doc_adp_append_code doc_adp_flush_text_buffer doc_adp_flush_text_buffer (private) doc_adp_compile->doc_adp_flush_text_buffer doc_adp_quote_tcl_string doc_adp_quote_tcl_string (private) doc_adp_compile->doc_adp_quote_tcl_string

Testcases:
No testcase defined.

doc_adp_execute (public)

 doc_adp_execute compiled_adp

Evaluates an ADP block returned by doc_adp_compile. May be invoked recursively by tag handlers.

Parameters:
compiled_adp (required)

Partial Call Graph (max 5 caller/called nodes):
%3 doc_eval_in_separate_frame doc_eval_in_separate_frame (private) doc_adp_execute doc_adp_execute doc_adp_execute->doc_eval_in_separate_frame

Testcases:
No testcase defined.

doc_adp_execute_file (public)

 doc_adp_execute_file [ -no_cache ] file_name

Compiles and executes an ADP file. Caches the results of compilation unless -no_cache is specified.

Switches:
-no_cache (optional, boolean)
Parameters:
file_name (required)

Partial Call Graph (max 5 caller/called nodes):
%3 _ _ (public) ad_file ad_file (public) doc_adp_compile doc_adp_compile (public) doc_adp_execute_file doc_adp_execute_file doc_adp_execute_file->_ doc_adp_execute_file->ad_file doc_adp_execute_file->doc_adp_compile

Testcases:
No testcase defined.

doc_adp_flush_text_buffer (private)

 doc_adp_flush_text_buffer

Helper procedure to generate a doc_adp_puts call for any text remaining in the text buffer.

Partial Call Graph (max 5 caller/called nodes):
%3 doc_adp_compile doc_adp_compile (public) doc_adp_flush_text_buffer doc_adp_flush_text_buffer doc_adp_compile->doc_adp_flush_text_buffer doc_adp_append_code doc_adp_append_code (private) doc_adp_flush_text_buffer->doc_adp_append_code doc_adp_quote_tcl_string doc_adp_quote_tcl_string (private) doc_adp_flush_text_buffer->doc_adp_quote_tcl_string

Testcases:
No testcase defined.

doc_adp_puts (public)

 doc_adp_puts value

Puts a string in the current ADP context.

Parameters:
value (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

doc_adp_quote_tcl_string (private)

 doc_adp_quote_tcl_string string

Turns literal text into a string which can be used as a Tcl argument. Quotes special Tcl characters and newlines.

Parameters:
string (required)

Partial Call Graph (max 5 caller/called nodes):
%3 doc_adp_compile doc_adp_compile (public) doc_adp_quote_tcl_string doc_adp_quote_tcl_string doc_adp_compile->doc_adp_quote_tcl_string doc_adp_flush_text_buffer doc_adp_flush_text_buffer (private) doc_adp_flush_text_buffer->doc_adp_quote_tcl_string

Testcases:
No testcase defined.

doc_eval_in_separate_frame (private)

 doc_eval_in_separate_frame __code

Evaluates __code in a separate stack frame.

Parameters:
__code (required)

Partial Call Graph (max 5 caller/called nodes):
%3 doc_adp_execute doc_adp_execute (public) doc_eval_in_separate_frame doc_eval_in_separate_frame doc_adp_execute->doc_eval_in_separate_frame

Testcases:
No testcase defined.

doc_register_adptag (public)

 doc_register_adptag [ -literal ] [ -balanced ] tag handler

Registers a handler for an ADP tag.

Switches:
-literal (optional, boolean)
should the handler for a balanced tag accept as its second argument the contents of the block (literally) rather than code to execute? Useful when the contents may contain registered tags which we do not want to be interpreted (e.g., declaring templates with <template>.
-balanced (optional, boolean)
Parameters:
tag (required)
handler (required)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ show source ]