changeset 26:584c2f18bb48

Consistent DataFormat names.
author Mikhail Kryshen <mikhail@kryshen.net>
date Thu, 14 May 2009 18:14:16 +0400
parents 55fe63bb7858
children 2b5306159761
files src/kryshen/tema/FunctionDataParser.java src/kryshen/tema/TemplateParser.java
diffstat 2 files changed, 29 insertions(+), 31 deletions(-) [+]
line diff
     1.1 --- a/src/kryshen/tema/FunctionDataParser.java	Wed Apr 22 03:30:59 2009 +0400
     1.2 +++ b/src/kryshen/tema/FunctionDataParser.java	Thu May 14 18:14:16 2009 +0400
     1.3 @@ -74,7 +74,7 @@
     1.4              throw new TemplateException
     1.5                      ("Unexpected end of instruction data.", in);
     1.6          
     1.7 -        DataFormat fd = skip ? this.fd.noCall() : this.fd;
     1.8 +        DataFormat fd = skip ? this.fd.noInvoke() : this.fd;
     1.9          
    1.10          TemplateParser.Result r;
    1.11          
     2.1 --- a/src/kryshen/tema/TemplateParser.java	Wed Apr 22 03:30:59 2009 +0400
     2.2 +++ b/src/kryshen/tema/TemplateParser.java	Thu May 14 18:14:16 2009 +0400
     2.3 @@ -42,36 +42,36 @@
     2.4      /* Separators. */
     2.5      public static final char[] REC_DATA_SEPARATORS = {':'};
     2.6      public static final char[] VERBATIM_DATA_SEPARATORS = {'\\', '`'};
     2.7 -    public static final char[] NOCALL_DATA_SEPARATORS = {'#'};
     2.8 +    public static final char[] NOINVOKE_DATA_SEPARATORS = {'#'};
     2.9      public static final char[] LIST_SEPARATORS = {' ', '\t', '\r', '\n'};
    2.10      
    2.11      /**
    2.12       * Specifies how to parse function arguments and data.
    2.13       */
    2.14      static enum DataFormat {
    2.15 -        RECURSIVE(true, false),
    2.16 +        INVOKE(true, false),
    2.17          VERBATIM(false, false),
    2.18 -        NOCALL(false, false),
    2.19 +        NOINVOKE(false, false),
    2.20          SUBFUNCTION(true, true),
    2.21 -        SUBFUNCTION_NOCALL(false, true);
    2.22 +        SUBFUNCTION_NOINVOKE(false, true);
    2.23          
    2.24 -        public final boolean call;
    2.25 +        public final boolean invoke;
    2.26          public final boolean subfunction;
    2.27          
    2.28 -        DataFormat(boolean call, boolean subfunction) {
    2.29 -            this.call = call;
    2.30 +        DataFormat(boolean invoke, boolean subfunction) {
    2.31 +            this.invoke = invoke;
    2.32              this.subfunction = subfunction;
    2.33          }
    2.34          
    2.35          /**
    2.36           * Returns no-call equivalent to this format.
    2.37           */
    2.38 -        public DataFormat noCall() {
    2.39 -            if (this == RECURSIVE)
    2.40 -                return NOCALL;
    2.41 +        public DataFormat noInvoke() {
    2.42 +            if (this == INVOKE)
    2.43 +                return NOINVOKE;
    2.44              
    2.45              if (this == SUBFUNCTION)
    2.46 -                return SUBFUNCTION_NOCALL;
    2.47 +                return SUBFUNCTION_NOINVOKE;
    2.48              
    2.49              return this;
    2.50          }
    2.51 @@ -141,7 +141,7 @@
    2.52       */
    2.53      public int parse(TemplateReader in, Writer out)
    2.54      throws IOException, TemplateException {
    2.55 -        return parse(in, out, DataFormat.RECURSIVE, null).retCode;
    2.56 +        return parse(in, out, DataFormat.INVOKE, null).retCode;
    2.57      }
    2.58      
    2.59      Result parse(TemplateReader in, Writer out, DataFormat format)
    2.60 @@ -161,10 +161,8 @@
    2.61              throws IOException, TemplateException {
    2.62          
    2.63          Result result = new Result();
    2.64 -        
    2.65 -        if (format == DataFormat.SUBFUNCTION ||
    2.66 -                format == DataFormat.SUBFUNCTION_NOCALL) {
    2.67 -            
    2.68 +
    2.69 +        if (format.subfunction) {
    2.70              result.retCode = parseFunction(in, out, format);
    2.71              result.empty = false;
    2.72              return result;
    2.73 @@ -178,7 +176,7 @@
    2.74                      if (result.retCode < 0)
    2.75                          result.retCode = 0;
    2.76                      
    2.77 -                    if (!format.call) {
    2.78 +                    if (!format.invoke) {
    2.79                          out.write(BRACKET_OPEN[openBracket]);
    2.80                      }
    2.81                      
    2.82 @@ -190,7 +188,7 @@
    2.83                      result.empty = false;
    2.84                      termBracket = tb;
    2.85                      
    2.86 -                    if (!format.call) {
    2.87 +                    if (!format.invoke) {
    2.88                          out.write(BRACKET_CLOSE[openBracket]);
    2.89                      }
    2.90                      
    2.91 @@ -356,33 +354,33 @@
    2.92              if (c < 0)
    2.93                  throw new TemplateException("Unexpected end of file.", in);
    2.94              
    2.95 -            if (!fd.call)
    2.96 +            if (!fd.invoke)
    2.97                  out.write(c);
    2.98              
    2.99              if (isSeparator(c, LIST_SEPARATORS)) {
   2.100                  return invoke(
   2.101 -                        fd.call ? sb.toString() : "true",
   2.102 -                        fd.call ?
   2.103 +                        fd.invoke ? sb.toString() : "true",
   2.104 +                        fd.invoke ?
   2.105                              DataFormat.SUBFUNCTION :
   2.106 -                            DataFormat.SUBFUNCTION_NOCALL,
   2.107 +                            DataFormat.SUBFUNCTION_NOINVOKE,
   2.108                          in, out);
   2.109              } else if (isSeparator(c, REC_DATA_SEPARATORS)) {
   2.110                  skipEscaped(in);
   2.111                  return invoke(
   2.112 -                        fd.call ? sb.toString() : "true",
   2.113 -                        fd.call ?
   2.114 -                            DataFormat.RECURSIVE :
   2.115 -                            DataFormat.NOCALL,
   2.116 +                        fd.invoke ? sb.toString() : "true",
   2.117 +                        fd.invoke ?
   2.118 +                            DataFormat.INVOKE :
   2.119 +                            DataFormat.NOINVOKE,
   2.120                          in, out);
   2.121              } else if (isSeparator(c, VERBATIM_DATA_SEPARATORS)) {
   2.122                  return invoke(
   2.123 -                        fd.call ? sb.toString() : "true",
   2.124 +                        fd.invoke ? sb.toString() : "true",
   2.125                          DataFormat.VERBATIM, in, out);
   2.126 -            } else if (isSeparator(c, NOCALL_DATA_SEPARATORS)) {
   2.127 +            } else if (isSeparator(c, NOINVOKE_DATA_SEPARATORS)) {
   2.128                  skipEscaped(in);
   2.129                  return invoke(
   2.130 -                        fd.call ? sb.toString() : "true",
   2.131 -                        DataFormat.NOCALL, in, out);
   2.132 +                        fd.invoke ? sb.toString() : "true",
   2.133 +                        DataFormat.NOINVOKE, in, out);
   2.134              } else {
   2.135                  sb.append((char)c);
   2.136              }