
![]() |
Show Changes |
![]() |
Edit |
![]() |
|
![]() |
Recent Changes |
![]() |
Subscriptions |
![]() |
Lost and Found |
![]() |
Find References |
![]() |
Rename |
![]() |
Administration Page |
| Search |
History
| 9/18/2008 7:17:16 AM |
| FLWCOM-jwdavidson |
| 9/18/2008 7:17:01 AM |
| FLWCOM-jwdavidson |
| 7/10/2008 6:22:23 PM |
| 65.70.111.249 |
| 7/7/2008 2:35:20 PM |
| 221.130.193.164 |
| 11/29/2005 9:13:00 AM |
| -66.69.144.142 |
![]() |
List all versions |
bvc
A BehaviorExpression (expr in the language grammar below) is a series of cascading references to properties or functions on objects. Here are some simple examples:
CurrentTopic
Now
Federation
RecentlyChangedTopics("bobdole")
Each of these symbolReferences (i.e., a reference to either a property or a function; see the grammar below) is evaluated relative to an object. The left-most symbolReference in an expression is evaluated against the home object. This special object defines the global properties and functions of the BEL language. As a result, the above examples are equivalent to:
home.CurrentTopic
home.Now
home.Federation
home.RecentlyChangedTopics("bobdole")
symbolReferences further to the right are evaluated as properties (or functions) of the object to the left. So, given the expression home.CurrentTopic, CurrentTopic is a property of the home object. If you add to this, for example with home.CurrentTopic.Namespace, you get the Namespace property of the current topic.
The evaluator works by first building a tree of objects by parsing out the expression. It then reduces the tree, working from the leaves back to the root by evaluating them and turning them into strings (see below for sample parse trees). So, if an expr object isn't a string, it will eventually be converted down to one. This string is the eventual output for the behavior expression and that result is inserted into the Wiki page.
To use a BehaviorExpression in a wiki page, surround the expression with the @@ delimiter. For example:
The date is @@Now.Date@@
If you need to use the sequence @@ inside a behavior expression, it must be escaped as \@@.
The BEL language is based on a set of strongly-typed objects (called BELObjects) that let you access information about the Wiki. Each object is an instance of a class. Each object has a specific set of properties and functions as a result of being an instance of a particular class. Also, classes can inherit from other classes; all classes eventually inherit from a class called Object (which is the only class that doesn't inherit from something else).
While there may be a 1:1 relationship between some of these BEL classes and .NET classes in the implementation of the language, that's a coincidence of implementation. The BEL object system is much simpler than the .NET object system; don't get confused and think you have the full .NET object system available via BEL.
Below is information about all of the classes that are part of BEL:
| Property or Function | Returns | Notes |
| Type | string | The name of the class of object |
| StringValue | object | The object as a string (with all children fully evaluated) |
| Property or Function | Returns | Notes |
| Today | DateTime | |
| CurrentTopic | Topic | |
| StringValue | "Home" |
| Property or Function | Returns | Notes |
| Name | string | Name of the topic (without namespace) |
| Namespace | Namespace | The namespace containing the topic |
| StringValue | string | The name of the topic |
| Property or Function | Returns | Notes |
| Name | string | Name of the namespace |
| Description | string | Description of the namespace (blank string if none) |
| Topics | Collection of Topic | |
| TopicNamed(string TopicName) | Topic or null | |
| StringValue | string | The name of the namespace |
| Property or Function | Returns | Notes |
| Namespaces | Collection of Namespace | |
| NamespaceNamed(string NamespaceName) | Namespace or null | |
| StringValue | "Federation" |
| Property or Function | Returns | Notes |
| Date | string | |
| Time | string | |
| StringValue | formatted date time string |
| Property or Function | Returns | Notes |
| Count | integer | |
| Item(integer index) | ||
| StringValue | string with all values listed [a, b, c] | |
| ForEach(string iteratorPropertyName, Object arg) |
| Property or Function | Returns | Notes |
| StringValue | "null" |
| Property or Function | Returns | Notes |
| StringValue | string | the value of the string itself |
| Property or Function | Returns | Notes |
| StringValue | string | the value of the number |
BEL supports simple collections (see the Collection BELObject object). These are ordered collections and they can hold other BELObjects.
You can specify a collection using brackets in a BehaviorExpression:
["hello", "goodbye"]
This creates a collection with two BELObjects in it, both of which are Strings (one for "hello" and one for "goodbye").
Collections support special functions (called iterator functions) that allow you to iterate over the objects in the collection. For example,
Federation.Namespaces.ForEach("each", each.Name)
This uses the special ForEach iterator. This iterator function takes two arguments. First is the name of a temporary property to create that will hold, in turn, each of the objects in the collection. Second, is an expression that is evaluated in a context in which that temporary property is defined.
The above example will produce a list of all of the namespaces. To produce a table of all namespaces and their descriptions, use this:
Federation.Namespaces.ForEach("each", Wiki("||@@each.Name@@||@@each.Description@@||"))
The special Wiki() function processes its argument as Wiki text.
The language is defined roughly as follows:
expr :=
term
term '.' expr
term :=
literal |
builtin |
symbolReference
symbolReference :=
propertyReference |
functionReference
propertyReference := propertyName
functionReference := functionName '(' args ')'
args := | arglist
arglist :=
arg |
arg ',' args
arg := expr
builtin := 'null' | 'home'
propertyName := identifier
functionName := identifier
identifier := 'A-Za-z' 'A-Za-z0-9'*
literal := string | integer | collectionLiteral
collectionLiteral := '[' exprs ']'
exprs := | exprlist
exprlist :=
expr
expr ',' expr
string := " chars... "
integer := '-'? [0-9]+
Each BEL-visible object is implemented in a .NET classes that supports IBELObject. Example include:
The BEL parser builds a tree composed of these and some additional kinds of IBELObjects:
BELPropertyReference (name: CurrentTopic)
|
|--------BELHome
BELPropertyReference (name: CurrentTopic)
|
|--------BELHome
BELPropertyReference (name: Namespaces)
|
|--------BELPropertyReference (name: Federation)
|
|--BELHome
BELUndefinedObject
BELHome
BELString ("Hello World")
Execution proceeds very simply. The root object built by the parser is asked for its StringValue.