Tag Expressions: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Basic Concepts and Terminology]]
{{context|Basic Concepts and Terminology|Tags and Tag Expressions}}
[Context: [[Home|HL Kit]] … [[Basic Concepts and Terminology]] … [[Tags and Tag Expressions]]]


==Overview==
==Overview==
Line 11: Line 10:


:{| class="infotable"
:{| class="infotable"
|class="leftnormal"|&
|class="leftnarrow"|&
|Logical "And". Evaluates the two terms on either side and returns "true" only if both terms are "true". Example: "term1 & term2".
|Logical "And". Evaluates the two terms on either side and returns "true" only if both terms are "true". Example: "term1 & term2".
|-
|-
Line 27: Line 26:
==Examples==
==Examples==


The following are a few sample expressions utilizing parenthetical sub-expressions and combinations of the above operators.
The following are a couple of sample expressions utilizing parenthetical sub-expressions and combinations of the above operators.


<pre>
(TRUE & FALSE) ^ (TRUE & TRUE) ^ (FALSE & FALSE)
(TRUE & FALSE) ^ (TRUE & TRUE) ^ (FALSE & FALSE)
</pre>


Evaluates to “true”. The first term evaluates to “false” and the second term evaluates to “true”. The Xor of “true” and “false” (the first two terms) yields “true”. The third term evaluates to “false”. The Xor of “true” and “false” (the result of the first Xor and the third term) yields “true”.
:The above example evaluates to "true". The first term evaluates to "false" and the second term evaluates to "true". The Xor of "true" and "false" (the first two terms) yields "true". The third term evaluates to "false". The Xor of "true" and "false" (the result of the first Xor and the third term) yields "true".


<pre>
TRUE ^ !(FALSE | TRUE)
TRUE ^ !(FALSE | TRUE)
</pre>


Evaluates to “true”. The sub-expression (FALSE | TRUE)evaluates to “true”. The negation of the sub-expression yields “false”. The Xor of “true” and the negated sub-expression result of “false” yields “true”.
:The above example evaluates to "true". The sub-expression "(FALSE | TRUE)" evaluates to "true". The negation of the sub-expression yields "false". The Xor of "true" and the negated sub-expression result of "false" yields "true".

Latest revision as of 08:29, 22 November 2008

Context: HL Kit &#133; Basic Concepts and Terminology &#133; Tags and Tag Expressions 

Overview

Combinations of tags indicate meta-characteristics of an object. Tag expressions are the mechanism through which objects with specific combinations of attributes can be identified. Specifically, tag expressions are Boolean expressions that delineate a combination of tags that an object must possess. For example, a tag expression could easily be used to determine if an object is a "first-level wizard spell". Separate tag groups could be defined that identify the "class" of the object (fighter, wizard, etc.) and the "level" of the object (1st, 2nd, etc.). An additional tag group could be defined that identifies the "type" of the object (e.g. spell, weapon, skill, etc.). A tag expression could then be written to identify all objects that possess tags for all three characteristics: the "class.wizard" tag, the "level.1" tag, and the "type.spell" tag.

Syntax

Tag expressions are Boolean expressions comprised of tag terms. The tag expression evaluates each of the tag terms against a particular object to determine whether the object does or does not match the criteria. These terms are then combined using Boolean logic, where the expression specifies the relationships to use. Four Boolean operators are supported, and parentheses may be freely used to define appropriate groupings of sub-expressions. The operators supported are outlined below.

& Logical "And". Evaluates the two terms on either side and returns "true" only if both terms are "true". Example: "term1 & term2".
| Logical "Or". Evaluates the two terms on either side and returns "true" if either of the terms is "true". Example: "term1 | term2".
^ Logical "Xor". Evaluates the two terms on either side and returns "true" if exactly one of the terms is "true". Example: "term1 ^ term2".
! Logical "Not". Evaluates the following term and returns "true" if that term is "false". Otherwise, it returns "false". Example: "!term1".

Examples

The following are a couple of sample expressions utilizing parenthetical sub-expressions and combinations of the above operators.

(TRUE & FALSE) ^ (TRUE & TRUE) ^ (FALSE & FALSE)
The above example evaluates to "true". The first term evaluates to "false" and the second term evaluates to "true". The Xor of "true" and "false" (the first two terms) yields "true". The third term evaluates to "false". The Xor of "true" and "false" (the result of the first Xor and the third term) yields "true".
TRUE ^ !(FALSE | TRUE)
The above example evaluates to "true". The sub-expression "(FALSE | TRUE)" evaluates to "true". The negation of the sub-expression yields "false". The Xor of "true" and the negated sub-expression result of "false" yields "true".