iRule based 'Natural Speech' Expression Language

Code is community submitted, community supported, and recognized as ‘Use At Your Own Risk’.

Short Description

The major design goal of the 'Natural Speech' expression language is to enable humans to write complex search expressions without having to learn a complicated search language syntax. People may already struggle to articulate what they want to search for, and the addition of complex search expression languages like RegEx can increase this difficulty and require specific education and extensive practice.

Problem solved by this Code Snippet

The 'Natural Speech' expression language addresses this issue by adopting the grammar and syntax of human natural language. 

The TCL procedure provided to execute the 'Natural Speech' interpreter accepts an input string and a 'Natural Speech' expression of your choice, and then returns the evaluation result to an [if] statement to initiate actions.


	if { [call ::ask_natural_speech_if [HTTP::path] {

                                         equals /

                                  leading with /appfolder/ 
                        and contains /somefolder/ or /anotherfolder/ 
                            and /deepfolder1/ or /deepfolder2/
                                and trailing with / or .php 
                                       but exclude 
                             or contains /admin/ nor /upload/

                              starts with /resourcefolder/ 
                            and ends with .jpg or .css or .js

	}] } then {		

		pool mypool

	} else {

		HTTP::respond 403 content "Access Denied" "Content-Type" "text/html"	



Note: I've decided to parse an ordinary HTTP path in this sample integration code because HTTP is a well-known data structure. Don't consider this proof-of-concept as a recommendation to actually use it this way, but feel free to do so if you see an advantage for your deployment.

How to use this Code Snippet

Visit my GitHub Repository for full explanations of the 'Natural Speech' expression language, interpreter and procedure.

Feel free to discuss the project here on CrowSRC!

Cheers, Kai

Code Snippet Meta Information

  1. Version: 1.0
  2. Coding Language: TCL

Full Code Snippet


Published Feb 02, 2023
Version 1.0

Was this article helpful?

No CommentsBe the first to comment