z183_ndeDots_parens_tst.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. XOWA: the XOWA Offline Wiki Application
  3. Copyright (C) 2012-2017 gnosygnu@gmail.com
  4. XOWA is licensed under the terms of the General Public License (GPL) Version 3,
  5. or alternatively under the terms of the Apache License Version 2.0.
  6. You may use XOWA according to either of these licenses as is most appropriate
  7. for your project on a case-by-case basis.
  8. The terms of each license can be found in the source code repository:
  9. GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
  10. Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
  11. */
  12. package gplx.gfml; import gplx.*;
  13. import org.junit.*;
  14. public class z183_ndeDots_parens_tst {
  15. @Before public void setup() {
  16. fx.ini_RootLxr_Add
  17. ( GfmlDocLxrs.NdeDot_lxr()
  18. , GfmlDocLxrs.NdeInline_lxr()
  19. , GfmlDocLxrs.NdeBodyBgn_lxr()
  20. , GfmlDocLxrs.NdeBodyEnd_lxr()
  21. , GfmlDocLxrs.NdeHdrBgn_lxr()
  22. , GfmlDocLxrs.NdeHdrEnd_lxr()
  23. );
  24. } GfmlParse_fxt fx = GfmlParse_fxt.new_();
  25. @Test public void Basic() {
  26. fx.tst_Doc("{a.b(c);z;}"
  27. , fx.nde_().ChainId_(0).Subs_
  28. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  29. ( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c")
  30. )
  31. , fx.nde_().ChainId_(0).Atru_("z")
  32. ));
  33. }
  34. @Test public void Basic_tkn() {
  35. //A_('1');
  36. fx.tst_Tkn("a(c);"
  37. , fx.tkn_grp_
  38. ( fx.tkn_itm_("a"), fx.tkn_itm_("(")
  39. , fx.tkn_grp_(fx.tkn_itm_("c"))
  40. , fx.tkn_itm_(")"), fx.tkn_itm_(";")
  41. )
  42. );
  43. }
  44. @Test public void Basic2_tkn() {
  45. fx.tst_Tkn("a.b(c);"
  46. , fx.tkn_grp_
  47. ( fx.tkn_itm_("a"), fx.tkn_itm_(".")
  48. , fx.tkn_grp_
  49. ( fx.tkn_itm_("b"), fx.tkn_itm_("("), fx.tkn_grp_ary_("c"), fx.tkn_itm_(")"), fx.tkn_itm_(";")
  50. )
  51. )
  52. );
  53. }
  54. @Test public void Many() {
  55. fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
  56. fx.tst_Doc("{a.b(c d e);z;}"
  57. , fx.nde_().ChainId_(0).Subs_
  58. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  59. ( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Atru_("d").Atru_("e")
  60. )
  61. , fx.nde_().ChainId_(0).Atru_("z")
  62. ));
  63. }
  64. // @Test public void Many2() {
  65. // fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
  66. // fx.tst_Doc("{a.b(c){d();}}"
  67. // , fx.nde_().ChainId_(0).Subs_
  68. // ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  69. // ( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Subs_
  70. // ( fx.nde_().Hnd_("d")
  71. // )
  72. // )
  73. // ));
  74. // }
  75. @Test public void Chain() {
  76. fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
  77. fx.tst_Doc("{a.b(c).d(e);z;}"
  78. , fx.nde_().ChainId_(0).Subs_
  79. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  80. ( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Subs_
  81. ( fx.nde_().Hnd_("d").ChainId_(1).Atru_("e")
  82. )
  83. )
  84. , fx.nde_().ChainId_(0).Atru_("z")
  85. ));
  86. }
  87. @Test public void Nest() {
  88. fx.tst_Doc("{a.b(c.d);z;}"
  89. , fx.nde_().ChainId_(0).Subs_
  90. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  91. ( fx.nde_().Hnd_("b").ChainId_(1).KeyedSubObj_(false).Subs_
  92. ( fx.nde_().Hnd_("c").ChainId_(2).KeyedSubObj_(true).Subs_
  93. ( fx.nde_().Hnd_("d").ChainId_(2).KeyedSubObj_(false)
  94. )
  95. )
  96. )
  97. , fx.nde_().Atru_("z")
  98. ));
  99. }
  100. @Test public void Nest_longer() {
  101. fx.tst_Doc("{a.b.c(d.e.f);z;}"
  102. , fx.nde_().ChainId_(0).Subs_
  103. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  104. ( fx.nde_().Hnd_("b").KeyedSubObj_(false).ChainId_(1).Subs_
  105. ( fx.nde_().Hnd_("c").KeyedSubObj_(false).ChainId_(1).Subs_
  106. ( fx.nde_().Hnd_("d").KeyedSubObj_(true).ChainId_(2).Subs_
  107. ( fx.nde_().Hnd_("e").KeyedSubObj_(false).ChainId_(2).Subs_
  108. ( fx.nde_().Hnd_("f").KeyedSubObj_(false).ChainId_(2)
  109. )
  110. )
  111. )
  112. )
  113. )
  114. , fx.nde_().Atru_("z")
  115. ));
  116. }
  117. @Test public void Nest_deeper() {
  118. fx.tst_Doc("{a.b(c.d(e.f));z;}"
  119. , fx.nde_().ChainId_(0).Subs_
  120. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  121. ( fx.nde_().Hnd_("b").KeyedSubObj_(false).ChainId_(1).Subs_
  122. ( fx.nde_().Hnd_("c").KeyedSubObj_(true).ChainId_(2).Subs_
  123. ( fx.nde_().Hnd_("d").KeyedSubObj_(false).ChainId_(2).Subs_
  124. ( fx.nde_().Hnd_("e").KeyedSubObj_(true).ChainId_(3).Subs_
  125. ( fx.nde_().Hnd_("f").KeyedSubObj_(false).ChainId_(3)
  126. )
  127. )
  128. )
  129. )
  130. )
  131. , fx.nde_().Atru_("z")
  132. ));
  133. }
  134. }