z501_lxr_parse_tst.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 z501_lxr_parse_tst {
  15. GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
  16. @Test public void SymCreate() {
  17. fx.tst_Parse(String_.Concat
  18. ( "_lxr_sym:key='gfml.elm_key_1' raw='<-' cmd='gfml.elm_key';"
  19. , "a<-1;"
  20. )
  21. , fx.nde_().Atrk_("a", "1")
  22. );
  23. }
  24. @Test public void SymUpdate() {
  25. fx.tst_Parse(String_.Concat
  26. ( "_lxr_sym:key='gfml.elm_key_0' raw='<-';"
  27. , "a<-1 b=1;"
  28. )
  29. , fx.nde_().Atrk_("a", "1").Atru_("b=1")
  30. );
  31. }
  32. @Test public void SwapCreate() {
  33. fx.tst_Parse(String_.Concat
  34. ( "_lxr_sym:key='gfml.swap_0' raw='/?/?' val='/?';"
  35. , "/?/?;"
  36. )
  37. , fx.nde_().Atru_("/?")
  38. );
  39. }
  40. @Test public void FrameCreate() {
  41. fx.tst_Parse(String_.Concat
  42. ( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/';"
  43. , "a=/-ignore-/b;"
  44. )
  45. , fx.nde_().Atrk_("a", "b")
  46. );
  47. }
  48. @Test public void FrameUpdate() {
  49. fx.tst_Parse(String_.Concat
  50. ( "_lxr_frame:key='gfml.comment_0' bgn='--' end='!';"
  51. , "a=--ignore!"
  52. , "b;"
  53. )
  54. , fx.nde_().Atrk_("a", "b")
  55. );
  56. }
  57. //@Test
  58. public void FrameCreateNest() {
  59. fx.tst_Parse(String_.Concat
  60. ( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/' {"
  61. , "sym:key='gfml.comment_2_escape_bgn' raw='/-/-' val='/-' cmd='gfml.elm_data';"
  62. , "sym:key='gfml.comment_2_escape_end' raw='-/-/' val='-/' cmd='gfml.elm_data';"
  63. , "}"
  64. , "a=/-/-/-ignore-/b;"
  65. )
  66. , fx.nde_().Atrk_("a", "b")
  67. );
  68. // todo:
  69. // cmd should be waitingTkns add, not data (makes invisible
  70. // should resolve type on sym to lxr_sym (since _lxr_sym is not invoked) or create _lxr_frame/sym type
  71. // how to change inner lxrs (lookup by key?)
  72. }
  73. // @Test public void FrameUpdateEval() {
  74. // raw = String_.Concat
  75. // ( "_lxr_frame:key='gfml.eval_0' bgn='~<' end='>';" // how to handle '<~' where <~ (block quote)
  76. // , "a=~[t];"
  77. // );
  78. // gdoc = GfmlDoc_.parse_any_eol_(raw);
  79. // fx_nde.tst_SubKeys(gdoc, 0, atr_("a", "\t"));
  80. // }
  81. }