--- adapt BOX of syntax/ to version in editor/
authorWalther Neuper <wneuper@ist.tugraz.at>
Wed, 02 Aug 2017 09:56:12 +0200
changeset 5190d3fa6cda3137
parent 5189 40a3d69df537
child 5192 2183a5d68d6f
--- adapt BOX of syntax/ to version in editor/

Note: 2 TestCases are still broken
isac-java/src/java-tests/isac/gui/mawen/editor/TestDATAeditor.scala
isac-java/src/java/isac/gui/mawen/syntax/ast.scala
     1.1 --- a/isac-java/src/java-tests/isac/gui/mawen/editor/TestDATAeditor.scala	Wed Aug 02 09:11:13 2017 +0200
     1.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/editor/TestDATAeditor.scala	Wed Aug 02 09:56:12 2017 +0200
     1.3 @@ -93,13 +93,11 @@
     1.4          Constant("Diff.d_d"),
     1.5          Variable("x"),
     1.6          Appl(List(               // added to test_create_..
     1.7 -          Constant("BOX"),       // added to test_create_..
     1.8 -          Constant("1"),         // fixes the colour within this group of formulas
     1.9 +          Constant("BOX.1"),     // added, fixes the colour within this group of formulas
    1.10            Appl(List(
    1.11              Constant("Transcendental.sin"),
    1.12              Appl(List(           //added to test_create_..
    1.13 -              Constant("BOX"),   //added to test_create_..
    1.14 -              Constant("2"),     // fixes another colour within this group of formulas
    1.15 +              Constant("BOX.2"), // added, fixes the colour within this group of formulas
    1.16                Appl(List(
    1.17                  Constant("Power.power_class.power"),
    1.18                  Variable("x"),
    1.19 @@ -112,19 +110,16 @@
    1.20          Constant("Diff.d_d"),
    1.21          Variable("bdv"),
    1.22          Appl(List(               //added to test_create_..
    1.23 -          Constant("BOX"),       // added to test_create_..
    1.24 -          Constant("1"),         // fixes the colour within this group of formulas
    1.25 +          Constant("BOX.1"),     //added, fixes the colour within this group of formulas
    1.26            Appl(List(
    1.27              Constant("Transcendental.sin"),
    1.28              Appl(List(           //added to test_create_..
    1.29 -              Constant("BOX"),   //added to test_create_..
    1.30 -              Constant("2"),     // fixes another colour within this group of formulas
    1.31 +              Constant("BOX.2"), //added, fixes another colour within this group of formulas
    1.32               Variable("u"))))))))),
    1.33        Appl(List(
    1.34          Constant("Groups.times_class.times"),
    1.35          Appl(List(               //added to test_create_..
    1.36 -          Constant("BOX"),       // added to test_create_..
    1.37 -          Constant("1a"),        // fixes the colour within this group of formulas
    1.38 +          Constant("BOX.11"),    //added, fixes the colour within this group of formulas
    1.39            Appl(List(
    1.40              Constant("Transcendental.cos"),
    1.41              Variable("u"))))),
    1.42 @@ -132,8 +127,7 @@
    1.43            Constant("Diff.d_d"),
    1.44            Variable("bdv"),
    1.45            Appl(List(             //added to test_create_..
    1.46 -            Constant("BOX"),     //added to test_create_..
    1.47 -            Constant("2a"),      // fixes another colour within this group of formulas
    1.48 +            Constant("BOX.12"),  //added, fixes another colour within this group of formulas
    1.49              Variable("u")))))))))
    1.50  
    1.51    //here the CURSOR coincides with a GAP and a BOX
    1.52 @@ -146,8 +140,7 @@
    1.53        Appl(List(
    1.54          Constant("Groups.times_class.times"),
    1.55          Appl(List(               //added to test_create_..
    1.56 -          Constant("BOX"),       // added to test_create_..
    1.57 -          Constant("1a"),        // fixes the colour within this group of formulas
    1.58 +          Constant("BOX.11"),    //added, fixes the colour within this group of formulas
    1.59            Appl(List(
    1.60              Constant("Transcendental.cos"),
    1.61              Appl(List(
    1.62 @@ -158,8 +151,7 @@
    1.63            Constant("Diff.d_d"),
    1.64            Variable("x"),
    1.65            Appl(List(             //added to test_create_..
    1.66 -            Constant("BOX"),     //added to test_create_..
    1.67 -            Constant("2a"),      // fixes another colour within this group of formulas
    1.68 +            Constant("BOX.12"),  //added, fixes another colour within this group of formulas
    1.69              Appl(List(
    1.70                Constant("CURSOR"),
    1.71                Constant("GAP")))))))))))
    1.72 @@ -249,8 +241,7 @@
    1.73      Appl(List(
    1.74        Constant("Groups.plus_class.plus"),
    1.75          Appl(List( 
    1.76 -          Constant("BOX"),      //a BOX containing "a"
    1.77 -          Constant("1"),        // fixes the colour within this group of formulas
    1.78 +          Constant("BOX.1"),      //a BOX containing "a", 1 fixes the colour within this group of formulas
    1.79            Variable("a"))),
    1.80        Appl(List(
    1.81          Constant("Groups.plus_class.plus"),
    1.82 @@ -262,8 +253,7 @@
    1.83    //here a BOX with the CURSOR on a GAP as in box_07_with_cursor above
    1.84    def box_with_cursor_on_gap =
    1.85          Appl(List( 
    1.86 -          Constant("BOX"),       // added to test_create_..
    1.87 -          Constant("1"),         // fixes the colour within this group of formulas
    1.88 +          Constant("BOX.1"),       // added, fixes the colour within this group of formulas
    1.89            Appl(List(
    1.90              Constant("CURSOR"),
    1.91              Constant("GAP")))))
    1.92 @@ -305,10 +295,11 @@
    1.93     *   un-boxed  <-->  BOXed
    1.94     *   ast       <-->  Appl(List(Constant("BOX"), Constant("1"), ast))
    1.95     *   
    1.96 -   *   The separation of Constant("1") allows for pattern matching 
    1.97 -   *   with Appl(Constant("BOX") :: Constant("1") :: ast).
    1.98 -   *   "1" denotes a colour, "1a" a colour similar to "1" (there are at most 2 "similar" colours)
    1.99 -   *   numbers "1".."9" are mapped to colours by some settings-file.
   1.100 +   *   Scala pattern matching may include in if:
   1.101 +   *   with Appl(Constant("BOX.1") :: ast).
   1.102 +   *   "1" denotes a colour, "11" a colour similar to "1" (there are at most 2 "similar" colours)
   1.103 +   *   TODO: introduce notion of "similar" colours
   1.104 +   *   numbers "1".."9" are mapped in <code>editor.Settings.CollorMapping</code>
   1.105     *   
   1.106     * # CURSOR, denoted by {ast}, ast is some (sub-)term preceded by the cursor
   1.107     *   without   <-->  with CURSOR
   1.108 @@ -327,8 +318,7 @@
   1.109      Appl(List(
   1.110        Constant("Groups.plus_class.plus"),
   1.111        Appl(List(
   1.112 -        Constant("BOX"),
   1.113 -        Constant("1"),
   1.114 +        Constant("BOX.1"),
   1.115          Variable("aaa"))),
   1.116        Variable("bbb")))
   1.117    def nest_BOX_2 = //"aaa + [bbb]"
   1.118 @@ -336,13 +326,11 @@
   1.119        Constant("Groups.plus_class.plus"),
   1.120        Variable("aaa"),
   1.121        Appl(List(
   1.122 -        Constant("BOX"),
   1.123 -        Constant("1"),
   1.124 +        Constant("BOX.1"),
   1.125          Variable("bbb")))))
   1.126    def nest_BOX_3 = //"[aaa + bbb]"
   1.127      Appl(List(
   1.128 -      Constant("BOX"),
   1.129 -      Constant("1"),
   1.130 +      Constant("BOX.1"),
   1.131          Appl(List(
   1.132            Constant("Groups.plus_class.plus"),
   1.133            Variable("aaa"),
   1.134 @@ -351,8 +339,7 @@
   1.135      Appl(List(
   1.136        Constant("Groups.plus_class.plus"),
   1.137        Appl(List(
   1.138 -        Constant("BOX"),
   1.139 -        Constant("1"),
   1.140 +        Constant("BOX.1"),
   1.141          Appl(List(
   1.142            Constant("CURSOR"),
   1.143            Variable("aaa"))))),
   1.144 @@ -361,8 +348,7 @@
   1.145      Appl(List(
   1.146        Constant("Groups.plus_class.plus"),
   1.147        Appl(List(
   1.148 -        Constant("BOX"),
   1.149 -        Constant("1"),
   1.150 +        Constant("BOX.1"),
   1.151          Appl(List(
   1.152            Constant("CURSOR"),
   1.153            Constant("GAP"))))),
   1.154 @@ -371,8 +357,7 @@
   1.155      Appl(List(
   1.156        Constant("Groups.plus_class.plus"),
   1.157        Appl(List(
   1.158 -        Constant("BOX"),
   1.159 -        Constant("1"),
   1.160 +        Constant("BOX.1"),
   1.161          Variable("aaa"))),
   1.162        Appl(List(
   1.163          Constant("CURSOR"),
   1.164 @@ -387,8 +372,7 @@
   1.165      */
   1.166    def nest_CURSOR_BOX_3A = //"[{aaa + bbb}]" case (1)
   1.167      Appl(List(
   1.168 -      Constant("BOX"),
   1.169 -      Constant("1"),
   1.170 +      Constant("BOX.1"),
   1.171        Appl(List(
   1.172          Constant("CURSOR"),
   1.173          Appl(List(
     2.1 --- a/isac-java/src/java/isac/gui/mawen/syntax/ast.scala	Wed Aug 02 09:11:13 2017 +0200
     2.2 +++ b/isac-java/src/java/isac/gui/mawen/syntax/ast.scala	Wed Aug 02 09:56:12 2017 +0200
     2.3 @@ -108,7 +108,7 @@
     2.4          uniop + XLibrary.enclose("(", ")", to_str(a, 0, "none"))
     2.5        }
     2.6  
     2.7 -    case Appl(List(Constant("BOX"), Constant(_), a)) => to_str(a, prior, "none")
     2.8 +    case Appl(List(Constant(str), a)) if str.startsWith("BOX") => to_str(a, prior, "none")
     2.9      case Appl(List(Constant(str), a1, a2)) => to_binop(str, a1, a2, prior, l_r)
    2.10  
    2.11      case Appl(asts) => XLibrary.strs_to_str(asts.map(x => {