|
Appendix C. Explicit Structure of the Hermes LanguageSyntax of the Hermes language. This is a complete listing of the options of the Hermes language in BNF format. This is the full advanced version of the language, incorporating all the options for the beginner and intermediate levels as described in Chapter 10. All Capitalized Terms are non-terminals. Underlined terms are literal terminals. (Words in parentheses) are comments. Other terms describe terminals. [Terms in square brackets] are optional. The start symbol is DataList. --------------language
elements---------------------------------------- DataList ::= SimpleDataList | ComputedDataList SimpleDataList ::= a node name | id: an object id | Character | Number | Boolean | NodeKind | LanguageType | items | that (last subject) | this (expression) | those items | contents of ResultList | a DataList name ComputedDataList
::=
DataList Combination DataList | Association of DataList | DataList
with their Association | DataList that Filter | Graphic [immediately]
in Graphic | DataList in context Context | either
DataList or DataList | if Boolean then DataList [, else
DataList] | DataList, sorted | DataList, without duplicates Association
::=
SimpleAssociation | InputAssociation | ComputedAssociation | Predicate SimpleAssociation ::= LinkType | name | id | creation date | creator | last modification date | contexts | all associations | [immediate] parts | Dimension | Distance in Units from Graphic [in Graphic] | an Association name Predicate ::= Association InputAssociation ::= LinkType | InputAssociation with their InputAssociation | InputAssociation and InputAssociation | an input association name ComputedAssociation
::= Association
of Association | Association with their Association |
Association that Filter | inverse Association | either
Association or Association | if Boolean then Association [,
else Association] | Association Combination Association | the
Number th Association | Association, sorted | Association, without
duplicates Filter
::=
SimpleFilter | CharacterFilter | NumberFilter | BooleanFilter |
ContextFilter | GraphicFilter | ComputedFilter SimpleFilter ::= equal DataList | named Character | included in DataList | include DataList | of kind NodeKind | of type LanguageType | a Filter name CharacterFilter
::=
include Character NumberFilter
::=
Counter BooleanFilter
::=
true ContextFilter
::=
view [Counter] DataList | inherit from Context | are
inherited by Context GraphicFilter ::= [immediately] contain Graphic | [immediately] contained in Graphic | Measure [Quantifier] Graphic [in Graphic] | have Attribute is Value | have Attribute is Number ComputedFilter ::= have Counter Association [with those items] | have Quantifier Association that Filter [with those items] | if Boolean then Filter [else Filter] | Filter Connective Filter | are Filter | are not Filter | do not Filter ---------------media
elements---------------------------------------------- Character ::= SimpleCharacter | ComputedCharacter SimpleCharacter ::= character string | a Character name ComputedCharacter ::= substring of Character from Number for Number | Character append Character Number ::= SimpleNumber | ComputedNumber SimpleNumber ::= real number | a Number name ComputedNumber ::= count of DataList | minimum DataList | maximum DataList | total of DataList | product of DataList | Number + Number | Number - Number | - Number | Number x Number | Number / Number | list of Distance in Units among Graphic, Graphic[, Graphic] [in Graphic] Boolean ::= SimpleBoolean | ComputedBoolean SimpleBoolean ::= true | false | a Boolean name ComputedBoolean ::= there are Counter DataList | Quantifier DataList Filter | not Boolean | Boolean Connective Boolean | Graphic Measure [Quantifier] Graphic [in Graphic] Graphic ::= SimpleGraphic | ComputedGraphic SimpleGraphic ::= polyline | a Graphic name ComputedGraphic ::= DataList (of type graphic) Image ::= bitmap image | an Image name Pen ::= pen sketch | a Pen name Sound ::= sound segment | a Sound name Video ::= video segment | a Video name Animation ::= animation segment | an Animation name ComputedView ::= DataList arranged in a window | a ComputedView name -------------------network
elements----------------------------------------- NodeKind ::= a NodeKind name LinkType ::= a LinkType name Context ::= a Context name ResultList ::= name of an evaluated DataList ------------------namable
terminology elements----------------------------- Counter ::= (at least one) | more than Number | less than Number | exact Number | not Counter | Counter Connective Counter | a Counter name Quantifier ::= no | any | all | most | the (only one) | Counter | a Quantifier name Measure ::= Distance is Counter Units | not Measure | Measure Connective Measure | a Measure name ------------------simple
terminology elements---------------------------------------- Connective ::= and (logical) | or (logical) Combination ::= and (unique sorted union) | and also (intersection) | but not (difference) | or (append) | with (and, indented) Distance ::= central distance | closest distance | x distance | y distance | z distance Units ::= inches | feet | cm | meters Dimension ::= length | area | volume | x width | y height | z depth Attribute ::= font | color | pen width | brush style | brush width | . . . . Value ::= roman | helvetica | red | blue | striped | plaid | . . . . LanguageType ::= data lists | associations | filters | characters | numbers | booleans | graphics | images | pens | sounds | videos | animations | computed views | node kinds | link types | result lists | contexts | counters | quantifiers | measures Denotational semantics of the Hermes language. The semantics of the Hermes Language was formalized using the notation of Schmidt (1986), based on the denotational semantics of Strachey and Scott. The abstract syntax, semantic algebras, and valuation functions provide a formal specification for the Hermes source code implementation. Each option in the abstract syntax is programmed as an object. The semantic algebras are implemented by these objects, which are given methods corresponding to the operations specified for the algebras. Evaluation methods for the objects correspond very closely to the valuation functions specified for the syntactic options. In addition, each object has methods for displaying itself and each object can be given a name by the user when it is defined. For instance, a typical option in the syntax, DataList ::= Association of DataList, might be programmed as follows in object-oriented Pascal: DataListAofD := object(DataList) function Eval(InList: DataListPtr): DataListPtr; virtual; procedure Display; virtual; private TheAssociation : AssociationPtr; TheDataList : DataListPtr; end; function DataListAofD.Eval(InList: DataListPtr): DataListPtr; begin Eval := TheAssociation^.Eval(TheDataList^.Eval(nil)); end; procedure DataListAofD.Display; begin TheAssociation^.Display; write(' of '); TheDataList^.Display; writeln; end; This defines the Association of DataList option as an object that inherits from the DataList object, has data items corresponding to its constituent Association and DataList, and has methods for displaying and evaluating itself. Note how the Eval method follows the same applicative process as the valuation function from the denotational semantics: D[[A of D]] = d. z. A[[A]] ( D[[D]] z)
The denotational semantics of the Hermes language is extraordinarily simple because the language has been designed to minimize the amount of programming doctrine required. In particular, there is no state change and no continuation processing because there are no assignment statements and no explicit iteration constructs. In fact, there is no store because there are no variables.[1] Moreover, there is no explicit typing. This all makes for a simple, straight-forward language structure. Balancing the structural simplicity of the language is the wealth of individual syntax options. The quantity of options results from the history of design trade-offs detailed in Appendix B. In particular, there was a concerted effort to provide a broad range of useful functionality while restricting the possibilities for creating problematic constructs. There are over a hundred options for the Advanced Version of the Hermes Language. Most of them define permissible and useful combinations of other options and are relatively self-explanatory. A few of them require more explanation.
In the following, the major options listed in the syntax above are explained briefly and examples of their use is given. Simple DataLists. These generate ordered lists of nodes from the database. Most of the Simple options generate a list of one node. The options for DataLists signify that these lists of nodes can be generated in the following ways: By specifying the name of a node. Names are optional for nodes. For example: archie’s lunar habitat By giving the Id of a node. All nodes have unique numeric identifiers that are used internally by the Hermes system. id: 2345 By defining a Character node using any of the Character options. substring of privacy message from 1 to 26 By defining a Number node using any of the Number options. 47 By defining a Boolean node using any of the Boolean options. there are more than 3 grandchildren of sandra All nodes in the database of a specified NodeKind lunar habitats All nodes in the database of a specified LanguageType datalists that have authors that contain "Sandra" All nodes in the database
The name of a stored DataList whose contents (not definition) is to be used
The name of a defined ResultList whose definition (not stored contents) is to be evaluated
Computed DataLists. These generate ordered lists of nodes from the database. Most of these apply one operator to another to generate a DataList: By combining two DataLists with a Combination
By applying an Association to an existing DataList (and traversing links to arrive at a new list).
By applying an Association to an existing DataList and listing the DataList with the Associations of each item listed under that item and indented. The term “with” indicates that indenting will take place for the results of the Association. Note that the Association operator is applied to the DataList results.
By applying a Filter to an existing DataList (and eliminating nodes which do not pass through).
By specifying a Graphic that is internal to a hierarchical Graphic. If the optional term “immediately” is used, then only the first level parts of the Graphic will result, and not the parts of parts, etc. as when the “immediately” keyword is absent.
By selecting a DataList as viewed within a context other than the currently active perspective
By choosing between two existing DataLists depending upon whether the first has any items when evaluated
By evaluating a Boolean and choosing between two existing DataLists; the second DataList is optional.
By sorting a DataList
By removing duplicates from a DataList
Simple Associations. These are computations that map or transform one list of nodes into another, based on the links coming into or out of the nodes in the first list. The transformations can take place as follows: All links of a specified Link Type
The name of a node. This is a pseudo-Association that allows internally stored names to be referenced in the Hermes language
The id of a node. This is a pseudo-Association that allows internally stored ids to be referenced in the Hermes language
The creation date of a node. This is a pseudo-Association that allows internally stored names to be referenced in the Hermes language. Design environments built on Hermes could make timestamping automatic
The creator of a node. This is a pseudo-Association that allows internally stored names to be referenced in the Hermes language. Design environments built on Hermes could automatically stamp a newly created node with the user’s login name
The last modification date of a node. This is a pseudo-Association that allows internally stored names to be referenced in the Hermes language. Design environments built on Hermes could make timestamping automatic
List the contexts in which something is defined. This is a pseudo-Association.
List every association
Parts of a graphical hierarchy. If the optional term “immediate” is used, then only the first level parts will result, and not the parts of parts, etc. as when the “immediate” keyword is absent.
Any Dimension (see Dimensions below). This is a pseudo-Association
Distance from a specified graphical object. When applied to one or more graphical objects, this returns the numeric distance(s). Distances are always measured within some implicitly or explicitly specified encompassing graphic
The name of a defined Association
Predicates. These are Computed Associations that display their resultant lists differently in order to hide the computations that have been encapsulated in the Predicate definition. Any Association definition can optionally be stored as a Predicate. For instance, the Association
can be stored as an Association or as a Predicate. The same nodes would appear in the lists generated by the use of either, but the lists would appear differently when displayed. The results of the Association would be labeled as issues, answers, and arguments, and they would be indented accordingly to show the structure of the computation. The results of the Predicate, in contrast, would all be labeled discussion and would not be indented. To the user, it would appear that the results of the Predicate were all linked directly to the original nodes by simple links of type discussion—so the complexity of the actual computation would be hidden. InputAssociation. This is a subclass of Associations that is used for formulating macros for input of structured data. Its definitions are identical to the corresponding Association definitions, but they are limited as to the complexity of their structure. In particular, they are limited to forms meaningful for prompting input of new nodes. Any InputAssociation can be included wherever a Association can be used, and it can be saved as an Association or a Predicate. However, the reverse is not true, and only expressions saved as InputAssociation can be used for eliciting the entry of new nodes. For instance, if discussion were saved as an InputAssociation, then the user could be prompted to enter a hierarchy of design rationale automatically. First, the system would prompt for an issue. For each issue entered, it would prompt for a series of answers. And as each answer was entered, the user would be prompted for arguments to support it. Computed Association. These combine Simple Associations with other operations. Apply one Association to the result of another Association arguments of answers Apply one Association to the result of another Association and list each item of the result of the first Association with its Associations listed under it and indented answers with their arguments First apply an Association and then apply a Filter
sons that are contained in siblings of sandra Follow the in-coming Association links instead of the usual out-going links inverse parent Choose between two existing Association results depending upon whether the first has any items when evaluated either sons or daughters Evaluate a Boolean and choose between two existing Associations; the second DataList is optional. if stove is near curtains then arguments Combine two Associations with a Combination sons and daughters Select the n-th Association the 7th son Sort the Association results
Remove duplicates from the Association results authors of novels, without duplicates Simple Filters. Filters are conditional operators applied to each node in a DataList; if the condition is true of the node, then the node is retained (from the input list, in the output list). The following filtering operations are defined: Check if an item is equal to (the same object as) an item specified by a DataList habitats that have chairs that equal archie’s favorite chair Check if an item has a name specified by a defined Character habitats that are named the secret word Check if an item is included in a defined DataList chairs that are included in habitats Check if an item includes a defined DataList habitats that include chairs Check if an item is of a kind defined by a NodeKind parts of habitats that are of kind chair Check if an item is of a type defined by a LanguageType items that are of type distances The name of a defined Filter are desirable Multimedia Filters. These include filters specific to Characters, Numbers, Booleans, Contexts, and Graphics. Check if a substring is included that is defined by a Character messages that include the warning string Check if a numeric item equals an amount that is defined by a Count
Check if a boolean value equals true test conditionals that are true Check if a specified DataList or Count of the DataList can be viewed in a Context contexts that view more than 7 issues that include “bunk” Check if a Context inherits from another Context contexts that inherit from archie’s context Check if a Context is inherited by another Context contexts that are inherited by archie’s context Check if a graphical item contains the graphical items that are defined by a DataList. The keyword “immediately” restricts the computation to the highest level parts. habitats that contain chairs Check if a graphical item is contained in the graphical items that are defined by a DataList. The keyword “immediately” restricts the computation to the highest level parts. chairs that are immediately contained in habitats Check if graphical items are a distance defined by a Measure from items defined by a DataList. This may optionally be quantified with a Quantifier. Distances are implicitly or explicitly measured within a Graphic that are near most stoves in the kitchen Check if an Attribute value equals Value that have color is red Check if an Attribute value equals Number that have pen width is 5 Computed Filters. These include Filters that combine other operators. Check if there are a certain number defined by Count of Associations. Optionally sublist the intermediate results that have more then 3 grandchildren with those items Check if there are a certain number defined by Quantifier of Associations that pass a Filter. Optionally sublist the intermediate results that have all grandchildren that are of kind boy Check a Filter only if a Boolean is true. Optionally check an alternative Filter otherwise that if test conditional then are red, else are blue Check if items pass both of (or one of) two Filters, depending on the Connective, logical and/or that are more than 3 and (logical) are less than 7 Check if items do or do not pass a Filter that are equal “bunk” that are not named “my bunk” that do not equal “bunk” [1] In fact, there is a very limited state change, implemented with a specific associated store for the DataList options that (last subject), this (expression), and those items. The first two of these each require a special stack and the third requires a list to keep track of their changing values. These are simple to implement and can be easily accounted for in the denotational semantics without all the overhead of variable names and assignments.
Go to top of this page Return to Gerry Stahl's Home Page Send email to Gerry.Stahl@drexel.edu This page last modified on January 05, 2004 |