index.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!--
  2. Copyright (c) 2007-2010 Alessandro Warth <awarth@cs.ucla.edu>
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. !-->
  22. <html>
  23. <head>
  24. <title>OMeta/JS 2.0 Workspace</title>
  25. <script src="prototype.js"></script>
  26. <script src="prototype-fix.js"></script>
  27. <script src="lib.js"></script>
  28. <script src="ometa-base.js"></script>
  29. <script src="parser.js"></script>
  30. <script src="bs-js-compiler.js"></script>
  31. <script src="bs-ometa-compiler.js"></script>
  32. <script src="bs-ometa-optimizer.js"></script>
  33. <script src="bs-ometa-js-compiler.js"></script>
  34. <script src="bs-project-list-parser.js"></script>
  35. <script src="workspace.js"></script>
  36. <script src="wiki.js"></script>
  37. <script>
  38. function toggleVisible(id) {
  39. var style = document.getElementById(id).style
  40. style.visibility = style.visibility == "hidden" ? "visible" : "hidden"
  41. style.display = style.display == "block" ? "none" : "block"
  42. }
  43. function initializeThisPage() {
  44. $('workspaceForm').source.onkeydown = onShortCutKey
  45. var makeProjectSelector = function(id) {
  46. $(id + "Home").innerHTML =
  47. "<select id=" + id +
  48. " onChange='loadProject(this.options[this.selectedIndex].value)'><option value=''>(nevermind)</option></select>"
  49. }
  50. var addOption = function(toId, x) {
  51. var option = document.createElement("option")
  52. option.innerHTML = x.replace(/_/g, " ")
  53. option.value = x
  54. $(toId).appendChild(option)
  55. }
  56. makeProjectSelector('infoSelector')
  57. addOption('infoSelector', 'Sample_Project')
  58. addOption('infoSelector', 'Not_Quite_JS')
  59. addOption('infoSelector', 'Things_You_Should_Know')
  60. addOption('infoSelector', 'OMeta_Tutorial')
  61. addOption('infoSelector', 'Memoizing_Parameterized_Rules')
  62. addOption('infoSelector', 'Project_Listing')
  63. makeProjectSelector('projectSelector')
  64. var ps = $('projectSelector')
  65. try {
  66. var projects = ProjectListParser.matchAll(readFile("Project_Listing"), "projs")
  67. for (var idx = 0; idx < projects.length; idx++)
  68. addOption('projectSelector', projects[idx])
  69. }
  70. catch (e) { }
  71. $('workspaceForm').source.value = $('workspaceForm').source.origValue = ''
  72. $('workspaceForm').translation.value = ''
  73. $('workspaceForm').transcript.value = ''
  74. loadProject()
  75. }
  76. saveIt = saveProject
  77. if (!document.location.hash)
  78. document.location.hash = "#Sample_Project"
  79. titleRest = " - <nobr><span title='In case you are wondering, this is\n" +
  80. "(OMeta/JS) 2.0, not OMeta/(JS 2.0).\n" +
  81. "In other words, it has nothing to do\n" +
  82. "with JS 2 / EcmaScript 2.'>OMeta/JS 2.0</span> Workspace</nobr>"
  83. function translateCode(s) {
  84. var translationError = function(m, i) { alert("Translation error - please tell Alex about this!"); throw fail },
  85. tree = BSOMetaJSParser.matchAll(s, "topLevel", undefined, function(m, i) { throw objectThatDelegatesTo(fail, {errorPos: i}) })
  86. return BSOMetaJSTranslator.match(tree, "trans", undefined, translationError)
  87. }
  88. function include(fileName) {
  89. return eval(readFile(fileName))
  90. }
  91. </script>
  92. </head>
  93. <body onLoad="initializeThisPage()">
  94. <table border=0 align=right>
  95. <tr><td align=right><b>important info: </b></td><td><span id=infoSelectorHome></span></td></tr>
  96. <tr><td align=right><b>go to project: </b></td><td><span id=projectSelectorHome></span></td></tr>
  97. <tr><td colspan=2 align=right><input type=button value="previous versions of this project" onClick="document.location = 'http://www.tinlizzie.org/ometa-js/websvn/log.php?repname=ometa-js-projects&path=%2F' + document.location.hash.substring(1) + '.txt&rev=0&sc=0&isdir=0'"><br>
  98. </td></tr>
  99. </table>
  100. <table border=0><tr><td><h2 id=title>OMeta/JS 2.0 Workspace<!-- <small><font color=lightgray>(not to be confused with JS 2 / EcmaScript 4)</font></small>--></h2></td></tr></table>
  101. <b>Instructions</b>
  102. <input type=button value="+/-" onClick="toggleVisible('instructions')">
  103. <br>
  104. <div id=instructions style="visibility: visible; display: block">
  105. <table bgcolor=#f9f9f9 cellpadding=4
  106. style="border: 1px solid #333333; padding: .2em .2em .2em .2em; margin-bottom: .4em; margin-top: .1em">
  107. <tr><td>
  108. The text area below (<b>source</b>) works like a Smalltalk workspace:
  109. <bl><li>
  110. To evaluate some code, just select it and press the <input type=button value="do it" onClick="doIt()"> button.
  111. </li><li>
  112. Pressing <input type=button value="do it" onClick="doIt()"> without a selection evaluates the line that the cursor is on.
  113. </li><li>
  114. <input type=button value="print it" onClick="printIt()"> is like <input type=button value="do it" onClick="doIt()">,
  115. but it also prints the result.
  116. </li></bl>
  117. Also, you can press <input type=button value="save it" onClick="saveIt()"> to save the current project.
  118. </td></tr></table>
  119. </div>
  120. <b><span title="A useful place to add new HTMLElements - see Canvas project for an example">Play Area</span></b>
  121. <input type=button value="+/-" onClick="toggleVisible('playArea')">
  122. <br>
  123. <div id=playArea style="visibility: visible; display: block"></div>
  124. <form id=workspaceForm>
  125. <b>Source</b>
  126. <input type=button value="+/-" onClick="toggleVisible('source')">
  127. <br>
  128. <div id=source style="visibility: visible; display: block">
  129. <textarea cols=132 rows=24 name=source style="font-family:monaco, monospace; font-size: 10pt"></textarea><br>
  130. <input type=button value="print it (ctrl+p)" onClick="printIt()" style="margin-bottom: .4em">
  131. <input type=button value="do it (ctrl+d)" onClick="doIt()" style="margin-bottom: .4em">
  132. <input type=button value="save it (ctrl + s)" onClick="saveProject()" style="margin-bottom: .4em"><br>
  133. </div>
  134. <b><span title="Shows the JavaScript translation of the last thing that was evaluated above">Translation</span></b>
  135. <input type=button value="+/-" onClick="toggleVisible('translation')">
  136. <br>
  137. <div id=translation style="visibility: hidden; display: none">
  138. <textarea cols=132 rows=4 name=translation style="font-family:monaco, monospace; font-size: 10pt; margin-bottom: .4em">
  139. </textArea>
  140. </div>
  141. <b>Transcript</b>
  142. <input type=button value="+/-" onClick="toggleVisible('transcript')">
  143. <br>
  144. <div id=transcript style="visibility: hidden; display: none">
  145. <textarea cols=132 rows=4 name=transcript
  146. style="font-family:monaco, monospace; font-size: 10pt; margin-bottom: .4em"></textArea>
  147. </div>
  148. </form>
  149. To learn more about OMeta, click <a href=http://www.tinlizzie.org/ometa/>here</a>.<br>
  150. </body>
  151. </html>