Richard Fobes > Language-Dashrep-2.33 > Language::Dashrep

Download:
Language-Dashrep-2.33.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 2.33   Source  

NAME ^

Language::Dashrep - Dashrep language translator/interpreter

VERSION ^

Version 2.33

SYNOPSIS ^

The following sample code executes the Dashrep-language actions specified in the standard input file.

   use Language::Dashrep;
   &Dashrep::dashrep_linewise_translate( );

The module also supports direct access to functions that define Dashrep phrases, expand text that contains Dashrep phrases, and more.

ABOUT ^

Dashrep (TM) is a versatile descriptive programming language that recognizes hyphenated phrases, such as rectangle-outline-attention-begin, and recursively expands the phrases to generate an HTML web page, an XML file, a JavaScript program, a boilerplate-based document, a template-based email message, or any other text-based content.

See www.Dashrep.org for details about the Dashrep language.

Although Dashrep code is not directly executable, it can generate executable code. Although it does not directly define loops, it generates lists in which any delimited (using commas and/or spaces) list of text strings (including integers) specifies the unique values for the list items. Although the Dashrep language does not directly implement a branching structure, the translated code can be completely changed at any level (including within lists) based on parameterized hyphenated phrases such as [-template-for-move-proposal-link-for-action-[-output-requested-action-]-].

The Dashrep language has been used to convert text files into MML- and XML-format files (for two books, The Creative Problem Solver's Toolbox and Ending The Hidden Unfairness In U.S. Elections), specify dynamically generated HTML pages (at www.VoteFair.org and www.NegotiationTool.com), generate JavaScript code (that Adobe Illustrator executed to generate vector graphics for use in the book Ending The Hidden Unfairness In U.S. Elections), generate invoices and packing slips, expand boilerplate-like text, and more.

The design goals for the Dashrep language were:

EXPORT ^

The following subroutines are exported.

dashrep_define

dashrep_import_replacements

dashrep_get_replacement

dashrep_get_list_of_phrases

dashrep_delete

dashrep_delete_all

dashrep_expand_parameters

dashrep_expand_phrases

dashrep_expand_phrases_except_special

dashrep_expand_special_phrases

dashrep_xml_tags_to_dashrep

dashrep_top_level_action

dashrep_linewise_translate

FUNCTIONS ^

initialize_special_phrases

Initialize the phrases with special "dashrep_..." names.

dashrep_define

Associates a replacement text string with the specified hyphenated phrase.

First parameter is the hyphenated phrase. Second parameter is its replacement text string.

Return value is 1 if the definition is successful. Return value is zero if there are not exactly two parameters.

dashrep_import_replacements

Parses text that associates Dashrep phrases with the definitions for those phrases.

First, and only, parameter is the text string that uses the Dashrep language.

Return value is the count for how many hyphenated phrases were defined (or redefined). Return value is zero if there is not exactly one parameter.

dashrep_get_replacement

Gets/returns the replacement text string that is associated with the specified hyphenated phrase.

First, and only, parameter is the hyphenated phrase.

Return value is the replacement string that is associated with the specified hyphenated phrase. Return value is an empty string if there is not exactly one parameter.

dashrep_get_list_of_phrases

Returns an array that lists all the hyphenated phrases that have been defined so far.

There are no parameters.

Return value is an array that lists all the hyphenated phrases that have been defined. Return value is an empty array if there is not exactly zero parameters.

dashrep_delete

Deletes the specified hyphenated phrase.

First parameter is the hyphenated phrase.

Return value is 1 if the deletion is successful. Return value is zero if there is not exactly one parameter.

dashrep_delete_all

Deletes all the hyphenated phrases.

There are no parameters.

Return value is 1 if the deletion is successful. Return value is zero if there is not exactly zero parameters.

dashrep_expand_parameters

Parses a text string that is written in the Dashrep language and handles parameter replacements and special operations. The special operations must be within "[- ... -]" text strings. If the supplied text string is just a hyphenated phrase, it is expanded to its replacement string. Otherwise, any hyphenated phrase that does not appear within the square-bracket pattern is not replaced. (Those hyphenated phrases must be replaced using either the dashrep_expand_phrases, dashrep_expand_phrases_except_special, or dashrep_expand_special_phrases subroutines.)

First, and only, parameter is the text -- or hyphenated phrase -- that is to be expanded.

Return value is the text after expanding any parameters. Return value is an empty string if there is not exactly one parameter.

dashrep_generate_lists

Internal subroutine, not exported. It is only needed within the Dashrep module.

dashrep_expand_phrases_except_special

Expands the hyphenated phrases in a text string that is written in the Dashrep language -- except the special (built-in) hyphenated phrases that handle spaces, hyphens, tabs, and line breaks, and except the parameterized phrases.

First, and only, parameter is the text string that uses the Dashrep language.

Return value is the expanded text string. Return value is an empty string if there is not exactly one parameter.

dashrep_expand_special_phrases

Expands only the the special (built-in) hyphenated phrases that handle hyphens, tabs, spaces and line breaks,

First, and only, parameter is the text string that contains the special hyphenated phrases.

Return value is the expanded text string. Return value is an empty string if there is not exactly one parameter.

dashrep_expand_phrases

Expands all the hyphenated phrases in a text string that is written in the Dashrep language. This includes expanding the special (built-in) hyphenated phrases that handle spaces, hyphens, and line breaks.

First, and only, parameter is the text string that may contain hyphenated phrases to be expanded.

Return value is the expanded text string. Return value is an empty string if there is not exactly one parameter.

dashrep_xml_tags_to_dashrep

Converts a single line of XML code into Dashrep code in which XML tags are replaced by Dashrep phrases. Tags are replaced by hyphenated phrases that are named according to the accumulated XML tag names, with "begin-" and "end-" to indicate the beginning and ending tags. The prefix "begin-and-end-" indicates a self-terminating XML tag (e.g. "<br />"). If the resulting phrase has a Dashrep definition, that definition (which is assumed to be a single phrase) is used instead. If the non-tag content contains any hyphens, they are replaced with the phrase "hyphen-here". If a tag's opening bracket (<) and closing bracket (>) are not both on the same line, the tag will not be recognized.

dashrep_top_level_action

Handles a top-level action such as a transfer to and from files.

First, and only, parameter is the text string that contains any text, which may include one top-level action (which is a hyphenated phrase).

Return value is the text string after removing the executed action, or the original text string if there was no action phrase. Return value is an empty string if there is not exactly one parameter.

dashrep_linewise_translate

Reads from the standard input file, does the specified Dashrep translations, and writes any requested translations into the standard output file.

There are no parameters.

Return value is a text string that is either empty -- if there is no error -- or else contains an error message (although currently no errors are defined).

dashrep_internal_endless_loop_info

Internal subroutine, not exported. It is only needed within the Dashrep module.

dashrep_internal_split_delimited_items

Internal subroutine, not exported. It is only needed within the Dashrep module.

AUTHOR ^

Richard Fobes, "CPSolver" at GitHub.com

DOCUMENTATION ^

See www.Dashrep.org for details about the Dashrep language.

BUGS ^

Please report any bugs or feature requests to "CPSolver" at GitHub.com.

TO DO ^

See www.Dashrep.org for descriptions of possible future developments.

ACKNOWLEDGEMENTS ^

Richard Fobes designed the Dashrep (TM) language and developed the original version of this code over a period of many years. Richard Fobes is the author of the book titled The Creative Problem Solver's Toolbox.

COPYRIGHT & LICENSE ^

Copyright 2009 through 2011 Richard Fobes at www.Dashrep.org, all rights reserved.

You can redistribute and/or modify this library module under the Perl Artistic License 2.0, a copy of which is included in the LICENSE file.

Conversions of this code into other languages are also covered by the above license terms.

The Dashrep (TM) name is trademarked by Richard Fobes at www.Dashrep.org to prevent the name from being co-opted.

The Dashrep (TM) language is in the public domain.

syntax highlighting: