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 wrap: on
line diff
--- a/src/kryshen/tema/FunctionDataParser.java	Wed Apr 22 03:30:59 2009 +0400
+++ b/src/kryshen/tema/FunctionDataParser.java	Thu May 14 18:14:16 2009 +0400
@@ -74,7 +74,7 @@
             throw new TemplateException
                     ("Unexpected end of instruction data.", in);
         
-        DataFormat fd = skip ? this.fd.noCall() : this.fd;
+        DataFormat fd = skip ? this.fd.noInvoke() : this.fd;
         
         TemplateParser.Result r;
         
--- a/src/kryshen/tema/TemplateParser.java	Wed Apr 22 03:30:59 2009 +0400
+++ b/src/kryshen/tema/TemplateParser.java	Thu May 14 18:14:16 2009 +0400
@@ -42,36 +42,36 @@
     /* Separators. */
     public static final char[] REC_DATA_SEPARATORS = {':'};
     public static final char[] VERBATIM_DATA_SEPARATORS = {'\\', '`'};
-    public static final char[] NOCALL_DATA_SEPARATORS = {'#'};
+    public static final char[] NOINVOKE_DATA_SEPARATORS = {'#'};
     public static final char[] LIST_SEPARATORS = {' ', '\t', '\r', '\n'};
     
     /**
      * Specifies how to parse function arguments and data.
      */
     static enum DataFormat {
-        RECURSIVE(true, false),
+        INVOKE(true, false),
         VERBATIM(false, false),
-        NOCALL(false, false),
+        NOINVOKE(false, false),
         SUBFUNCTION(true, true),
-        SUBFUNCTION_NOCALL(false, true);
+        SUBFUNCTION_NOINVOKE(false, true);
         
-        public final boolean call;
+        public final boolean invoke;
         public final boolean subfunction;
         
-        DataFormat(boolean call, boolean subfunction) {
-            this.call = call;
+        DataFormat(boolean invoke, boolean subfunction) {
+            this.invoke = invoke;
             this.subfunction = subfunction;
         }
         
         /**
          * Returns no-call equivalent to this format.
          */
-        public DataFormat noCall() {
-            if (this == RECURSIVE)
-                return NOCALL;
+        public DataFormat noInvoke() {
+            if (this == INVOKE)
+                return NOINVOKE;
             
             if (this == SUBFUNCTION)
-                return SUBFUNCTION_NOCALL;
+                return SUBFUNCTION_NOINVOKE;
             
             return this;
         }
@@ -141,7 +141,7 @@
      */
     public int parse(TemplateReader in, Writer out)
     throws IOException, TemplateException {
-        return parse(in, out, DataFormat.RECURSIVE, null).retCode;
+        return parse(in, out, DataFormat.INVOKE, null).retCode;
     }
     
     Result parse(TemplateReader in, Writer out, DataFormat format)
@@ -161,10 +161,8 @@
             throws IOException, TemplateException {
         
         Result result = new Result();
-        
-        if (format == DataFormat.SUBFUNCTION ||
-                format == DataFormat.SUBFUNCTION_NOCALL) {
-            
+
+        if (format.subfunction) {
             result.retCode = parseFunction(in, out, format);
             result.empty = false;
             return result;
@@ -178,7 +176,7 @@
                     if (result.retCode < 0)
                         result.retCode = 0;
                     
-                    if (!format.call) {
+                    if (!format.invoke) {
                         out.write(BRACKET_OPEN[openBracket]);
                     }
                     
@@ -190,7 +188,7 @@
                     result.empty = false;
                     termBracket = tb;
                     
-                    if (!format.call) {
+                    if (!format.invoke) {
                         out.write(BRACKET_CLOSE[openBracket]);
                     }
                     
@@ -356,33 +354,33 @@
             if (c < 0)
                 throw new TemplateException("Unexpected end of file.", in);
             
-            if (!fd.call)
+            if (!fd.invoke)
                 out.write(c);
             
             if (isSeparator(c, LIST_SEPARATORS)) {
                 return invoke(
-                        fd.call ? sb.toString() : "true",
-                        fd.call ?
+                        fd.invoke ? sb.toString() : "true",
+                        fd.invoke ?
                             DataFormat.SUBFUNCTION :
-                            DataFormat.SUBFUNCTION_NOCALL,
+                            DataFormat.SUBFUNCTION_NOINVOKE,
                         in, out);
             } else if (isSeparator(c, REC_DATA_SEPARATORS)) {
                 skipEscaped(in);
                 return invoke(
-                        fd.call ? sb.toString() : "true",
-                        fd.call ?
-                            DataFormat.RECURSIVE :
-                            DataFormat.NOCALL,
+                        fd.invoke ? sb.toString() : "true",
+                        fd.invoke ?
+                            DataFormat.INVOKE :
+                            DataFormat.NOINVOKE,
                         in, out);
             } else if (isSeparator(c, VERBATIM_DATA_SEPARATORS)) {
                 return invoke(
-                        fd.call ? sb.toString() : "true",
+                        fd.invoke ? sb.toString() : "true",
                         DataFormat.VERBATIM, in, out);
-            } else if (isSeparator(c, NOCALL_DATA_SEPARATORS)) {
+            } else if (isSeparator(c, NOINVOKE_DATA_SEPARATORS)) {
                 skipEscaped(in);
                 return invoke(
-                        fd.call ? sb.toString() : "true",
-                        DataFormat.NOCALL, in, out);
+                        fd.invoke ? sb.toString() : "true",
+                        DataFormat.NOINVOKE, in, out);
             } else {
                 sb.append((char)c);
             }