com.lexonics.edsel.parser
Class Parser

java.lang.Object
  extended bycom.lexonics.edsel.parser.Parser

public final class Parser
extends Object

An Edsel parser.

Edsel, the Easy Data Structure Expression Language, is a notation for representing labeled, attributed directed graphs. This is an application for which XML is commonly used. Edsel, however, is better suited for this purpose than XML, in two ways:

An Edsel graph consists of uniquely-labeled attributed nodes connected arbitrarily by labeled directed edges. The notation consists of a sequence of node definitions, each of which gives the node's name and body (its attribute names and value lists, and its outgoing edge names and destination lists). In the following syntax definition, braces denote arbitrary repetition, brackets denote optionality, vertical bars denote alternation, quoted strings denote terminal symbols, uppercase strings denote terminal symbol classes, and the start symbol is graph.

        
                attribute = attribute-name { attribute-value } ';' .
                attribute-name = name .
                attribute-value = STRING .
                graph = { node-definition } .
                name = IDENTIFIER .
                node = node-definition | node-reference .
                node-body = '{' { attribute } [ '|' { outgoing-edge } ] '}' .
                node-definition = node-name node-body .
                node-name = name .
                node-reference = node-name .
                outgoing-edge = outgoing-edge-name { outgoing-edge-destination } ';' .
                outgoing-edge-destination = node .
                outgoing-edge-name = name .
        
        

An IDENTIFIER is a sequence of one or more upper- and lowercase ASCII letters, digits, and hyphens. A STRING is a single-quoted sequence of zero or more Unicode characters; any character may be escaped by a backslash, and single quotes and backslashes must be.

Whitespace may occur freely between tokens and is insignificant. Parenthesized comments may also occur between tokens; comments may be nested.

By convention, the first node may be named -Edsel and have a -version attribute giving the Edsel version (1.0).

Example:

        
        -Edsel { -version '1.0'; }

        (This is a simple example of Edsel.)

        John
        {
                first-name 'John';
                last-name 'Smith';
        |
                wife Mary;
        }

        Mary
        {
                first-name 'Mary';
                last-name 'Smith';
        |
                husband John;
        }
        
        


Nested Class Summary
static class Parser.ParseException
          An Edsel parse exception.
 
Method Summary
static Graph graph(CharSequence edsel)
          Parse an Edsel string representation of a graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

graph

public static Graph graph(CharSequence edsel)
                   throws Parser.ParseException
Parse an Edsel string representation of a graph.

Parameters:
edsel - The Edsel string representation. Must be non-null.
Returns:
The corresponding Graph.
Throws:
IllegalArgumentException - The Edsel string representation is null
Parser.ParseException - The Edsel string representation is syntactically incorrect.


Copyright, 2003
Lexonics, Inc.
All Rights Reserved