Parsing Engine

danbikel.parser
Interface HeadFinder

All Known Implementing Classes:
AbstractHeadFinder, BrokenHeadFinder, HeadFinder, HeadFinder, HeadFinder

public interface HeadFinder

Specifies the methods for the head-finding component of a language package. A head finder determines the distinguished head child for any context-free production.

A language package must include an implementation of this interface.

See Also:
AbstractHeadFinder

Method Summary
 Sexp addHeadInformation(Sexp tree)
          Perform head-finding in tree, augmenting nodes that are the head child of their parent by appending headSuffix().
 int findHead(Sexp tree)
          Finds the head for the production at the root of the specified subtree.
 int findHead(Sexp tree, Symbol lhs, SexpList rhs)
          Finds the head for the grammar production lhs → rhs.
 String headSuffix()
          The suffix to append to nodes that are the head children of their respective parents when marking heads via addHeadInformation(Sexp).
 

Method Detail

findHead

int findHead(Sexp tree)
Finds the head for the production at the root of the specified subtree. The general contract of this method is to extract the root nonterminal label of the specified tree, create a list of the child nonterminal labels and call findHead(Sexp,Symbol,SexpList).

Parameters:
tree - the subtree for whose root production to find the head
Returns:
the 1-based index of the head child of the production at the root of the specified subtree
See Also:
findHead(Sexp,Symbol,SexpList)

findHead

int findHead(Sexp tree,
             Symbol lhs,
             SexpList rhs)
Finds the head for the grammar production lhs → rhs. This method may destructively modify rhs.

Parameters:
tree - the original subtree in which to find the head child, or null if the subtree is not available
lhs - the nonterminal label that is the left-hand side of a grammar production
rhs - a list of symbols that is the right-hand side of a grammar production
Returns:
the 1-based index of the head child in rhs

addHeadInformation

Sexp addHeadInformation(Sexp tree)
Perform head-finding in tree, augmenting nodes that are the head child of their parent by appending headSuffix(). This method is useful for head-finding debugging.

Returns:
a reference to the modified tree object

headSuffix

String headSuffix()
The suffix to append to nodes that are the head children of their respective parents when marking heads via addHeadInformation(Sexp).

Returns:
the string that is to be appended to the print name of nodes that are the head children of their respective parents

Parsing Engine

Author: Dan Bikel.