SyntaxRule.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package kawa.lang;
  2. import java.io.*;
  3. /** A rule in an R5RS <code>syntax-template</code>. A combination of
  4. * a <code>SyntaxPattern</code> and a <code>SyntaxTemplate</code>. */
  5. public class SyntaxRule extends SyntaxTemplate implements Externalizable
  6. {
  7. SyntaxPattern pattern;
  8. public SyntaxRule() {
  9. }
  10. public SyntaxRule(SyntaxPattern pattern,
  11. String pattern_nesting,
  12. String template_program,
  13. Object[] literal_values,
  14. int max_nesting) {
  15. super(pattern_nesting, template_program, literal_values, max_nesting);
  16. this.pattern = pattern;
  17. }
  18. public SyntaxRule(SyntaxPattern pattern,
  19. Object template,
  20. SyntaxForm template_syntax,
  21. Object ellipsis, Translator tr) {
  22. super(template, template_syntax, ellipsis, tr);
  23. this.pattern = pattern;
  24. }
  25. public void writeExternal(ObjectOutput out) throws IOException {
  26. out.writeObject(pattern);
  27. super.writeExternal(out);
  28. }
  29. public void readExternal(ObjectInput in)
  30. throws IOException, ClassNotFoundException {
  31. pattern = (SyntaxPattern) in.readObject();
  32. super.readExternal(in);
  33. }
  34. }