本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.5KB

  1. <!doctype html>
  2. <title>CodeMirror: Haxe mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="haxe.js"></script>
  8. <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  9. <div id=nav>
  10. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  11. <ul>
  12. <li><a href="../../index.html">Home</a>
  13. <li><a href="../../doc/manual.html">Manual</a>
  14. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  15. </ul>
  16. <ul>
  17. <li><a href="../index.html">Language modes</a>
  18. <li><a class=active href="#">Haxe</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>Haxe mode</h2>
  23. <div><p><textarea id="code-haxe" name="code">
  24. import one.two.Three;
  25. @attr("test")
  26. class Foo&lt;T&gt; extends Three
  27. {
  28. public function new()
  29. {
  30. noFoo = 12;
  31. }
  32. public static inline function doFoo(obj:{k:Int, l:Float}):Int
  33. {
  34. for(i in 0...10)
  35. {
  36. obj.k++;
  37. trace(i);
  38. var var1 = new Array();
  39. if(var1.length > 1)
  40. throw "Error";
  41. }
  42. // The following line should not be colored, the variable is scoped out
  43. var1;
  44. /* Multi line
  45. * Comment test
  46. */
  47. return obj.k;
  48. }
  49. private function bar():Void
  50. {
  51. #if flash
  52. var t1:String = "1.21";
  53. #end
  54. try {
  55. doFoo({k:3, l:1.2});
  56. }
  57. catch (e : String) {
  58. trace(e);
  59. }
  60. var t2:Float = cast(3.2);
  61. var t3:haxe.Timer = new haxe.Timer();
  62. var t4 = {k:Std.int(t2), l:Std.parseFloat(t1)};
  63. var t5 = ~/123+.*$/i;
  64. doFoo(t4);
  65. untyped t1 = 4;
  66. bob = new Foo&lt;Int&gt;
  67. }
  68. public var okFoo(default, never):Float;
  69. var noFoo(getFoo, null):Int;
  70. function getFoo():Int {
  71. return noFoo;
  72. }
  73. public var three:Int;
  74. }
  75. enum Color
  76. {
  77. red;
  78. green;
  79. blue;
  80. grey( v : Int );
  81. rgb (r:Int,g:Int,b:Int);
  82. }
  83. </textarea></p>
  84. <p>Hxml mode:</p>
  85. <p><textarea id="code-hxml">
  86. -cp test
  87. -js path/to/file.js
  88. #-remap nme:flash
  89. --next
  90. -D source-map-content
  91. -cmd 'test'
  92. -lib lime
  93. </textarea></p>
  94. </div>
  95. <script>
  96. var editor = CodeMirror.fromTextArea(document.getElementById("code-haxe"), {
  97. mode: "haxe",
  98. lineNumbers: true,
  99. indentUnit: 4,
  100. indentWithTabs: true
  101. });
  102. editor = CodeMirror.fromTextArea(document.getElementById("code-hxml"), {
  103. mode: "hxml",
  104. lineNumbers: true,
  105. indentUnit: 4,
  106. indentWithTabs: true
  107. });
  108. </script>
  109. <p><strong>MIME types defined:</strong> <code>text/x-haxe, text/x-hxml</code>.</p>
  110. </article>
上海开阖软件有限公司 沪ICP备12045867号-1