You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/08/05 09:05:58 UTC

[1/3] incubator-freemarker git commit: Fixed some parser error message glitches.

Repository: incubator-freemarker
Updated Branches:
  refs/heads/2.3-gae 16ff17463 -> 2aebfe533


Fixed some parser error message glitches.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/15afde13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/15afde13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/15afde13

Branch: refs/heads/2.3-gae
Commit: 15afde13463306d0e96f09211e0ccdf92d9ec71e
Parents: 16ff174
Author: ddekany <dd...@apache.org>
Authored: Sat Aug 5 10:01:56 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sat Aug 5 10:03:03 2017 +0200

----------------------------------------------------------------------
 src/main/javacc/FTL.jj                                      | 6 +++---
 src/test/java/freemarker/core/ParsingErrorMessagesTest.java | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15afde13/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index b011c41..175614c 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -3227,7 +3227,7 @@ Macro Macro() :
     )
     {
         if (inMacro || inFunction) {
-            throw new ParseException("Macros cannot be nested.", template, start);
+            throw new ParseException("Macro or function definitions can't be nested into each other.", template, start);
         }
         if (isFunction) inFunction = true; else inMacro = true;
     }
@@ -3294,12 +3294,12 @@ Macro Macro() :
     (
         end = <END_MACRO>
         {
-        	if (isFunction) throw new ParseException("Expected function end tag here.", template, start);
+        	if (isFunction) throw new ParseException("Expected function end tag here.", template, end);
     	}
         |
         end = <END_FUNCTION>
         {
-    		if (!isFunction) throw new ParseException("Expected macro end tag here.", template, start);
+    		if (!isFunction) throw new ParseException("Expected macro end tag here.", template, end);
     	}
     )
     {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/15afde13/src/test/java/freemarker/core/ParsingErrorMessagesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/ParsingErrorMessagesTest.java b/src/test/java/freemarker/core/ParsingErrorMessagesTest.java
index 53194a8..e471a31 100644
--- a/src/test/java/freemarker/core/ParsingErrorMessagesTest.java
+++ b/src/test/java/freemarker/core/ParsingErrorMessagesTest.java
@@ -61,7 +61,9 @@ public class ParsingErrorMessagesTest {
     @Test
     public void testUnclosedDirectives() {
         assertErrorContains("<#macro x>", "#macro", "unclosed");
+        assertErrorContains("<#macro x></#function>", "macro end tag");
         assertErrorContains("<#function x>", "#macro", "unclosed");
+        assertErrorContains("<#function x></#macro>", "function end tag");
         assertErrorContains("<#assign x>", "#assign", "unclosed");
         assertErrorContains("<#macro m><#local x>", "#local", "unclosed");
         assertErrorContains("<#global x>", "#global", "unclosed");


[2/3] incubator-freemarker git commit: (JavaDoc adjustment)

Posted by dd...@apache.org.
(JavaDoc adjustment)


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/e3d1bb83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/e3d1bb83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/e3d1bb83

Branch: refs/heads/2.3-gae
Commit: e3d1bb837df300d4b9230716cc391199a599e109
Parents: 15afde1
Author: ddekany <dd...@apache.org>
Authored: Sat Aug 5 10:03:39 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sat Aug 5 10:03:39 2017 +0200

----------------------------------------------------------------------
 src/main/java/freemarker/core/Environment.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3d1bb83/src/main/java/freemarker/core/Environment.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Environment.java b/src/main/java/freemarker/core/Environment.java
index c826381..565dcd4 100644
--- a/src/main/java/freemarker/core/Environment.java
+++ b/src/main/java/freemarker/core/Environment.java
@@ -242,8 +242,7 @@ public final class Environment extends Configurable {
     /**
      * Returns the {@link Template} that we are "lexically" inside at the moment. This template will change when
      * entering an {@code #include} or calling a macro or function in another template, or returning to yet another
-     * template with {@code #nested}. As such, it's useful in {@link TemplateDirectiveModel} to find out if from where
-     * the directive was called from.
+     * template with {@code #nested}.
      * 
      * @see #getMainTemplate()
      * @see #getCurrentNamespace()


[3/3] incubator-freemarker git commit: Documented the precision of arithmetical operations

Posted by dd...@apache.org.
Documented the precision of arithmetical operations


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/2aebfe53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/2aebfe53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/2aebfe53

Branch: refs/heads/2.3-gae
Commit: 2aebfe53331a6306481d44cee94eb45c6f42797b
Parents: e3d1bb8
Author: ddekany <dd...@apache.org>
Authored: Sat Aug 5 11:05:32 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sat Aug 5 11:05:32 2017 +0200

----------------------------------------------------------------------
 .../java/freemarker/core/ArithmeticEngine.java    |  5 +++--
 src/manual/en_US/book.xml                         | 18 ++++++++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/2aebfe53/src/main/java/freemarker/core/ArithmeticEngine.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ArithmeticEngine.java b/src/main/java/freemarker/core/ArithmeticEngine.java
index c07dc92..5e485b8 100644
--- a/src/main/java/freemarker/core/ArithmeticEngine.java
+++ b/src/main/java/freemarker/core/ArithmeticEngine.java
@@ -30,9 +30,10 @@ import freemarker.template.utility.OptimizerUtil;
 import freemarker.template.utility.StringUtil;
 
 /**
- * Class to perform arithmetic operations.
+ * Used for implementing the arithmetic operations and number comparisons in the template language. The concrete
+ * implementation is plugged into the configuration with the {@code arithmetical_engine} setting. 
+ * (See {@link Configurable#setArithmeticEngine(ArithmeticEngine)}.)
  */
-
 public abstract class ArithmeticEngine {
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/2aebfe53/src/manual/en_US/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index e072d1a..1288f8a 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -3304,8 +3304,6 @@ Slicing with right-unlimited ranges:
             </listitem>
           </itemizedlist>
 
-          <remark>Information about the precision?</remark>
-
           <para>Example:</para>
 
           <programlisting role="template">${100 - x * x}
@@ -3385,6 +3383,22 @@ ${12 % 6.9} &lt;#-- Prints 0 --&gt;</programlisting>
 ${-12 % 5} &lt;#-- Prints -2 --&gt;
 ${12 % -5} &lt;#-- Prints 2 --&gt;
 </programlisting>
+
+          <para role="forProgrammers">About the precision of the operations:
+          By default FreeMarker uses <literal>BigDecimal</literal>-s for all
+          arithmetical calculations, to avoid rounding and overflow/underflow
+          artifacts, and also keeps the result as
+          <literal>BigDecimal</literal>-s. So <literal>+</literal> (addition),
+          <literal>-</literal> (subtraction) and <literal>*</literal>
+          (multiplication) are <quote>lossless</quote>. Again by default,
+          <literal>/</literal> (division) results are calculated to 12
+          decimals with half-up rounding (unless some operands have even more
+          decimals, in which case it's calculated with that much decimals).
+          All this behavior depends on the
+          <literal>arithmetic_engine</literal> configuration setting
+          (<literal>Configurable.setArithmericEngine(ArithmericEngine)</literal>)
+          though, and some application might use a different value than the
+          default, although that's highly uncommon.</para>
         </section>
 
         <section xml:id="dgui_template_exp_comparison">