kawa.lang

Class SyntaxTemplate

Implemented Interfaces:
Externalizable
Known Direct Subclasses:
SyntaxRule

public class SyntaxTemplate
extends java.lang.Object
implements Externalizable

The translated form of a (syntax template).

Constructor Summary

SyntaxTemplate()
SyntaxTemplate(Object template, SyntaxForm syntax, Translator tr)
SyntaxTemplate(String patternNesting, String template_program, Object[] literal_values, int max_nesting)

Method Summary

int
convert_template(Object form, SyntaxForm syntax, StringBuffer template_program, int nesting, java.util.Vector literals_vector, Object seen, boolean isVector, Translator tr)
Recursively translate a syntax-rule template to a template program.
Object
execute(Object[] vars, TemplateScope templateScope)
Expand this template The compiler translates (syntax template) to a call to this method.
Object
execute(Object[] vars, Translator tr, TemplateScope templateScope)
void
readExternal(ObjectInput in)
void
writeExternal(ObjectOutput out)

Constructor Details

SyntaxTemplate

protected SyntaxTemplate()

SyntaxTemplate

public SyntaxTemplate(Object template,
                      SyntaxForm syntax,
                      Translator tr)

SyntaxTemplate

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

Method Details

convert_template

public int convert_template(Object form,
                            SyntaxForm syntax,
                            StringBuffer template_program,
                            int nesting,
                            java.util.Vector literals_vector,
                            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 Object execute(Object[] vars,
                      TemplateScope templateScope)
Expand this template The compiler translates (syntax template) to a call to this method.

execute

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

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException