<commit_before><!--
   Copyright 2007 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<grammar>

	<!-- 
	  | Package:  [root]
	  +-->

	<phrase name="req" impl="org.danann.cernunnos.AttributePhrase"/>
	<doc entry="req">
		<description>Returns the value of the specified attribute from the TaskRequest.  An error will occur if the attribute is not present.</description>
		<example caption="Copies the document at 'http://www.google.com' to the file system location identified by the first argument on the command line">
			<pre><xmp><copy-file location="http://www.google.com" to-file="${req($1)}"/></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  runtime
	  +-->

	<task name="add-grammar" impl="org.danann.cernunnos.runtime.AddGrammarTask"/>
	<doc entry="add-grammar">
		<description>Reads a new Grammar based on the specified resource and overlays the current one with it.  Subtasks will be read and bootstrapped in light of this new Grammar.</description>
	</doc>

	<task name="serialize-grammar" impl="org.danann.cernunnos.runtime.XmlGrammar$SerializeGrammarTask"/>
	<doc entry="serialize-grammar">
		<description>Creates an XML representation of the current grammar and sets it as the value of the 'Attributes.NODE' attribute.</description>
		<example caption="Creates the documentation you are reading (when executed from the root of a Cernunnos source tree)">
			<pre><xmp><serialize-grammar>
    <file-iterator dir="media/grammardoc" excludes="**/*.xsl">
        <copy-file to-dir="docs/grammardoc"/>
    </file-iterator>
    <xslt stylesheet="media/grammardoc/table-of-contents.xsl" to-file="docs/grammardoc/table-of-contents.html"/>
    <node-iterator xpath="entry">
        <xslt stylesheet="media/grammardoc/entry.xsl" to-file="docs/grammardoc/entries/${valueOf(name)}.html"/>
    </node-iterator>
</serialize-grammar></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  core
	  +-->

	<phrase name="jexl" impl="org.danann.cernunnos.core.JexlPhrase"/>
	<doc entry="jexl">
		<description>Evaluates the specified JEXL expression and returns the result.  All current request attributes will be visible.</description>
		<example caption="Writes 'Hello World!' to System.out">
			<pre><xmp><echo>${jexl('Hello' + ' World!')}</echo></xmp></pre>
		</example>
	</doc>

	<task name="with-attribute" impl="org.danann.cernunnos.core.SetAttributeTask"/>
	<doc entry="with-attribute">
		<description>Creates a request attribute with the specified name and value, then invokes subtasks.</description>
	</doc>

	<task name="properties" impl="org.danann.cernunnos.core.PropertiesTask"/>
	<doc entry="properties">
		<description>Reads the specified .properties file and makes all of its entries available to subtasks as request attributes.</description>
		<example caption="Reads database connection information from a properties file, makes a connection, writes each name from the 'users' table to the screen">
			<pre><xmp><properties location="build/WEB-INF/classes/properties/rdbm.properties">
    <sql-connection driver="${req(jdbcDriver)}" url="${req(jdbcUrl)}" username="${req(jdbcUser)}" password="${req(jdbcPassword)}">
		<sql-query>
        	<sql>SELECT user_name FROM users</sql>
            <subtasks>
            	<echo>${req(1)}, </echo>
			</subtasks>
		</sql-query>
    </sql-connection>
</properties></xmp></pre>
		</example>
	</doc>

	<task name="crn" impl="org.danann.cernunnos.core.CernunnosTask"/>
	<doc entry="crn">
		<description>Reads, bootstrapps, and exececutes the specified Cernunnos script.</description>
	</doc>

	<task name="echo" impl="org.danann.cernunnos.core.EchoTask"/>
	<doc entry="echo">
		<description>Prints the specified message to the appropriate PrintStream (default is System.out).  You may optionally provide a message prefix and suffix.</description>
		<example caption="Reads database connection information from a properties file, makes a connection, writes each name from the 'users' table to the screen">
			<pre><xmp><properties location="build/WEB-INF/classes/properties/rdbm.properties">
    <sql-connection driver="${req(jdbcDriver)}" url="${req(jdbcUrl)}" username="${req(jdbcUser)}" password="${<PASSWORD>(<PASSWORD>)}">
		<sql-query>
        	<sql>SELECT user_name FROM users</sql>
            <subtasks>
            	<echo>${req(1)}, </echo>
			</subtasks>
		</sql-query>
    </sql-connection>
</properties></xmp></pre>
		</example>
	</doc>

	<!-- Adds Carriage Return + Line Feed (Windows style) to the end of each message -->
	<task name="echo-ln" impl="org.danann.cernunnos.core.EchoTask" suffix="&#13;&#10;"/>
	<doc entry="echo-ln">
		<description>Prints the specified message, followed by a line feed, to the appropriate PrintStream (default is System.out).  You may optionally provide a message prefix.</description>
		<example caption="Parses a document from the resource at 'properties/db/data.xml', creates a node list from the expression '//table/name', and writes the text value of each node to System.out">
			<pre><xmp><node-iterator source="${doc(properties/db/data.xml)}" xpath="//table/name">
  <echo-ln>${valueOf(.)}</echo-ln>
</node-iterator></xmp></pre>
		</example>
	</doc>

	<task name="process" impl="org.danann.cernunnos.core.ExecuteProcessTask"/>
	<doc entry="process">
		<description>Invokes the specified process from the specified directory.</description>
		<example caption="Invokes the Ant tool to deploy a project.">
			<pre><xmp><process>ant deploy</process></xmp></pre>
		</example>
	</doc>

	<task name="string-replace" impl="org.danann.cernunnos.core.StringReplaceTask"/>
	<doc entry="string-replace">
		<description>Replaces each occurance of REGEX in the specified STRING with the specified REPLACEMENT.  The resulting String will be registered as the 'Attributes.STRING' request attribute.</description>
	</doc>

	<!-- 
	  | Package:  core
	  +-->

	<task name="if" impl="org.danann.cernunnos.flow.IfTask"/>
	<doc entry="if">
		<description>Execustes SUBTASKS if the conditions of TEST are met.</description>
	</doc>

	<!-- 
	  | Package:  io
	  +-->

	<task name="file-iterator" impl="org.danann.cernunnos.io.FileIteratorTask"/>
	<doc entry="file-iterator">
		<description>Builds a collection of file names within a specified directory and iterates over them.  Use optional pattern expressions to specify groups of files to include or exclude.</description>
		<example caption="Copies all files from 'some_folder' to 'another_folder'">
			<pre><xmp><file-iterator dir="some_folder">
  <copy-file to-dir="another_folder"/>
</file-iterator></xmp></pre>
		</example>
	</doc>

	<task name="mkdirs" impl="org.danann.cernunnos.io.MakeDirectoriesTask"/>
	<doc entry="mkdirs">
		<description>Creates any missing directories in the specified path on the local filesystem.</description>
	</doc>

	<task name="copy-file" impl="org.danann.cernunnos.io.CopyFileTask"/>
	<doc entry="copy-file">
		<description>Copies the specified file to the specified location, creating missing directories as necessary.  None of this task's reagents are required, but you will usually want to specify either TO_DIR or TO_FILE.</description>
		<example caption="Copies the document at 'http://www.google.com' to the file 'google_home.html'">
			<pre><xmp><copy-file location="http://www.google.com" to-file="google_home.html"/></xmp></pre>
		</example>
		<example caption="Copies all files from 'some_folder' to 'another_folder'">
			<pre><xmp><file-iterator dir="some_folder">
  <copy-file to-dir="another_folder"/>
</file-iterator></xmp></pre>
		</example>
	</doc>

	<task name="write-file" impl="org.danann.cernunnos.io.WriteFileTask"/>
	<doc entry="write-file">
		<description>Writes the specified content to the specified file.</description>
	</doc>

	<task name="print-stream" impl="org.danann.cernunnos.io.OpenPrintStreamTask"/>
	<doc entry="print-stream">
		<description>Opens a PrintStream that writes to the specified file system location.</description>
		<example caption="Writes 'Hello World!' to the file 'hello.txt'">
			<pre><xmp><print-stream file="hello.txt">
  <echo>Hello World!</echo>
</print-stream></xmp></pre>
		</example>
	</doc>

	<task name="archive-iterator" impl="org.danann.cernunnos.io.ArchiveIteratorTask"/>
	<doc entry="archive-iterator">
		<description>Iterates over the entries found in the specified archive.  Each entry name will be registered as the request attribute 'Attributes.LOCATION' for subtasks.</description>
	</doc>

	<!-- 
	  | Package:  mail
	  +-->

	<task name="send-email" impl="org.danann.cernunnos.mail.SendEmailTask"/>
	<doc entry="send-email">
		<description>Sends an email based on the specified information.</description>
	</doc>

	<!-- 
	  | Package:  net
	  +-->

	<phrase name="url" impl="org.danann.cernunnos.net.UrlPhrase"/>
	<doc entry="url">
		<description>Reads the resource at the specified location, constructs a new Phrase from the content, and returns the result of evaluating the Phrase.</description>
		<example caption="Connects to a database using the password stored in '/C:/passwd.txt', executes the SQL statement specified by the first argument on the command line">
			<pre><xmp><sql-connection driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:hsql://localhost:8887" username="sa" password="${url(/C:/passwd.txt)}">
  <sql-statement sql="${req($1)}"/>
</sql-connection></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  sql
	  +-->
<commit_msg>Added grammar entries for new tasks & phrases.<commit_after><!--
   Copyright 2007 <NAME>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<grammar>

	<!-- 
	  | Package:  [root]
	  +-->

	<phrase name="req" impl="org.danann.cernunnos.AttributePhrase"/>
	<doc entry="req">
		<description>Returns the value of the specified attribute from the TaskRequest.  An error will occur if the attribute is not present.</description>
		<example caption="Copies the document at 'http://www.google.com' to the file system location identified by the first argument on the command line">
			<pre><xmp><copy-file location="http://www.google.com" to-file="${req($1)}"/></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  runtime
	  +-->

	<task name="add-grammar" impl="org.danann.cernunnos.runtime.AddGrammarTask"/>
	<doc entry="add-grammar">
		<description>Reads a new Grammar based on the specified resource and overlays the current one with it.  Subtasks will be read and bootstrapped in light of this new Grammar.</description>
	</doc>

	<task name="serialize-grammar" impl="org.danann.cernunnos.runtime.XmlGrammar$SerializeGrammarTask"/>
	<doc entry="serialize-grammar">
		<description>Creates an XML representation of the current grammar and sets it as the value of the 'Attributes.NODE' attribute.</description>
		<example caption="Creates the documentation you are reading (when executed from the root of a Cernunnos source tree)">
			<pre><xmp><serialize-grammar>
    <file-iterator dir="media/grammardoc" excludes="**/*.xsl">
        <copy-file to-dir="docs/grammardoc"/>
    </file-iterator>
    <xslt stylesheet="media/grammardoc/table-of-contents.xsl" to-file="docs/grammardoc/table-of-contents.html"/>
    <node-iterator xpath="entry">
        <xslt stylesheet="media/grammardoc/entry.xsl" to-file="docs/grammardoc/entries/${valueOf(name)}.html"/>
    </node-iterator>
</serialize-grammar></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  core
	  +-->

	<phrase name="jexl" impl="org.danann.cernunnos.core.JexlPhrase"/>
	<doc entry="jexl">
		<description>Evaluates the specified JEXL expression and returns the result.  All current request attributes will be visible.</description>
		<example caption="Writes 'Hello World!' to System.out">
			<pre><xmp><echo>${jexl('Hello' + ' World!')}</echo></xmp></pre>
		</example>
	</doc>

	<task name="with-attribute" impl="org.danann.cernunnos.core.SetAttributeTask"/>
	<doc entry="with-attribute">
		<description>Creates a request attribute with the specified name and value, then invokes subtasks.</description>
	</doc>

	<task name="properties" impl="org.danann.cernunnos.core.PropertiesTask"/>
	<doc entry="properties">
		<description>Reads the specified .properties file and makes all of its entries available to subtasks as request attributes.</description>
		<example caption="Reads database connection information from a properties file, makes a connection, writes each name from the 'users' table to the screen">
			<pre><xmp><properties location="build/WEB-INF/classes/properties/rdbm.properties">
    <sql-connection driver="${req(jdbcDriver)}" url="${req(jdbcUrl)}" username="${req(jdbcUser)}" password="${<PASSWORD>(<PASSWORD>)}">
		<sql-query>
        	<sql>SELECT user_name FROM users</sql>
            <subtasks>
            	<echo>${req(1)}, </echo>
			</subtasks>
		</sql-query>
    </sql-connection>
</properties></xmp></pre>
		</example>
	</doc>

	<task name="crn" impl="org.danann.cernunnos.core.CernunnosTask"/>
	<doc entry="crn">
		<description>Reads, bootstrapps, and exececutes the specified Cernunnos script.</description>
	</doc>

	<task name="echo" impl="org.danann.cernunnos.core.EchoTask"/>
	<doc entry="echo">
		<description>Prints the specified message to the appropriate PrintStream (default is System.out).  You may optionally provide a message prefix and suffix.</description>
		<example caption="Reads database connection information from a properties file, makes a connection, writes each name from the 'users' table to the screen">
			<pre><xmp><properties location="build/WEB-INF/classes/properties/rdbm.properties">
    <sql-connection driver="${req(jdbcDriver)}" url="${req(jdbcUrl)}" username="${req(jdbcUser)}" password="${req(jdbcPassword)}">
		<sql-query>
        	<sql>SELECT user_name FROM users</sql>
            <subtasks>
            	<echo>${req(1)}, </echo>
			</subtasks>
		</sql-query>
    </sql-connection>
</properties></xmp></pre>
		</example>
	</doc>

	<!-- Adds Carriage Return + Line Feed (Windows style) to the end of each message -->
	<task name="echo-ln" impl="org.danann.cernunnos.core.EchoTask" suffix="&#13;&#10;"/>
	<doc entry="echo-ln">
		<description>Prints the specified message, followed by a line feed, to the appropriate PrintStream (default is System.out).  You may optionally provide a message prefix.</description>
		<example caption="Parses a document from the resource at 'properties/db/data.xml', creates a node list from the expression '//table/name', and writes the text value of each node to System.out">
			<pre><xmp><node-iterator source="${doc(properties/db/data.xml)}" xpath="//table/name">
  <echo-ln>${valueOf(.)}</echo-ln>
</node-iterator></xmp></pre>
		</example>
	</doc>

	<task name="process" impl="org.danann.cernunnos.core.ExecuteProcessTask"/>
	<doc entry="process">
		<description>Invokes the specified process from the specified directory.</description>
		<example caption="Invokes the Ant tool to deploy a project.">
			<pre><xmp><process>ant deploy</process></xmp></pre>
		</example>
	</doc>

	<task name="string-replace" impl="org.danann.cernunnos.core.StringReplaceTask"/>
	<doc entry="string-replace">
		<description>Replaces each occurance of REGEX in the specified STRING with the specified REPLACEMENT.  The resulting String will be registered as the 'Attributes.STRING' request attribute.</description>
	</doc>

	<!-- 
	  | Package:  core
	  +-->

	<task name="if" impl="org.danann.cernunnos.flow.IfTask"/>
	<doc entry="if">
		<description>Execustes SUBTASKS if the conditions of TEST are met.</description>
	</doc>

	<!-- 
	  | Package:  io
	  +-->

	<phrase name="file" impl="org.danann.cernunnos.io.FilePhrase"/>
	<doc entry="file">
		<description>Creates a java.io.File object from thbe specified LOCATION and returns it.</description>
	</doc>

	<task name="file-iterator" impl="org.danann.cernunnos.io.FileIteratorTask"/>
	<doc entry="file-iterator">
		<description>Builds a collection of file names within a specified directory and iterates over them.  Use optional pattern expressions to specify groups of files to include or exclude.</description>
		<example caption="Copies all files from 'some_folder' to 'another_folder'">
			<pre><xmp><file-iterator dir="some_folder">
  <copy-file to-dir="another_folder"/>
</file-iterator></xmp></pre>
		</example>
	</doc>

	<task name="mkdirs" impl="org.danann.cernunnos.io.MakeDirectoriesTask"/>
	<doc entry="mkdirs">
		<description>Creates any missing directories in the specified path on the local filesystem.</description>
	</doc>

	<task name="copy-file" impl="org.danann.cernunnos.io.CopyFileTask"/>
	<doc entry="copy-file">
		<description>Copies the specified file to the specified location, creating missing directories as necessary.  None of this task's reagents are required, but you will usually want to specify either TO_DIR or TO_FILE.</description>
		<example caption="Copies the document at 'http://www.google.com' to the file 'google_home.html'">
			<pre><xmp><copy-file location="http://www.google.com" to-file="google_home.html"/></xmp></pre>
		</example>
		<example caption="Copies all files from 'some_folder' to 'another_folder'">
			<pre><xmp><file-iterator dir="some_folder">
  <copy-file to-dir="another_folder"/>
</file-iterator></xmp></pre>
		</example>
	</doc>

	<task name="write-file" impl="org.danann.cernunnos.io.WriteFileTask"/>
	<doc entry="write-file">
		<description>Writes the specified content to the specified file.</description>
	</doc>

	<task name="print-stream" impl="org.danann.cernunnos.io.OpenPrintStreamTask"/>
	<doc entry="print-stream">
		<description>Opens a PrintStream that writes to the specified file system location.</description>
		<example caption="Writes 'Hello World!' to the file 'hello.txt'">
			<pre><xmp><print-stream file="hello.txt">
  <echo>Hello World!</echo>
</print-stream></xmp></pre>
		</example>
	</doc>

	<task name="archive-iterator" impl="org.danann.cernunnos.io.ArchiveIteratorTask"/>
	<doc entry="archive-iterator">
		<description>Iterates over the entries found in the specified archive.  Each entry name will be registered as the request attribute 'Attributes.LOCATION' for subtasks.</description>
	</doc>

	<task name="extract-archive" impl="org.danann.cernunnos.io.ExtractArchiveTask"/>
	<doc entry="extract-archive">
		<description>Extracts the contents of the specified archive and writes them to the specified directory.</description>
	</doc>

	<!-- 
	  | Package:  mail
	  +-->

	<task name="send-email" impl="org.danann.cernunnos.mail.SendEmailTask"/>
	<doc entry="send-email">
		<description>Sends an email based on the specified information.</description>
	</doc>

	<!-- 
	  | Package:  net
	  +-->

	<phrase name="url" impl="org.danann.cernunnos.net.UrlPhrase"/>
	<doc entry="url">
		<description>Reads the resource at the specified location, constructs a new Phrase from the content, and returns the result of evaluating the Phrase.</description>
		<example caption="Connects to a database using the password stored in '/C:/passwd.txt', executes the SQL statement specified by the first argument on the command line">
			<pre><xmp><sql-connection driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:hsql://localhost:8887" username="sa" password="${url(/C:/passwd.txt)}">
  <sql-statement sql="${req($1)}"/>
</sql-connection></xmp></pre>
		</example>
	</doc>

	<!-- 
	  | Package:  sql
	  +-->

{'fraction_non_alphanumeric': 0.14771776059874933, 'fraction_numerical': 0.0019695701413166575, 'mean_word_length': 4.510037981551818, 'pattern_counts': {'":': 0, '<': 497, '<?xml version=': 0, '>': 497, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5171128', 'n_tokens_mistral': 6533, 'n_tokens_neox': 6088, 'n_words': 1771}