OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Subject: error-checking algorithm for the redefinition

Here is a summarized version of the algorithm that (I hope) correctly
handle inclusions, definitions, and redefinitions.

fields of RefPattern (of JTREX)

combineMethod: (none/interleave/choice)
    specifies what method is used to combine patterns.

haveHead: boolean
    true if this named pattern already has a "head".
    a "head" is a <define> declaration without @combine.

    (a) notBeingRedefined
    (b) beingRedefinedAndNoOriginal
    (c) beingRedefinedAndOriginal


When an <include> element is encountered,

processInclude() {
    variable tmp;
    for( each <define> under <include> ) {
        store values of the above three fields to tmp;
    // to correctly handle grammars like [*1],
    // we need two separate loops.
    for( each <define> under <include> ) {
        reset values to (none,false,(b)).
    process included pattern.
    for( each redefined pattern in this <include>) {
        if( the redefinition field is (b) )
        restore the values of the three fields from tmp;

// normal processing of <define>
processDefine() {
    // parse the body of <define>
    p = parseBody();
    if( the redefinition field is (a) ) {
        adopt p as the pattern for this name.
        don't forget to honor @combine.
    } else {
        set the redefinition field to (c).
        discard p.
    update the combineMethod field and the
    haveHead field according to @combine.

If defining a pattern more than once in the same file is allowed,
then a measure has to be taken to process the following pattern.

<include href="...">
  <define name="foo"/>
  <define name="foo"/>

Kohsuke KAWAGUCHI                          +1 650 786 0721
Sun Microsystems                   kohsuke.kawaguchi@sun.com

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Powered by eList eXpress LLC