kawa.lang
Class SyntaxTemplate

java.lang.Object
  extended by kawa.lang.SyntaxTemplate
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
SyntaxRule

public class SyntaxTemplate
extends java.lang.Object
implements java.io.Externalizable

The translated form of a (syntax template).

See Also:
Serialized Form

Constructor Summary
protected SyntaxTemplate()
           
  SyntaxTemplate(java.lang.Object template, SyntaxForm syntax, Translator tr)
           
  SyntaxTemplate(java.lang.String patternNesting, java.lang.String template_program, java.lang.Object[] literal_values, int max_nesting)
           
 
Method Summary
 int convert_template(java.lang.Object form, SyntaxForm syntax, java.lang.StringBuffer template_program, int nesting, java.util.Vector literals_vector, java.lang.Object seen, boolean isVector, Translator tr)
          Recursively translate a syntax-rule template to a template program.
 java.lang.Object execute(java.lang.Object[] vars, TemplateScope templateScope)
          Expand this template The compiler translates (syntax template) to a call to this method.
 java.lang.Object execute(java.lang.Object[] vars, Translator tr, TemplateScope templateScope)
           
 void readExternal(java.io.ObjectInput in)
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyntaxTemplate

protected SyntaxTemplate()

SyntaxTemplate

public SyntaxTemplate(java.lang.String patternNesting,
                      java.lang.String template_program,
                      java.lang.Object[] literal_values,
                      int max_nesting)

SyntaxTemplate

public SyntaxTemplate(java.lang.Object template,
                      SyntaxForm syntax,
                      Translator tr)
Method Detail

convert_template

public int convert_template(java.lang.Object form,
                            SyntaxForm syntax,
                            java.lang.StringBuffer template_program,
                            int nesting,
                            java.util.Vector literals_vector,
                            java.lang.Object seen,
                            boolean isVector,
                            Translator tr)
Recursively translate a syntax-rule template to a template program.

Parameters:
form - the template from the syntax-rule
syntax - if non-null, the closest surrounding SyntaxForm
template_program - (output) the translated template
nesting - the depth of ... we are inside
literals_vector - (output) the literal data in the template
tr - the current Translator
Returns:
the index of a pattern variable (in pattern_names) that is nested at least as much as nesting; if there is none such, -1 if there is any pattern variable or elipsis; and -2 if the is no pattern variable or elipsis.

execute

public java.lang.Object execute(java.lang.Object[] vars,
                                TemplateScope templateScope)
Expand this template The compiler translates (syntax template) to a call to this method.


execute

public java.lang.Object execute(java.lang.Object[] vars,
                                Translator tr,
                                TemplateScope templateScope)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException