gollum 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gollum might be problematic. Click here for more details.

Files changed (454) hide show
  1. data/README.md +44 -7
  2. data/Rakefile +1 -1
  3. data/bin/gollum +20 -1
  4. data/gollum.gemspec +400 -5
  5. data/lib/gollum.rb +2 -1
  6. data/lib/gollum/blob_entry.rb +13 -1
  7. data/lib/gollum/committer.rb +10 -1
  8. data/lib/gollum/file.rb +15 -2
  9. data/lib/gollum/file_view.rb +145 -0
  10. data/lib/gollum/frontend/app.rb +217 -69
  11. data/lib/gollum/frontend/helpers.rb +21 -0
  12. data/lib/gollum/frontend/public/gollum/css/_styles.css +121 -0
  13. data/lib/gollum/frontend/public/gollum/css/editor.css +17 -8
  14. data/lib/gollum/frontend/public/gollum/css/gollum.css +440 -402
  15. data/lib/gollum/frontend/public/gollum/css/template.css +540 -289
  16. data/lib/gollum/frontend/public/gollum/images/dirty-shade.png +0 -0
  17. data/lib/gollum/frontend/public/gollum/images/fileview/document.png +0 -0
  18. data/lib/gollum/frontend/public/gollum/images/fileview/folder-horizontal.png +0 -0
  19. data/lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png +0 -0
  20. data/lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png +0 -0
  21. data/lib/gollum/frontend/public/gollum/images/para.png +0 -0
  22. data/lib/gollum/frontend/public/gollum/images/pin-16.png +0 -0
  23. data/lib/gollum/frontend/public/gollum/images/pin-20.png +0 -0
  24. data/lib/gollum/frontend/public/gollum/images/pin-24.png +0 -0
  25. data/lib/gollum/frontend/public/gollum/images/pin-32.png +0 -0
  26. data/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js +31 -7
  27. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/asciidoc.js +2 -1
  28. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/creole.js +2 -1
  29. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/markdown.js +18 -6
  30. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/org.js +2 -1
  31. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/pod.js +2 -1
  32. data/lib/gollum/frontend/public/gollum/javascript/editor/langs/textile.js +2 -1
  33. data/lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js +3 -0
  34. data/lib/gollum/frontend/public/gollum/javascript/gollum.js +78 -16
  35. data/lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js +4 -0
  36. data/lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js +8 -0
  37. data/lib/gollum/frontend/public/gollum/livepreview/css/custom.css +107 -0
  38. data/lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png +0 -0
  39. data/lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png +0 -0
  40. data/lib/gollum/frontend/public/gollum/livepreview/images/save_24.png +0 -0
  41. data/lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png +0 -0
  42. data/lib/gollum/frontend/public/gollum/livepreview/index.html +46 -0
  43. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/ace.js +103 -0
  44. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/anchor.js +254 -0
  45. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/anchor_test.js +184 -0
  46. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/background_tokenizer.js +261 -0
  47. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/background_tokenizer_test.js +92 -0
  48. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/command_manager.js +121 -0
  49. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/command_manager_test.js +193 -0
  50. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/default_commands.js +460 -0
  51. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js +101 -0
  52. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js +124 -0
  53. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/codefolding-fold-button-states.png +0 -0
  54. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css +327 -0
  55. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/expand-marker.png +0 -0
  56. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/document.js +617 -0
  57. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/document_test.js +314 -0
  58. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session.js +2419 -0
  59. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/bracket_match.js +252 -0
  60. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/fold.js +116 -0
  61. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/fold_line.js +276 -0
  62. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session/folding.js +759 -0
  63. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/edit_session_test.js +981 -0
  64. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor.js +2163 -0
  65. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor_change_document_test.js +195 -0
  66. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor_highlight_selected_word_test.js +231 -0
  67. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor_navigation_test.js +171 -0
  68. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/editor_text_edit_test.js +562 -0
  69. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/ext/static.css +22 -0
  70. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/ext/static_highlight.js +98 -0
  71. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/ext/static_highlight_test.js +81 -0
  72. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/ext/textarea.js +536 -0
  73. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/emacs.js +367 -0
  74. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/hash_handler.js +170 -0
  75. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/keybinding.js +143 -0
  76. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/state_handler.js +257 -0
  77. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/textinput.js +315 -0
  78. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim.js +122 -0
  79. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/commands.js +556 -0
  80. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/aliases.js +101 -0
  81. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/motions.js +611 -0
  82. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/operators.js +193 -0
  83. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/maps/util.js +134 -0
  84. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/keyboard/vim/registers.js +49 -0
  85. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/cursor.js +202 -0
  86. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/gutter.js +187 -0
  87. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/marker.js +214 -0
  88. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text.js +595 -0
  89. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/layer/text_test.js +106 -0
  90. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/browser_focus.js +105 -0
  91. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/dom.js +292 -0
  92. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/es5-shim.js +1059 -0
  93. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/event.js +317 -0
  94. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/event_emitter.js +121 -0
  95. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/event_emitter_test.js +72 -0
  96. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/fixoldbrowsers.js +19 -0
  97. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/keys.js +129 -0
  98. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/lang.js +164 -0
  99. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/net.js +62 -0
  100. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/oop.js +61 -0
  101. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/regexp.js +113 -0
  102. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/useragent.js +105 -0
  103. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour.js +98 -0
  104. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/cstyle.js +225 -0
  105. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/html.js +98 -0
  106. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xml.js +113 -0
  107. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/xquery.js +68 -0
  108. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search.js +74 -0
  109. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c9search_highlight_rules.js +66 -0
  110. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c_cpp.js +132 -0
  111. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/c_cpp_highlight_rules.js +180 -0
  112. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/clojure.js +121 -0
  113. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/clojure_highlight_rules.js +235 -0
  114. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee.js +121 -0
  115. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/coffee-script.js +63 -0
  116. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/helpers.js +100 -0
  117. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/lexer.js +739 -0
  118. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/nodes.js +2756 -0
  119. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/parser.js +603 -0
  120. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/parser_test.js +68 -0
  121. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/rewriter.js +342 -0
  122. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee/scope.js +154 -0
  123. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules.js +227 -0
  124. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_highlight_rules_test.js +72 -0
  125. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coffee_worker.js +92 -0
  126. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion.js +71 -0
  127. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion_highlight_rules.js +135 -0
  128. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/coldfusion_test.js +74 -0
  129. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/csharp.js +58 -0
  130. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/csharp_highlight_rules.js +104 -0
  131. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css.js +110 -0
  132. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css/csslint.js +9014 -0
  133. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_highlight_rules.js +242 -0
  134. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_highlight_rules_test.js +99 -0
  135. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_test.js +85 -0
  136. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_worker.js +66 -0
  137. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_worker_test.js +75 -0
  138. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/diff.js +58 -0
  139. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/diff_highlight_rules.js +108 -0
  140. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/doc_comment_highlight_rules.js +93 -0
  141. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js +83 -0
  142. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js +127 -0
  143. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js +108 -0
  144. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/cstyle.js +95 -0
  145. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/cstyle_test.js +92 -0
  146. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/diff.js +76 -0
  147. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js +115 -0
  148. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html.js +86 -0
  149. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html_test.js +169 -0
  150. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/mixed.js +88 -0
  151. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js +65 -0
  152. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js +105 -0
  153. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/xml.js +262 -0
  154. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/xml_test.js +117 -0
  155. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang.js +81 -0
  156. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang_highlight_rules.js +129 -0
  157. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/groovy.js +24 -0
  158. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/groovy_highlight_rules.js +183 -0
  159. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haxe.js +58 -0
  160. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haxe_highlight_rules.js +104 -0
  161. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js +83 -0
  162. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js +159 -0
  163. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules_test.js +93 -0
  164. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_test.js +74 -0
  165. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/java.js +25 -0
  166. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/java_highlight_rules.js +144 -0
  167. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript.js +164 -0
  168. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js +471 -0
  169. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules_test.js +225 -0
  170. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_test.js +165 -0
  171. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_worker.js +88 -0
  172. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_worker_test.js +99 -0
  173. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json.js +100 -0
  174. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json/json_parse.js +346 -0
  175. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_highlight_rules.js +111 -0
  176. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker.js +103 -0
  177. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker_test.js +108 -0
  178. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsx.js +53 -0
  179. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsx_highlight_rules.js +122 -0
  180. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js +57 -0
  181. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex_highlight_rules.js +38 -0
  182. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/less.js +87 -0
  183. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/less_highlight_rules.js +279 -0
  184. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid.js +116 -0
  185. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid_highlight_rules.js +220 -0
  186. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid_highlight_rules_test.js +91 -0
  187. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lua.js +87 -0
  188. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lua_highlight_rules.js +436 -0
  189. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js +22 -0
  190. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js +42 -0
  191. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/markdown.js +81 -0
  192. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/markdown_highlight_rules.js +195 -0
  193. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/matching_brace_outdent.js +81 -0
  194. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/matching_parens_outdent.js +81 -0
  195. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml.js +103 -0
  196. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml_highlight_rules.js +355 -0
  197. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/perl.js +117 -0
  198. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/perl_highlight_rules.js +168 -0
  199. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/pgsql.js +78 -0
  200. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/pgsql_highlight_rules.js +583 -0
  201. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/php.js +119 -0
  202. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/php_highlight_rules.js +1165 -0
  203. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/powershell.js +58 -0
  204. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/powershell_highlight_rules.js +138 -0
  205. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python.js +147 -0
  206. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python_highlight_rules.js +182 -0
  207. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python_test.js +86 -0
  208. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby.js +116 -0
  209. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules.js +194 -0
  210. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules_test.js +116 -0
  211. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scad.js +132 -0
  212. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scad_highlight_rules.js +168 -0
  213. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scala.js +25 -0
  214. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scala_highlight_rules.js +179 -0
  215. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scss.js +86 -0
  216. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/scss_highlight_rules.js +304 -0
  217. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sh.js +144 -0
  218. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sh_highlight_rules.js +145 -0
  219. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sql.js +70 -0
  220. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sql_highlight_rules.js +89 -0
  221. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/svg.js +78 -0
  222. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/svg_highlight_rules.js +71 -0
  223. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text.js +159 -0
  224. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text_highlight_rules.js +109 -0
  225. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text_test.js +71 -0
  226. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/textile.js +73 -0
  227. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/textile_highlight_rules.js +100 -0
  228. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml.js +65 -0
  229. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules.js +109 -0
  230. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules_test.js +103 -0
  231. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_test.js +82 -0
  232. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js +120 -0
  233. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery.js +202 -0
  234. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/Position.js +59 -0
  235. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/Readme.md +6 -0
  236. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/StringLexer.js +1686 -0
  237. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XMLLexer.js +2993 -0
  238. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQDTLexer.js +69 -0
  239. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQDTParser.js +63 -0
  240. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQueryLexer.js +10363 -0
  241. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQueryParser.js +42525 -0
  242. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQuerySemanticHighlighter.js +165 -0
  243. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/antlr3-all.js +6177 -0
  244. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/xquery.js +55 -0
  245. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_highlight_rules.js +158 -0
  246. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_worker.js +86 -0
  247. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/yaml.js +64 -0
  248. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/yaml_highlight_rules.js +116 -0
  249. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/model/editor.js +70 -0
  250. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_gutter_handler.js +73 -0
  251. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/default_handlers.js +354 -0
  252. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/dragdrop.js +105 -0
  253. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/fold_handler.js +71 -0
  254. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/mouse_event.js +140 -0
  255. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/mouse_handler.js +158 -0
  256. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/multi_select_handler.js +163 -0
  257. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/multi_select.js +762 -0
  258. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/multi_select_test.js +171 -0
  259. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/definitions.js +696 -0
  260. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/lexer.js +598 -0
  261. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/options.js +61 -0
  262. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/parser.js +2072 -0
  263. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/placeholder.js +278 -0
  264. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/placeholder_test.js +164 -0
  265. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/range.js +581 -0
  266. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/range_list.js +230 -0
  267. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/range_list_test.js +170 -0
  268. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/range_test.js +198 -0
  269. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/renderloop.js +93 -0
  270. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/requirejs/text.js +58 -0
  271. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/scrollbar.js +142 -0
  272. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/search.js +398 -0
  273. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/search_highlight.js +87 -0
  274. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/search_test.js +451 -0
  275. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/selection.js +886 -0
  276. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/selection_test.js +472 -0
  277. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/split.js +411 -0
  278. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all.js +42 -0
  279. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/all_browser.js +136 -0
  280. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/assertions.js +63 -0
  281. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/assert.js +313 -0
  282. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/async.js +529 -0
  283. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/index.js +13 -0
  284. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/test.js +195 -0
  285. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/asyncjs/utils.js +65 -0
  286. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/benchmark.js +85 -0
  287. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/mockdom.js +10 -0
  288. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/mockrenderer.js +204 -0
  289. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/tests.html +46 -0
  290. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css +159 -0
  291. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.js +46 -0
  292. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css +118 -0
  293. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.js +46 -0
  294. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.css +119 -0
  295. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds_midnight.js +46 -0
  296. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.css +145 -0
  297. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/cobalt.js +46 -0
  298. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.css +151 -0
  299. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/crimson_editor.js +46 -0
  300. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.css +149 -0
  301. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dawn.js +46 -0
  302. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.css +182 -0
  303. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/dreamweaver.js +45 -0
  304. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.css +102 -0
  305. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/eclipse.js +48 -0
  306. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.css +133 -0
  307. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/github.js +46 -0
  308. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.css +137 -0
  309. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/idle_fingers.js +46 -0
  310. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.css +140 -0
  311. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/kr_theme.js +46 -0
  312. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.css +140 -0
  313. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore.js +46 -0
  314. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.css +146 -0
  315. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/merbivore_soft.js +46 -0
  316. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.css +148 -0
  317. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/mono_industrial.js +46 -0
  318. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.css +145 -0
  319. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/monokai.js +46 -0
  320. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.css +150 -0
  321. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/pastel_on_dark.js +46 -0
  322. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.css +131 -0
  323. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_dark.js +46 -0
  324. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.css +130 -0
  325. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/solarized_light.js +46 -0
  326. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.css +165 -0
  327. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/textmate.js +47 -0
  328. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.css +164 -0
  329. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow.js +46 -0
  330. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.css +164 -0
  331. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night.js +46 -0
  332. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.css +164 -0
  333. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_blue.js +46 -0
  334. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.css +164 -0
  335. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_bright.js +46 -0
  336. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.css +160 -0
  337. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/tomorrow_night_eighties.js +46 -0
  338. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.css +162 -0
  339. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.js +46 -0
  340. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css +141 -0
  341. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.js +46 -0
  342. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/token_iterator.js +162 -0
  343. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/token_iterator_test.js +219 -0
  344. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/tokenizer.js +195 -0
  345. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/undomanager.js +142 -0
  346. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/unicode.js +107 -0
  347. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js +1402 -0
  348. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer_test.js +93 -0
  349. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/jshint.js +4469 -0
  350. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/jslint.js +6396 -0
  351. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/mirror.js +43 -0
  352. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/worker.js +138 -0
  353. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/worker_client.js +176 -0
  354. data/lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/worker_sourcemint.js +73 -0
  355. data/lib/gollum/frontend/public/gollum/livepreview/js/jquery.ba-throttle-debounce.min.js +2 -0
  356. data/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +456 -0
  357. data/lib/gollum/frontend/public/gollum/livepreview/js/md_sundown.js +22 -0
  358. data/lib/gollum/frontend/public/gollum/livepreview/js/requirejs.min.js +35 -0
  359. data/lib/gollum/frontend/public/gollum/livepreview/js/sundown.js +1 -0
  360. data/lib/gollum/frontend/public/gollum/livepreview/licenses/ace/LICENSE.txt +476 -0
  361. data/lib/gollum/frontend/public/gollum/livepreview/licenses/bootstraponline_gollum/LICENSE.txt +9 -0
  362. data/lib/gollum/frontend/public/gollum/livepreview/licenses/debounce/LICENSE-MIT.txt +22 -0
  363. data/lib/gollum/frontend/public/gollum/livepreview/licenses/gollum/LICENSE.txt +21 -0
  364. data/lib/gollum/frontend/public/gollum/livepreview/licenses/jquery/MIT-LICENSE.txt +20 -0
  365. data/lib/gollum/frontend/public/gollum/livepreview/licenses/licenses.txt +59 -0
  366. data/lib/gollum/frontend/public/gollum/livepreview/licenses/notepages/LICENSE.txt +19 -0
  367. data/lib/gollum/frontend/public/gollum/livepreview/licenses/requirejs/LICENSE.txt +58 -0
  368. data/lib/gollum/frontend/public/gollum/livepreview/licenses/retina_display_icon_set/by_sa_3.0_unported_legalcode.txt +359 -0
  369. data/lib/gollum/frontend/public/gollum/livepreview/licenses/sizzle/LICENSE.txt +148 -0
  370. data/lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt +4 -0
  371. data/lib/gollum/frontend/public/gollum/livepreview/readme.md +44 -0
  372. data/lib/gollum/frontend/templates/compare.mustache +9 -9
  373. data/lib/gollum/frontend/templates/create.mustache +4 -1
  374. data/lib/gollum/frontend/templates/edit.mustache +6 -3
  375. data/lib/gollum/frontend/templates/editor.mustache +30 -14
  376. data/lib/gollum/frontend/templates/file_view.mustache +32 -0
  377. data/lib/gollum/frontend/templates/history.mustache +8 -8
  378. data/lib/gollum/frontend/templates/layout.mustache +21 -14
  379. data/lib/gollum/frontend/templates/page.mustache +37 -14
  380. data/lib/gollum/frontend/templates/pages.mustache +14 -10
  381. data/lib/gollum/frontend/templates/search.mustache +2 -2
  382. data/lib/gollum/frontend/templates/searchbar.mustache +1 -1
  383. data/lib/gollum/frontend/uri_encode_component.rb +172 -0
  384. data/lib/gollum/frontend/views/compare.rb +2 -4
  385. data/lib/gollum/frontend/views/create.rb +5 -0
  386. data/lib/gollum/frontend/views/edit.rb +12 -0
  387. data/lib/gollum/frontend/views/file_view.rb +19 -0
  388. data/lib/gollum/frontend/views/has_page.rb +15 -0
  389. data/lib/gollum/frontend/views/history.rb +8 -4
  390. data/lib/gollum/frontend/views/layout.rb +9 -1
  391. data/lib/gollum/frontend/views/page.rb +37 -10
  392. data/lib/gollum/frontend/views/pages.rb +48 -0
  393. data/lib/gollum/git_access.rb +2 -2
  394. data/lib/gollum/markup.rb +115 -19
  395. data/lib/gollum/page.rb +79 -9
  396. data/lib/gollum/tex.rb +319 -42
  397. data/lib/gollum/wiki.rb +92 -12
  398. data/licenses/css_tree_menu_thecssninja/license.txt +50 -0
  399. data/licenses/licenses.txt +23 -0
  400. data/licenses/unity_asset_pool/COPYRIGHT +286 -0
  401. data/test/examples/lotr.git/config +1 -1
  402. data/test/examples/lotr.git/logs/HEAD +4 -0
  403. data/test/examples/lotr.git/logs/refs/heads/master +4 -0
  404. data/test/examples/lotr.git/objects/0d/c9016ca928c78d5421a99a53b379b53929221e +0 -0
  405. data/test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0 +0 -0
  406. data/test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6 +0 -0
  407. data/test/examples/lotr.git/objects/45/3b250f979c7bd6dfb62640c944c982ae6721ee +0 -0
  408. data/test/examples/lotr.git/objects/45/f319ee12f2b551b901b22e72602963c366fff1 +0 -0
  409. data/test/examples/lotr.git/objects/46/a697caf435815bb07bbce947fc2d58be15f087 +0 -0
  410. data/test/examples/lotr.git/objects/4c/45c2b4e297a726c3d3f66886f35373e48fe1c5 +2 -0
  411. data/test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15 +0 -0
  412. data/test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2 +1 -0
  413. data/test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71 +0 -0
  414. data/test/examples/lotr.git/objects/7b/60c5a20a501a70f2317fa0ef763e1e2ce22d6b +0 -0
  415. data/test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979 +0 -0
  416. data/test/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809 +0 -0
  417. data/test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6 +0 -0
  418. data/test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c +0 -0
  419. data/test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd +0 -0
  420. data/test/examples/lotr.git/objects/c9/6a7645db5d4c76389e77cd103ef3ed77d81e4c +0 -0
  421. data/test/examples/lotr.git/objects/ca/7355dc497e9729fbaf0c0e3f424b86afef5614 +0 -0
  422. data/test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd +2 -0
  423. data/test/examples/lotr.git/objects/d5/29304506d37f544675244c335d85cab5d29966 +0 -0
  424. data/test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df +1 -0
  425. data/test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634 +0 -0
  426. data/test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66 +0 -0
  427. data/test/examples/lotr.git/refs/heads/master +1 -1
  428. data/test/examples/revert.git/COMMIT_EDITMSG +1 -1
  429. data/test/examples/revert.git/index +0 -0
  430. data/test/examples/revert.git/logs/HEAD +1 -0
  431. data/test/examples/revert.git/logs/refs/heads/master +1 -0
  432. data/test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab +0 -0
  433. data/test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa +0 -0
  434. data/test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023 +3 -0
  435. data/test/examples/revert.git/refs/heads/master +1 -1
  436. data/test/file_view/1_file.txt +3 -0
  437. data/test/file_view/1_file_1_folder.txt +8 -0
  438. data/test/file_view/1_folder.txt +8 -0
  439. data/test/file_view/2_files_2_folders.txt +12 -0
  440. data/test/file_view/2_files_2_folders_1_root.txt +13 -0
  441. data/test/file_view/nested_folders.txt +28 -0
  442. data/test/test_app.rb +162 -12
  443. data/test/test_app_helpers.rb +13 -0
  444. data/test/test_committer.rb +1 -1
  445. data/test/test_file_view.rb +102 -0
  446. data/test/test_git_access.rb +3 -2
  447. data/test/test_markup.rb +45 -12
  448. data/test/test_page.rb +65 -1
  449. data/test/test_page_revert.rb +14 -2
  450. data/test/test_pages_view.rb +37 -0
  451. data/test/test_unicode.rb +110 -0
  452. data/test/test_wiki.rb +51 -4
  453. metadata +658 -239
  454. data/lib/gollum/frontend/public/gollum/javascript/jquery.js +0 -7179
@@ -0,0 +1,61 @@
1
+ /* vim: set sw=4 ts=4 et tw=78: */
2
+ /* ***** BEGIN LICENSE BLOCK *****
3
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
+ *
5
+ * The contents of this file are subject to the Mozilla Public License Version
6
+ * 1.1 (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ * http://www.mozilla.org/MPL/
9
+ *
10
+ * Software distributed under the License is distributed on an "AS IS" basis,
11
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
+ * for the specific language governing rights and limitations under the
13
+ * License.
14
+ *
15
+ * The Original Code is the Narcissus JavaScript engine.
16
+ *
17
+ * The Initial Developer of the Original Code is
18
+ * Brendan Eich <brendan@mozilla.org>.
19
+ * Portions created by the Initial Developer are Copyright (C) 2004
20
+ * the Initial Developer. All Rights Reserved.
21
+ *
22
+ * Contributor(s):
23
+ * Tom Austin <taustin@ucsc.edu>
24
+ * Brendan Eich <brendan@mozilla.org>
25
+ * Shu-Yu Guo <shu@rfrn.org>
26
+ * Dave Herman <dherman@mozilla.com>
27
+ * Dimitris Vardoulakis <dimvar@ccs.neu.edu>
28
+ * Patrick Walton <pcwalton@mozilla.com>
29
+ *
30
+ * Alternatively, the contents of this file may be used under the terms of
31
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
32
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33
+ * in which case the provisions of the GPL or the LGPL are applicable instead
34
+ * of those above. If you wish to allow use of your version of this file only
35
+ * under the terms of either the GPL or the LGPL, and not to allow others to
36
+ * use your version of this file under the terms of the MPL, indicate your
37
+ * decision by deleting the provisions above and replace them with the notice
38
+ * and other provisions required by the GPL or the LGPL. If you do not delete
39
+ * the provisions above, a recipient may use your version of this file under
40
+ * the terms of any one of the MPL, the GPL or the LGPL.
41
+ *
42
+ * ***** END LICENSE BLOCK ***** */
43
+
44
+ define(function(require, exports, module) {
45
+
46
+ // Global variables to hide from the interpreter
47
+ exports.hiddenHostGlobals = { Narcissus: true };
48
+
49
+ // Desugar SpiderMonkey language extensions?
50
+ exports.desugarExtensions = false;
51
+
52
+ // Allow HTML comments?
53
+ exports.allowHTMLComments = false;
54
+
55
+ // Allow non-standard Mozilla extensions?
56
+ exports.mozillaMode = true;
57
+
58
+ // Allow experimental paren-free mode?
59
+ exports.parenFreeMode = false;
60
+
61
+ });
@@ -0,0 +1,2072 @@
1
+ /* -*- Mode: JS; tab-width: 4; indent-tabs-mode: nil; -*-
2
+ * vim: set sw=4 ts=4 et tw=78:
3
+ * ***** BEGIN LICENSE BLOCK *****
4
+ *
5
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ * http://www.mozilla.org/MPL/
11
+ *
12
+ * Software distributed under the License is distributed on an "AS IS" basis,
13
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
+ * for the specific language governing rights and limitations under the
15
+ * License.
16
+ *
17
+ * The Original Code is the Narcissus JavaScript engine.
18
+ *
19
+ * The Initial Developer of the Original Code is
20
+ * Brendan Eich <brendan@mozilla.org>.
21
+ * Portions created by the Initial Developer are Copyright (C) 2004
22
+ * the Initial Developer. All Rights Reserved.
23
+ *
24
+ * Contributor(s):
25
+ * Tom Austin <taustin@ucsc.edu>
26
+ * Brendan Eich <brendan@mozilla.org>
27
+ * Shu-Yu Guo <shu@rfrn.org>
28
+ * Dave Herman <dherman@mozilla.com>
29
+ * Dimitris Vardoulakis <dimvar@ccs.neu.edu>
30
+ * Patrick Walton <pcwalton@mozilla.com>
31
+ *
32
+ * Alternatively, the contents of this file may be used under the terms of
33
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
34
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35
+ * in which case the provisions of the GPL or the LGPL are applicable instead
36
+ * of those above. If you wish to allow use of your version of this file only
37
+ * under the terms of either the GPL or the LGPL, and not to allow others to
38
+ * use your version of this file under the terms of the MPL, indicate your
39
+ * decision by deleting the provisions above and replace them with the notice
40
+ * and other provisions required by the GPL or the LGPL. If you do not delete
41
+ * the provisions above, a recipient may use your version of this file under
42
+ * the terms of any one of the MPL, the GPL or the LGPL.
43
+ *
44
+ * ***** END LICENSE BLOCK ***** */
45
+
46
+ /*
47
+ * Narcissus - JS implemented in JS.
48
+ *
49
+ * Parser.
50
+ */
51
+
52
+ define(function(require, exports, module) {
53
+
54
+ var lexer = require('./lexer');
55
+ var definitions = require('./definitions');
56
+ var options = require('./options');
57
+ var Tokenizer = lexer.Tokenizer;
58
+
59
+ var Dict = definitions.Dict;
60
+ var Stack = definitions.Stack;
61
+
62
+ // Set constants in the local scope.
63
+ eval(definitions.consts);
64
+
65
+ /*
66
+ * pushDestructuringVarDecls :: (node, hoisting node) -> void
67
+ *
68
+ * Recursively add all destructured declarations to varDecls.
69
+ */
70
+ function pushDestructuringVarDecls(n, s) {
71
+ for (var i in n) {
72
+ var sub = n[i];
73
+ if (sub.type === IDENTIFIER) {
74
+ s.varDecls.push(sub);
75
+ } else {
76
+ pushDestructuringVarDecls(sub, s);
77
+ }
78
+ }
79
+ }
80
+
81
+ function Parser(tokenizer) {
82
+ tokenizer.parser = this;
83
+ this.t = tokenizer;
84
+ this.x = null;
85
+ this.unexpectedEOF = false;
86
+ options.mozillaMode && (this.mozillaMode = true);
87
+ options.parenFreeMode && (this.parenFreeMode = true);
88
+ }
89
+
90
+ function StaticContext(parentScript, parentBlock, inModule, inFunction, strictMode) {
91
+ this.parentScript = parentScript;
92
+ this.parentBlock = parentBlock || parentScript;
93
+ this.inModule = inModule || false;
94
+ this.inFunction = inFunction || false;
95
+ this.inForLoopInit = false;
96
+ this.topLevel = true;
97
+ this.allLabels = new Stack();
98
+ this.currentLabels = new Stack();
99
+ this.labeledTargets = new Stack();
100
+ this.defaultLoopTarget = null;
101
+ this.defaultTarget = null;
102
+ this.strictMode = strictMode;
103
+ }
104
+
105
+ StaticContext.prototype = {
106
+ // non-destructive update via prototype extension
107
+ update: function(ext) {
108
+ var desc = {};
109
+ for (var key in ext) {
110
+ desc[key] = {
111
+ value: ext[key],
112
+ writable: true,
113
+ enumerable: true,
114
+ configurable: true
115
+ }
116
+ }
117
+ return Object.create(this, desc);
118
+ },
119
+ pushLabel: function(label) {
120
+ return this.update({ currentLabels: this.currentLabels.push(label),
121
+ allLabels: this.allLabels.push(label) });
122
+ },
123
+ pushTarget: function(target) {
124
+ var isDefaultLoopTarget = target.isLoop;
125
+ var isDefaultTarget = isDefaultLoopTarget || target.type === SWITCH;
126
+
127
+ if (this.currentLabels.isEmpty()) {
128
+ if (isDefaultLoopTarget) this.update({ defaultLoopTarget: target });
129
+ if (isDefaultTarget) this.update({ defaultTarget: target });
130
+ return this;
131
+ }
132
+
133
+ target.labels = new Dict();
134
+ this.currentLabels.forEach(function(label) {
135
+ target.labels.set(label, true);
136
+ });
137
+ return this.update({ currentLabels: new Stack(),
138
+ labeledTargets: this.labeledTargets.push(target),
139
+ defaultLoopTarget: isDefaultLoopTarget
140
+ ? target
141
+ : this.defaultLoopTarget,
142
+ defaultTarget: isDefaultTarget
143
+ ? target
144
+ : this.defaultTarget });
145
+ },
146
+ nest: function() {
147
+ return this.topLevel ? this.update({ topLevel: false }) : this;
148
+ },
149
+ canImport: function() {
150
+ return this.topLevel && !this.inFunction;
151
+ },
152
+ canExport: function() {
153
+ return this.inModule && this.topLevel && !this.inFunction;
154
+ },
155
+ banWith: function() {
156
+ return this.strictMode || this.inModule;
157
+ },
158
+ modulesAllowed: function() {
159
+ return this.topLevel && !this.inFunction;
160
+ }
161
+ };
162
+
163
+ var Pp = Parser.prototype;
164
+
165
+ Pp.mozillaMode = false;
166
+
167
+ Pp.parenFreeMode = false;
168
+
169
+ Pp.withContext = function(x, f) {
170
+ var x0 = this.x;
171
+ this.x = x;
172
+ var result = f.call(this);
173
+ // NB: we don't bother with finally, since exceptions trash the parser
174
+ this.x = x0;
175
+ return result;
176
+ };
177
+
178
+ Pp.newNode = function newNode(opts) {
179
+ return new Node(this.t, opts);
180
+ };
181
+
182
+ Pp.fail = function fail(msg) {
183
+ throw this.t.newSyntaxError(msg);
184
+ };
185
+
186
+ Pp.match = function match(tt, scanOperand, keywordIsName) {
187
+ return this.t.match(tt, scanOperand, keywordIsName);
188
+ };
189
+
190
+ Pp.mustMatch = function mustMatch(tt, keywordIsName) {
191
+ return this.t.mustMatch(tt, keywordIsName);
192
+ };
193
+
194
+ Pp.peek = function peek(scanOperand) {
195
+ return this.t.peek(scanOperand);
196
+ };
197
+
198
+ Pp.peekOnSameLine = function peekOnSameLine(scanOperand) {
199
+ return this.t.peekOnSameLine(scanOperand);
200
+ };
201
+
202
+ Pp.done = function done() {
203
+ return this.t.done;
204
+ };
205
+
206
+ /*
207
+ * Script :: (boolean, boolean, boolean) -> node
208
+ *
209
+ * Parses the toplevel and module/function bodies.
210
+ */
211
+ Pp.Script = function Script(inModule, inFunction, expectEnd) {
212
+ var node = this.newNode(scriptInit());
213
+ var x2 = new StaticContext(node, node, inModule, inFunction);
214
+ this.withContext(x2, function() {
215
+ this.Statements(node, true);
216
+ });
217
+ if (expectEnd && !this.done())
218
+ this.fail("expected end of input");
219
+ return node;
220
+ };
221
+
222
+ /*
223
+ * Pragma :: (expression statement node) -> boolean
224
+ *
225
+ * Checks whether a node is a pragma and annotates it.
226
+ */
227
+ function Pragma(n) {
228
+ if (n.type === SEMICOLON) {
229
+ var e = n.expression;
230
+ if (e.type === STRING && e.value === "use strict") {
231
+ n.pragma = "strict";
232
+ return true;
233
+ }
234
+ }
235
+ return false;
236
+ }
237
+
238
+ /*
239
+ * Node :: (tokenizer, optional init object) -> node
240
+ */
241
+ function Node(t, init) {
242
+ var token = t.token;
243
+ if (token) {
244
+ // If init.type exists it will override token.type.
245
+ this.type = token.type;
246
+ this.value = token.value;
247
+ this.lineno = token.lineno;
248
+
249
+ // Start and end are file positions for error handling.
250
+ this.start = token.start;
251
+ this.end = token.end;
252
+ } else {
253
+ this.lineno = t.lineno;
254
+ }
255
+
256
+ this.filename = t.filename;
257
+ this.children = [];
258
+
259
+ for (var prop in init)
260
+ this[prop] = init[prop];
261
+ }
262
+
263
+ /*
264
+ * SyntheticNode :: (optional init object) -> node
265
+ */
266
+ function SyntheticNode(init) {
267
+ this.children = [];
268
+ for (var prop in init)
269
+ this[prop] = init[prop];
270
+ this.synthetic = true;
271
+ }
272
+
273
+ var Np = Node.prototype = SyntheticNode.prototype = {};
274
+ Np.constructor = Node;
275
+
276
+ var TO_SOURCE_SKIP = {
277
+ type: true,
278
+ value: true,
279
+ lineno: true,
280
+ start: true,
281
+ end: true,
282
+ tokenizer: true,
283
+ assignOp: true
284
+ };
285
+ function unevalableConst(code) {
286
+ var token = definitions.tokens[code];
287
+ var constName = definitions.opTypeNames.hasOwnProperty(token)
288
+ ? definitions.opTypeNames[token]
289
+ : token in definitions.keywords
290
+ ? token.toUpperCase()
291
+ : token;
292
+ return { toSource: function() { return constName } };
293
+ }
294
+ Np.toSource = function toSource() {
295
+ var mock = {};
296
+ var self = this;
297
+ mock.type = unevalableConst(this.type);
298
+ // avoid infinite recursion in case of back-links
299
+ if (this.generatingSource)
300
+ return mock.toSource();
301
+ this.generatingSource = true;
302
+ if ("value" in this)
303
+ mock.value = this.value;
304
+ if ("lineno" in this)
305
+ mock.lineno = this.lineno;
306
+ if ("start" in this)
307
+ mock.start = this.start;
308
+ if ("end" in this)
309
+ mock.end = this.end;
310
+ if (this.assignOp)
311
+ mock.assignOp = unevalableConst(this.assignOp);
312
+ for (var key in this) {
313
+ if (this.hasOwnProperty(key) && !(key in TO_SOURCE_SKIP))
314
+ mock[key] = this[key];
315
+ }
316
+ try {
317
+ return mock.toSource();
318
+ } finally {
319
+ delete this.generatingSource;
320
+ }
321
+ };
322
+
323
+ // Always use push to add operands to an expression, to update start and end.
324
+ Np.push = function (kid) {
325
+ // kid can be null e.g. [1, , 2].
326
+ if (kid !== null) {
327
+ if (kid.start < this.start)
328
+ this.start = kid.start;
329
+ if (this.end < kid.end)
330
+ this.end = kid.end;
331
+ }
332
+ return this.children.push(kid);
333
+ }
334
+
335
+ Node.indentLevel = 0;
336
+
337
+ function tokenString(tt) {
338
+ var t = definitions.tokens[tt];
339
+ return /^\W/.test(t) ? definitions.opTypeNames[t] : t.toUpperCase();
340
+ }
341
+
342
+ Np.toString = function () {
343
+ var a = [];
344
+ for (var i in this) {
345
+ if (this.hasOwnProperty(i) && i !== 'type' && i !== 'target')
346
+ a.push({id: i, value: this[i]});
347
+ }
348
+ a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; });
349
+ var INDENTATION = " ";
350
+ var n = ++Node.indentLevel;
351
+ var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenString(this.type);
352
+ for (i = 0; i < a.length; i++)
353
+ s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value;
354
+ n = --Node.indentLevel;
355
+ s += "\n" + INDENTATION.repeat(n) + "}";
356
+ return s;
357
+ }
358
+
359
+ Np.synth = function(init) {
360
+ var node = new SyntheticNode(init);
361
+ node.filename = this.filename;
362
+ node.lineno = this.lineno;
363
+ node.start = this.start;
364
+ node.end = this.end;
365
+ return node;
366
+ };
367
+
368
+ /*
369
+ * Helper init objects for common nodes.
370
+ */
371
+
372
+ var LOOP_INIT = { isLoop: true };
373
+
374
+ function blockInit() {
375
+ return { type: BLOCK, varDecls: [] };
376
+ }
377
+
378
+ function scriptInit() {
379
+ return { type: SCRIPT,
380
+ funDecls: [],
381
+ varDecls: [],
382
+ modDefns: new Dict(),
383
+ modAssns: new Dict(),
384
+ modDecls: new Dict(),
385
+ modLoads: new Dict(),
386
+ impDecls: [],
387
+ expDecls: [],
388
+ exports: new Dict(),
389
+ hasEmptyReturn: false,
390
+ hasReturnWithValue: false,
391
+ hasYield: false };
392
+ }
393
+
394
+ definitions.defineGetter(Np, "length",
395
+ function() {
396
+ throw new Error("Node.prototype.length is gone; " +
397
+ "use n.children.length instead");
398
+ });
399
+
400
+ definitions.defineProperty(String.prototype, "repeat",
401
+ function(n) {
402
+ var s = "", t = this + s;
403
+ while (--n >= 0)
404
+ s += t;
405
+ return s;
406
+ }, false, false, true);
407
+
408
+ Pp.MaybeLeftParen = function MaybeLeftParen() {
409
+ if (this.parenFreeMode)
410
+ return this.match(LEFT_PAREN) ? LEFT_PAREN : END;
411
+ return this.mustMatch(LEFT_PAREN).type;
412
+ };
413
+
414
+ Pp.MaybeRightParen = function MaybeRightParen(p) {
415
+ if (p === LEFT_PAREN)
416
+ this.mustMatch(RIGHT_PAREN);
417
+ }
418
+
419
+ /*
420
+ * Statements :: (node[, boolean]) -> void
421
+ *
422
+ * Parses a sequence of Statements.
423
+ */
424
+ Pp.Statements = function Statements(n, topLevel) {
425
+ var prologue = !!topLevel;
426
+ try {
427
+ while (!this.done() && this.peek(true) !== RIGHT_CURLY) {
428
+ var n2 = this.Statement();
429
+ n.push(n2);
430
+ if (prologue && Pragma(n2)) {
431
+ this.x.strictMode = true;
432
+ n.strict = true;
433
+ } else {
434
+ prologue = false;
435
+ }
436
+ }
437
+ } catch (e) {
438
+ try {
439
+ if (this.done())
440
+ this.unexpectedEOF = true;
441
+ } catch(e) {}
442
+ throw e;
443
+ }
444
+ }
445
+
446
+ Pp.Block = function Block() {
447
+ this.mustMatch(LEFT_CURLY);
448
+ var n = this.newNode(blockInit());
449
+ var x2 = this.x.update({ parentBlock: n }).pushTarget(n);
450
+ this.withContext(x2, function() {
451
+ this.Statements(n);
452
+ });
453
+ this.mustMatch(RIGHT_CURLY);
454
+ return n;
455
+ }
456
+
457
+ var DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2;
458
+
459
+ /*
460
+ * Export :: (binding node, boolean) -> Export
461
+ *
462
+ * Static semantic representation of a module export.
463
+ */
464
+ function Export(node, isDefinition) {
465
+ this.node = node; // the AST node declaring this individual export
466
+ this.isDefinition = isDefinition; // is the node an 'export'-annotated definition?
467
+ this.resolved = null; // resolved pointer to the target of this export
468
+ }
469
+
470
+ /*
471
+ * registerExport :: (Dict, EXPORT node) -> void
472
+ */
473
+ function registerExport(exports, decl) {
474
+ function register(name, exp) {
475
+ if (exports.has(name))
476
+ throw new SyntaxError("multiple exports of " + name);
477
+ exports.set(name, exp);
478
+ }
479
+
480
+ switch (decl.type) {
481
+ case MODULE:
482
+ case FUNCTION:
483
+ register(decl.name, new Export(decl, true));
484
+ break;
485
+
486
+ case VAR:
487
+ for (var i = 0; i < decl.children.length; i++)
488
+ register(decl.children[i].name, new Export(decl.children[i], true));
489
+ break;
490
+
491
+ case LET:
492
+ case CONST:
493
+ throw new Error("NYI: " + definitions.tokens[decl.type]);
494
+
495
+ case EXPORT:
496
+ for (var i = 0; i < decl.pathList.length; i++) {
497
+ var path = decl.pathList[i];
498
+ switch (path.type) {
499
+ case OBJECT_INIT:
500
+ for (var j = 0; j < path.children.length; j++) {
501
+ // init :: IDENTIFIER | PROPERTY_INIT
502
+ var init = path.children[j];
503
+ if (init.type === IDENTIFIER)
504
+ register(init.value, new Export(init, false));
505
+ else
506
+ register(init.children[0].value, new Export(init.children[1], false));
507
+ }
508
+ break;
509
+
510
+ case DOT:
511
+ register(path.children[1].value, new Export(path, false));
512
+ break;
513
+
514
+ case IDENTIFIER:
515
+ register(path.value, new Export(path, false));
516
+ break;
517
+
518
+ default:
519
+ throw new Error("unexpected export path: " + definitions.tokens[path.type]);
520
+ }
521
+ }
522
+ break;
523
+
524
+ default:
525
+ throw new Error("unexpected export decl: " + definitions.tokens[exp.type]);
526
+ }
527
+ }
528
+
529
+ /*
530
+ * Module :: (node) -> Module
531
+ *
532
+ * Static semantic representation of a module.
533
+ */
534
+ function Module(node) {
535
+ var exports = node.body.exports;
536
+ var modDefns = node.body.modDefns;
537
+
538
+ var exportedModules = new Dict();
539
+
540
+ exports.forEach(function(name, exp) {
541
+ var node = exp.node;
542
+ if (node.type === MODULE) {
543
+ exportedModules.set(name, node);
544
+ } else if (!exp.isDefinition && node.type === IDENTIFIER && modDefns.has(node.value)) {
545
+ var mod = modDefns.get(node.value);
546
+ exportedModules.set(name, mod);
547
+ }
548
+ });
549
+
550
+ this.node = node;
551
+ this.exports = exports;
552
+ this.exportedModules = exportedModules;
553
+ }
554
+
555
+ /*
556
+ * Statement :: () -> node
557
+ *
558
+ * Parses a Statement.
559
+ */
560
+ Pp.Statement = function Statement() {
561
+ var i, label, n, n2, p, c, ss, tt = this.t.get(true), tt2, x0, x2, x3;
562
+
563
+ var comments = this.t.blockComments;
564
+
565
+ // Cases for statements ending in a right curly return early, avoiding the
566
+ // common semicolon insertion magic after this switch.
567
+ switch (tt) {
568
+ case IMPORT:
569
+ if (!this.x.canImport())
570
+ this.fail("illegal context for import statement");
571
+ n = this.newNode();
572
+ n.pathList = this.ImportPathList();
573
+ this.x.parentScript.impDecls.push(n);
574
+ break;
575
+
576
+ case EXPORT:
577
+ if (!this.x.canExport())
578
+ this.fail("export statement not in module top level");
579
+ switch (this.peek()) {
580
+ case MODULE:
581
+ case FUNCTION:
582
+ case LET:
583
+ case VAR:
584
+ case CONST:
585
+ n = this.Statement();
586
+ n.blockComments = comments;
587
+ n.exported = true;
588
+ this.x.parentScript.expDecls.push(n);
589
+ registerExport(this.x.parentScript.exports, n);
590
+ return n;
591
+ }
592
+ n = this.newNode();
593
+ n.pathList = this.ExportPathList();
594
+ this.x.parentScript.expDecls.push(n);
595
+ registerExport(this.x.parentScript.exports, n);
596
+ break;
597
+
598
+ case FUNCTION:
599
+ // DECLARED_FORM extends funDecls of x, STATEMENT_FORM doesn't.
600
+ return this.FunctionDefinition(true, this.x.topLevel ? DECLARED_FORM : STATEMENT_FORM, comments);
601
+
602
+ case LEFT_CURLY:
603
+ n = this.newNode(blockInit());
604
+ x2 = this.x.update({ parentBlock: n }).pushTarget(n).nest();
605
+ this.withContext(x2, function() {
606
+ this.Statements(n);
607
+ });
608
+ this.mustMatch(RIGHT_CURLY);
609
+ return n;
610
+
611
+ case IF:
612
+ n = this.newNode();
613
+ n.condition = this.HeadExpression();
614
+ x2 = this.x.pushTarget(n).nest();
615
+ this.withContext(x2, function() {
616
+ n.thenPart = this.Statement();
617
+ n.elsePart = this.match(ELSE, true) ? this.Statement() : null;
618
+ });
619
+ return n;
620
+
621
+ case SWITCH:
622
+ // This allows CASEs after a DEFAULT, which is in the standard.
623
+ n = this.newNode({ cases: [], defaultIndex: -1 });
624
+ n.discriminant = this.HeadExpression();
625
+ x2 = this.x.pushTarget(n).nest();
626
+ this.withContext(x2, function() {
627
+ this.mustMatch(LEFT_CURLY);
628
+ while ((tt = this.t.get()) !== RIGHT_CURLY) {
629
+ switch (tt) {
630
+ case DEFAULT:
631
+ if (n.defaultIndex >= 0)
632
+ this.fail("More than one switch default");
633
+ // FALL THROUGH
634
+ case CASE:
635
+ n2 = this.newNode();
636
+ if (tt === DEFAULT)
637
+ n.defaultIndex = n.cases.length;
638
+ else
639
+ n2.caseLabel = this.Expression(COLON);
640
+ break;
641
+
642
+ default:
643
+ this.fail("Invalid switch case");
644
+ }
645
+ this.mustMatch(COLON);
646
+ n2.statements = this.newNode(blockInit());
647
+ while ((tt=this.peek(true)) !== CASE && tt !== DEFAULT &&
648
+ tt !== RIGHT_CURLY)
649
+ n2.statements.push(this.Statement());
650
+ n.cases.push(n2);
651
+ }
652
+ });
653
+ return n;
654
+
655
+ case FOR:
656
+ n = this.newNode(LOOP_INIT);
657
+ n.blockComments = comments;
658
+ if (this.match(IDENTIFIER)) {
659
+ if (this.t.token.value === "each")
660
+ n.isEach = true;
661
+ else
662
+ this.t.unget();
663
+ }
664
+ if (!this.parenFreeMode)
665
+ this.mustMatch(LEFT_PAREN);
666
+ x2 = this.x.pushTarget(n).nest();
667
+ x3 = this.x.update({ inForLoopInit: true });
668
+ n2 = null;
669
+ if ((tt = this.peek(true)) !== SEMICOLON) {
670
+ this.withContext(x3, function() {
671
+ if (tt === VAR || tt === CONST) {
672
+ this.t.get();
673
+ n2 = this.Variables();
674
+ } else if (tt === LET) {
675
+ this.t.get();
676
+ if (this.peek() === LEFT_PAREN) {
677
+ n2 = this.LetBlock(false);
678
+ } else {
679
+ // Let in for head, we need to add an implicit block
680
+ // around the rest of the for.
681
+ this.x.parentBlock = n;
682
+ n.varDecls = [];
683
+ n2 = this.Variables();
684
+ }
685
+ } else {
686
+ n2 = this.Expression();
687
+ }
688
+ });
689
+ }
690
+ if (n2 && this.match(IN)) {
691
+ n.type = FOR_IN;
692
+ this.withContext(x3, function() {
693
+ n.object = this.Expression();
694
+ if (n2.type === VAR || n2.type === LET) {
695
+ c = n2.children;
696
+
697
+ // Destructuring turns one decl into multiples, so either
698
+ // there must be only one destructuring or only one
699
+ // decl.
700
+ if (c.length !== 1 && n2.destructurings.length !== 1) {
701
+ // FIXME: this.fail ?
702
+ throw new SyntaxError("Invalid for..in left-hand side",
703
+ this.filename, n2.lineno);
704
+ }
705
+ if (n2.destructurings.length > 0) {
706
+ n.iterator = n2.destructurings[0];
707
+ } else {
708
+ n.iterator = c[0];
709
+ }
710
+ n.varDecl = n2;
711
+ } else {
712
+ if (n2.type === ARRAY_INIT || n2.type === OBJECT_INIT) {
713
+ n2.destructuredNames = this.checkDestructuring(n2);
714
+ }
715
+ n.iterator = n2;
716
+ }
717
+ });
718
+ } else {
719
+ x3.inForLoopInit = false;
720
+ n.setup = n2;
721
+ this.mustMatch(SEMICOLON);
722
+ if (n.isEach)
723
+ this.fail("Invalid for each..in loop");
724
+ this.withContext(x3, function() {
725
+ n.condition = (this.peek(true) === SEMICOLON)
726
+ ? null
727
+ : this.Expression();
728
+ this.mustMatch(SEMICOLON);
729
+ tt2 = this.peek(true);
730
+ n.update = (this.parenFreeMode
731
+ ? tt2 === LEFT_CURLY || definitions.isStatementStartCode[tt2]
732
+ : tt2 === RIGHT_PAREN)
733
+ ? null
734
+ : this.Expression();
735
+ });
736
+ }
737
+ if (!this.parenFreeMode)
738
+ this.mustMatch(RIGHT_PAREN);
739
+ this.withContext(x2, function() {
740
+ n.body = this.Statement();
741
+ });
742
+ return n;
743
+
744
+ case WHILE:
745
+ n = this.newNode({ isLoop: true });
746
+ n.blockComments = comments;
747
+ n.condition = this.HeadExpression();
748
+ x2 = this.x.pushTarget(n).nest();
749
+ this.withContext(x2, function() {
750
+ n.body = this.Statement();
751
+ });
752
+ return n;
753
+
754
+ case DO:
755
+ n = this.newNode({ isLoop: true });
756
+ n.blockComments = comments;
757
+ x2 = this.x.pushTarget(n).next();
758
+ this.withContext(x2, function() {
759
+ n.body = this.Statement();
760
+ });
761
+ this.mustMatch(WHILE);
762
+ n.condition = this.HeadExpression();
763
+ // <script language="JavaScript"> (without version hints) may need
764
+ // automatic semicolon insertion without a newline after do-while.
765
+ // See http://bugzilla.mozilla.org/show_bug.cgi?id=238945.
766
+ this.match(SEMICOLON);
767
+ return n;
768
+
769
+ case BREAK:
770
+ case CONTINUE:
771
+ n = this.newNode();
772
+ n.blockComments = comments;
773
+
774
+ // handle the |foo: break foo;| corner case
775
+ x2 = this.x.pushTarget(n);
776
+
777
+ if (this.peekOnSameLine() === IDENTIFIER) {
778
+ this.t.get();
779
+ n.label = this.t.token.value;
780
+ }
781
+
782
+ if (n.label) {
783
+ n.target = x2.labeledTargets.find(function(target) {
784
+ return target.labels.has(n.label)
785
+ });
786
+ } else if (tt === CONTINUE) {
787
+ n.target = x2.defaultLoopTarget;
788
+ } else {
789
+ n.target = x2.defaultTarget;
790
+ }
791
+
792
+ if (!n.target)
793
+ this.fail("Invalid " + ((tt === BREAK) ? "break" : "continue"));
794
+ if (!n.target.isLoop && tt === CONTINUE)
795
+ this.fail("Invalid continue");
796
+
797
+ break;
798
+
799
+ case TRY:
800
+ n = this.newNode({ catchClauses: [] });
801
+ n.blockComments = comments;
802
+ n.tryBlock = this.Block();
803
+ while (this.match(CATCH)) {
804
+ n2 = this.newNode();
805
+ p = this.MaybeLeftParen();
806
+ switch (this.t.get()) {
807
+ case LEFT_BRACKET:
808
+ case LEFT_CURLY:
809
+ // Destructured catch identifiers.
810
+ this.t.unget();
811
+ n2.varName = this.DestructuringExpression(true);
812
+ break;
813
+ case IDENTIFIER:
814
+ n2.varName = this.t.token.value;
815
+ break;
816
+ default:
817
+ this.fail("missing identifier in catch");
818
+ break;
819
+ }
820
+ if (this.match(IF)) {
821
+ if (!this.mozillaMode)
822
+ this.fail("Illegal catch guard");
823
+ if (n.catchClauses.length && !n.catchClauses.top().guard)
824
+ this.fail("Guarded catch after unguarded");
825
+ n2.guard = this.Expression();
826
+ }
827
+ this.MaybeRightParen(p);
828
+ n2.block = this.Block();
829
+ n.catchClauses.push(n2);
830
+ }
831
+ if (this.match(FINALLY))
832
+ n.finallyBlock = this.Block();
833
+ if (!n.catchClauses.length && !n.finallyBlock)
834
+ this.fail("Invalid try statement");
835
+ return n;
836
+
837
+ case CATCH:
838
+ case FINALLY:
839
+ this.fail(definitions.tokens[tt] + " without preceding try");
840
+
841
+ case THROW:
842
+ n = this.newNode();
843
+ n.exception = this.Expression();
844
+ break;
845
+
846
+ case RETURN:
847
+ n = this.ReturnOrYield();
848
+ break;
849
+
850
+ case WITH:
851
+ if (this.x.banWith())
852
+ this.fail("with statements not allowed in strict code or modules");
853
+ n = this.newNode();
854
+ n.blockComments = comments;
855
+ n.object = this.HeadExpression();
856
+ x2 = this.x.pushTarget(n).next();
857
+ this.withContext(x2, function() {
858
+ n.body = this.Statement();
859
+ });
860
+ return n;
861
+
862
+ case VAR:
863
+ case CONST:
864
+ n = this.Variables();
865
+ break;
866
+
867
+ case LET:
868
+ if (this.peek() === LEFT_PAREN) {
869
+ n = this.LetBlock(true);
870
+ return n;
871
+ }
872
+ n = this.Variables();
873
+ break;
874
+
875
+ case DEBUGGER:
876
+ n = this.newNode();
877
+ break;
878
+
879
+ case NEWLINE:
880
+ case SEMICOLON:
881
+ n = this.newNode({ type: SEMICOLON });
882
+ n.blockComments = comments;
883
+ n.expression = null;
884
+ return n;
885
+
886
+ case IDENTIFIER:
887
+ case USE:
888
+ case MODULE:
889
+ switch (this.t.token.value) {
890
+ case "use":
891
+ if (!isPragmaToken(this.peekOnSameLine())) {
892
+ this.t.unget();
893
+ break;
894
+ }
895
+ return this.newNode({ type: USE, params: this.Pragmas() });
896
+
897
+ case "module":
898
+ if (!this.x.modulesAllowed())
899
+ this.fail("module declaration not at top level");
900
+ this.x.parentScript.hasModules = true;
901
+ tt = this.peekOnSameLine();
902
+ if (tt !== IDENTIFIER && tt !== LEFT_CURLY) {
903
+ this.t.unget();
904
+ break;
905
+ }
906
+ n = this.newNode({ type: MODULE });
907
+ n.blockComments = comments;
908
+ this.mustMatch(IDENTIFIER);
909
+ label = this.t.token.value;
910
+
911
+ if (this.match(LEFT_CURLY)) {
912
+ n.name = label;
913
+ n.body = this.Script(true, false);
914
+ n.module = new Module(n);
915
+ this.mustMatch(RIGHT_CURLY);
916
+ this.x.parentScript.modDefns.set(n.name, n);
917
+ return n;
918
+ }
919
+
920
+ this.t.unget();
921
+ this.ModuleVariables(n);
922
+ return n;
923
+
924
+ default:
925
+ tt = this.peek();
926
+ // Labeled statement.
927
+ if (tt === COLON) {
928
+ label = this.t.token.value;
929
+ if (this.x.allLabels.has(label))
930
+ this.fail("Duplicate label: " + label);
931
+ this.t.get();
932
+ n = this.newNode({ type: LABEL, label: label });
933
+ n.blockComments = comments;
934
+ x2 = this.x.pushLabel(label).nest();
935
+ this.withContext(x2, function() {
936
+ n.statement = this.Statement();
937
+ });
938
+ n.target = (n.statement.type === LABEL) ? n.statement.target : n.statement;
939
+ return n;
940
+ }
941
+ // FALL THROUGH
942
+ }
943
+ // FALL THROUGH
944
+
945
+ default:
946
+ // Expression statement.
947
+ // We unget the current token to parse the expression as a whole.
948
+ n = this.newNode({ type: SEMICOLON });
949
+ this.t.unget();
950
+ n.blockComments = comments;
951
+ n.expression = this.Expression();
952
+ n.end = n.expression.end;
953
+ break;
954
+ }
955
+
956
+ n.blockComments = comments;
957
+ this.MagicalSemicolon();
958
+ return n;
959
+ }
960
+
961
+ /*
962
+ * isPragmaToken :: (number) -> boolean
963
+ */
964
+ function isPragmaToken(tt) {
965
+ switch (tt) {
966
+ case IDENTIFIER:
967
+ case STRING:
968
+ case NUMBER:
969
+ case NULL:
970
+ case TRUE:
971
+ case FALSE:
972
+ return true;
973
+ }
974
+ return false;
975
+ }
976
+
977
+ /*
978
+ * Pragmas :: () -> Array[Array[token]]
979
+ */
980
+ Pp.Pragmas = function Pragmas() {
981
+ var pragmas = [];
982
+ do {
983
+ pragmas.push(this.Pragma());
984
+ } while (this.match(COMMA));
985
+ this.MagicalSemicolon();
986
+ return pragmas;
987
+ }
988
+
989
+ /*
990
+ * Pragmas :: () -> Array[token]
991
+ */
992
+ Pp.Pragma = function Pragma() {
993
+ var items = [];
994
+ var tt;
995
+ do {
996
+ tt = this.t.get(true);
997
+ items.push(this.t.token);
998
+ } while (isPragmaToken(this.peek()));
999
+ return items;
1000
+ }
1001
+
1002
+ /*
1003
+ * MagicalSemicolon :: () -> void
1004
+ */
1005
+ Pp.MagicalSemicolon = function MagicalSemicolon() {
1006
+ var tt;
1007
+ if (this.t.lineno === this.t.token.lineno) {
1008
+ tt = this.peekOnSameLine();
1009
+ if (tt !== END && tt !== NEWLINE && tt !== SEMICOLON && tt !== RIGHT_CURLY)
1010
+ this.fail("missing ; before statement");
1011
+ }
1012
+ this.match(SEMICOLON);
1013
+ }
1014
+
1015
+ /*
1016
+ * ReturnOrYield :: () -> (RETURN | YIELD) node
1017
+ */
1018
+ Pp.ReturnOrYield = function ReturnOrYield() {
1019
+ var n, b, tt = this.t.token.type, tt2;
1020
+
1021
+ var parentScript = this.x.parentScript;
1022
+
1023
+ if (tt === RETURN) {
1024
+ if (!this.x.inFunction)
1025
+ this.fail("Return not in function");
1026
+ } else /* if (tt === YIELD) */ {
1027
+ if (!this.x.inFunction)
1028
+ this.fail("Yield not in function");
1029
+ parentScript.hasYield = true;
1030
+ }
1031
+ n = this.newNode({ value: undefined });
1032
+
1033
+ tt2 = (tt === RETURN) ? this.peekOnSameLine(true) : this.peek(true);
1034
+ if (tt2 !== END && tt2 !== NEWLINE &&
1035
+ tt2 !== SEMICOLON && tt2 !== RIGHT_CURLY
1036
+ && (tt !== YIELD ||
1037
+ (tt2 !== tt && tt2 !== RIGHT_BRACKET && tt2 !== RIGHT_PAREN &&
1038
+ tt2 !== COLON && tt2 !== COMMA))) {
1039
+ if (tt === RETURN) {
1040
+ n.value = this.Expression();
1041
+ parentScript.hasReturnWithValue = true;
1042
+ } else {
1043
+ n.value = this.AssignExpression();
1044
+ }
1045
+ } else if (tt === RETURN) {
1046
+ parentScript.hasEmptyReturn = true;
1047
+ }
1048
+
1049
+ return n;
1050
+ }
1051
+
1052
+ /*
1053
+ * ModuleExpression :: () -> (STRING | IDENTIFIER | DOT) node
1054
+ */
1055
+ Pp.ModuleExpression = function ModuleExpression() {
1056
+ return this.match(STRING) ? this.newNode() : this.QualifiedPath();
1057
+ }
1058
+
1059
+ /*
1060
+ * ImportPathList :: () -> Array[DOT node]
1061
+ */
1062
+ Pp.ImportPathList = function ImportPathList() {
1063
+ var a = [];
1064
+ do {
1065
+ a.push(this.ImportPath());
1066
+ } while (this.match(COMMA));
1067
+ return a;
1068
+ }
1069
+
1070
+ /*
1071
+ * ImportPath :: () -> DOT node
1072
+ */
1073
+ Pp.ImportPath = function ImportPath() {
1074
+ var n = this.QualifiedPath();
1075
+ if (!this.match(DOT)) {
1076
+ if (n.type === IDENTIFIER)
1077
+ this.fail("cannot import local variable");
1078
+ return n;
1079
+ }
1080
+
1081
+ var n2 = this.newNode();
1082
+ n2.push(n);
1083
+ n2.push(this.ImportSpecifierSet());
1084
+ return n2;
1085
+ }
1086
+
1087
+ /*
1088
+ * ExplicitSpecifierSet :: (() -> node) -> OBJECT_INIT node
1089
+ */
1090
+ Pp.ExplicitSpecifierSet = function ExplicitSpecifierSet(SpecifierRHS) {
1091
+ var n, n2, id, tt;
1092
+
1093
+ n = this.newNode({ type: OBJECT_INIT });
1094
+ this.mustMatch(LEFT_CURLY);
1095
+
1096
+ if (!this.match(RIGHT_CURLY)) {
1097
+ do {
1098
+ id = this.Identifier();
1099
+ if (this.match(COLON)) {
1100
+ n2 = this.newNode({ type: PROPERTY_INIT });
1101
+ n2.push(id);
1102
+ n2.push(SpecifierRHS());
1103
+ n.push(n2);
1104
+ } else {
1105
+ n.push(id);
1106
+ }
1107
+ } while (!this.match(RIGHT_CURLY) && this.mustMatch(COMMA));
1108
+ }
1109
+
1110
+ return n;
1111
+ }
1112
+
1113
+ /*
1114
+ * ImportSpecifierSet :: () -> (IDENTIFIER | OBJECT_INIT) node
1115
+ */
1116
+ Pp.ImportSpecifierSet = function ImportSpecifierSet() {
1117
+ var self = this;
1118
+ return this.match(MUL)
1119
+ ? this.newNode({ type: IDENTIFIER, name: "*" })
1120
+ : ExplicitSpecifierSet(function() { return self.Identifier() });
1121
+ }
1122
+
1123
+ /*
1124
+ * Identifier :: () -> IDENTIFIER node
1125
+ */
1126
+ Pp.Identifier = function Identifier() {
1127
+ this.mustMatch(IDENTIFIER);
1128
+ return this.newNode({ type: IDENTIFIER });
1129
+ }
1130
+
1131
+ /*
1132
+ * IdentifierName :: () -> IDENTIFIER node
1133
+ */
1134
+ Pp.IdentifierName = function IdentifierName() {
1135
+ this.mustMatch(IDENTIFIER, true);
1136
+ return this.newNode({ type: IDENTIFIER });
1137
+ }
1138
+
1139
+ /*
1140
+ * QualifiedPath :: () -> (IDENTIFIER | DOT) node
1141
+ */
1142
+ Pp.QualifiedPath = function QualifiedPath() {
1143
+ var n, n2;
1144
+
1145
+ n = this.Identifier();
1146
+
1147
+ while (this.match(DOT)) {
1148
+ if (this.peek() !== IDENTIFIER) {
1149
+ // Unget the '.' token, which isn't part of the QualifiedPath.
1150
+ this.t.unget();
1151
+ break;
1152
+ }
1153
+ n2 = this.newNode();
1154
+ n2.push(n);
1155
+ n2.push(this.Identifier());
1156
+ n = n2;
1157
+ }
1158
+
1159
+ return n;
1160
+ }
1161
+
1162
+ /*
1163
+ * ExportPath :: () -> (IDENTIFIER | DOT | OBJECT_INIT) node
1164
+ */
1165
+ Pp.ExportPath = function ExportPath() {
1166
+ var self = this;
1167
+ if (this.peek() === LEFT_CURLY)
1168
+ return this.ExplicitSpecifierSet(function() { return self.QualifiedPath() });
1169
+ return this.QualifiedPath();
1170
+ }
1171
+
1172
+ /*
1173
+ * ExportPathList :: () -> Array[(IDENTIFIER | DOT | OBJECT_INIT) node]
1174
+ */
1175
+ Pp.ExportPathList = function ExportPathList() {
1176
+ var a = [];
1177
+ do {
1178
+ a.push(this.ExportPath());
1179
+ } while (this.match(COMMA));
1180
+ return a;
1181
+ }
1182
+
1183
+ /*
1184
+ * FunctionDefinition :: (boolean,
1185
+ * DECLARED_FORM or EXPRESSED_FORM or STATEMENT_FORM,
1186
+ * [string] or null or undefined)
1187
+ * -> node
1188
+ */
1189
+ Pp.FunctionDefinition = function FunctionDefinition(requireName, functionForm, comments) {
1190
+ var tt;
1191
+ var f = this.newNode({ params: [], paramComments: [] });
1192
+ if (typeof comments === "undefined")
1193
+ comments = null;
1194
+ f.blockComments = comments;
1195
+ if (f.type !== FUNCTION)
1196
+ f.type = (f.value === "get") ? GETTER : SETTER;
1197
+ if (this.match(MUL))
1198
+ f.isExplicitGenerator = true;
1199
+ if (this.match(IDENTIFIER, false, true))
1200
+ f.name = this.t.token.value;
1201
+ else if (requireName)
1202
+ this.fail("missing function identifier");
1203
+
1204
+ var inModule = this.x.inModule;
1205
+ x2 = new StaticContext(null, null, inModule, true, this.x.strictMode);
1206
+ this.withContext(x2, function() {
1207
+ this.mustMatch(LEFT_PAREN);
1208
+ if (!this.match(RIGHT_PAREN)) {
1209
+ do {
1210
+ tt = this.t.get();
1211
+ f.paramComments.push(this.t.lastBlockComment());
1212
+ switch (tt) {
1213
+ case LEFT_BRACKET:
1214
+ case LEFT_CURLY:
1215
+ // Destructured formal parameters.
1216
+ this.t.unget();
1217
+ f.params.push(this.DestructuringExpression());
1218
+ break;
1219
+ case IDENTIFIER:
1220
+ f.params.push(this.t.token.value);
1221
+ break;
1222
+ default:
1223
+ this.fail("missing formal parameter");
1224
+ }
1225
+ } while (this.match(COMMA));
1226
+ this.mustMatch(RIGHT_PAREN);
1227
+ }
1228
+
1229
+ // Do we have an expression closure or a normal body?
1230
+ tt = this.t.get(true);
1231
+ if (tt !== LEFT_CURLY)
1232
+ this.t.unget();
1233
+
1234
+ if (tt !== LEFT_CURLY) {
1235
+ f.body = this.AssignExpression();
1236
+ } else {
1237
+ f.body = this.Script(inModule, true);
1238
+ }
1239
+ });
1240
+
1241
+ if (tt === LEFT_CURLY)
1242
+ this.mustMatch(RIGHT_CURLY);
1243
+
1244
+ f.end = this.t.token.end;
1245
+ f.functionForm = functionForm;
1246
+ if (functionForm === DECLARED_FORM)
1247
+ this.x.parentScript.funDecls.push(f);
1248
+
1249
+ if (this.x.inModule && !f.isExplicitGenerator && f.body.hasYield)
1250
+ this.fail("yield in non-generator function");
1251
+
1252
+ if (f.isExplicitGenerator || f.body.hasYield)
1253
+ f.body = this.newNode({ type: GENERATOR, body: f.body });
1254
+
1255
+ return f;
1256
+ }
1257
+
1258
+ /*
1259
+ * ModuleVariables :: (MODULE node) -> void
1260
+ *
1261
+ * Parses a comma-separated list of module declarations (and maybe
1262
+ * initializations).
1263
+ */
1264
+ Pp.ModuleVariables = function ModuleVariables(n) {
1265
+ var n1, n2;
1266
+ do {
1267
+ n1 = this.Identifier();
1268
+ if (this.match(ASSIGN)) {
1269
+ n2 = this.ModuleExpression();
1270
+ n1.initializer = n2;
1271
+ if (n2.type === STRING)
1272
+ this.x.parentScript.modLoads.set(n1.value, n2.value);
1273
+ else
1274
+ this.x.parentScript.modAssns.set(n1.value, n1);
1275
+ }
1276
+ n.push(n1);
1277
+ } while (this.match(COMMA));
1278
+ }
1279
+
1280
+ /*
1281
+ * Variables :: () -> node
1282
+ *
1283
+ * Parses a comma-separated list of var declarations (and maybe
1284
+ * initializations).
1285
+ */
1286
+ Pp.Variables = function Variables(letBlock) {
1287
+ var n, n2, ss, i, s, tt;
1288
+
1289
+ tt = this.t.token.type;
1290
+ switch (tt) {
1291
+ case VAR:
1292
+ case CONST:
1293
+ s = this.x.parentScript;
1294
+ break;
1295
+ case LET:
1296
+ s = this.x.parentBlock;
1297
+ break;
1298
+ case LEFT_PAREN:
1299
+ tt = LET;
1300
+ s = letBlock;
1301
+ break;
1302
+ }
1303
+
1304
+ n = this.newNode({ type: tt, destructurings: [] });
1305
+
1306
+ do {
1307
+ tt = this.t.get();
1308
+ if (tt === LEFT_BRACKET || tt === LEFT_CURLY) {
1309
+ // Need to unget to parse the full destructured expression.
1310
+ this.t.unget();
1311
+
1312
+ var dexp = this.DestructuringExpression(true);
1313
+
1314
+ n2 = this.newNode({ type: IDENTIFIER,
1315
+ name: dexp,
1316
+ readOnly: n.type === CONST });
1317
+ n.push(n2);
1318
+ pushDestructuringVarDecls(n2.name.destructuredNames, s);
1319
+ n.destructurings.push({ exp: dexp, decl: n2 });
1320
+
1321
+ if (this.x.inForLoopInit && this.peek() === IN) {
1322
+ continue;
1323
+ }
1324
+
1325
+ this.mustMatch(ASSIGN);
1326
+ if (this.t.token.assignOp)
1327
+ this.fail("Invalid variable initialization");
1328
+
1329
+ n2.blockComment = this.t.lastBlockComment();
1330
+ n2.initializer = this.AssignExpression();
1331
+
1332
+ continue;
1333
+ }
1334
+
1335
+ if (tt !== IDENTIFIER)
1336
+ this.fail("missing variable name");
1337
+
1338
+ n2 = this.newNode({ type: IDENTIFIER,
1339
+ name: this.t.token.value,
1340
+ readOnly: n.type === CONST });
1341
+ n.push(n2);
1342
+ s.varDecls.push(n2);
1343
+
1344
+ if (this.match(ASSIGN)) {
1345
+ var comment = this.t.lastBlockComment();
1346
+ if (this.t.token.assignOp)
1347
+ this.fail("Invalid variable initialization");
1348
+
1349
+ n2.initializer = this.AssignExpression();
1350
+ } else {
1351
+ var comment = this.t.lastBlockComment();
1352
+ }
1353
+ n2.blockComment = comment;
1354
+ } while (this.match(COMMA));
1355
+
1356
+ return n;
1357
+ }
1358
+
1359
+ /*
1360
+ * LetBlock :: (boolean) -> node
1361
+ *
1362
+ * Does not handle let inside of for loop init.
1363
+ */
1364
+ Pp.LetBlock = function LetBlock(isStatement) {
1365
+ var n, n2;
1366
+
1367
+ // t.token.type must be LET
1368
+ n = this.newNode({ type: LET_BLOCK, varDecls: [] });
1369
+ this.mustMatch(LEFT_PAREN);
1370
+ n.variables = this.Variables(n);
1371
+ this.mustMatch(RIGHT_PAREN);
1372
+
1373
+ if (isStatement && this.peek() !== LEFT_CURLY) {
1374
+ /*
1375
+ * If this is really an expression in let statement guise, then we
1376
+ * need to wrap the LET_BLOCK node in a SEMICOLON node so that we pop
1377
+ * the return value of the expression.
1378
+ */
1379
+ n2 = this.newNode({ type: SEMICOLON, expression: n });
1380
+ isStatement = false;
1381
+ }
1382
+
1383
+ if (isStatement)
1384
+ n.block = this.Block();
1385
+ else
1386
+ n.expression = this.AssignExpression();
1387
+
1388
+ return n;
1389
+ }
1390
+
1391
+ Pp.checkDestructuring = function checkDestructuring(n, simpleNamesOnly) {
1392
+ if (n.type === ARRAY_COMP)
1393
+ this.fail("Invalid array comprehension left-hand side");
1394
+ if (n.type !== ARRAY_INIT && n.type !== OBJECT_INIT)
1395
+ return;
1396
+
1397
+ var lhss = {};
1398
+ var nn, n2, idx, sub, cc, c = n.children;
1399
+ for (var i = 0, j = c.length; i < j; i++) {
1400
+ if (!(nn = c[i]))
1401
+ continue;
1402
+ if (nn.type === PROPERTY_INIT) {
1403
+ cc = nn.children;
1404
+ sub = cc[1];
1405
+ idx = cc[0].value;
1406
+ } else if (n.type === OBJECT_INIT) {
1407
+ // Do we have destructuring shorthand {foo, bar}?
1408
+ sub = nn;
1409
+ idx = nn.value;
1410
+ } else {
1411
+ sub = nn;
1412
+ idx = i;
1413
+ }
1414
+
1415
+ if (sub.type === ARRAY_INIT || sub.type === OBJECT_INIT) {
1416
+ lhss[idx] = this.checkDestructuring(sub, simpleNamesOnly);
1417
+ } else {
1418
+ if (simpleNamesOnly && sub.type !== IDENTIFIER) {
1419
+ // In declarations, lhs must be simple names
1420
+ this.fail("missing name in pattern");
1421
+ }
1422
+
1423
+ lhss[idx] = sub;
1424
+ }
1425
+ }
1426
+
1427
+ return lhss;
1428
+ }
1429
+
1430
+ Pp.DestructuringExpression = function DestructuringExpression(simpleNamesOnly) {
1431
+ var n = this.PrimaryExpression();
1432
+ // Keep the list of lefthand sides for varDecls
1433
+ n.destructuredNames = this.checkDestructuring(n, simpleNamesOnly);
1434
+ return n;
1435
+ }
1436
+
1437
+ Pp.GeneratorExpression = function GeneratorExpression(e) {
1438
+ return this.newNode({ type: GENERATOR,
1439
+ expression: e,
1440
+ tail: this.ComprehensionTail() });
1441
+ }
1442
+
1443
+ Pp.ComprehensionTail = function ComprehensionTail() {
1444
+ var body, n, n2, n3, p;
1445
+
1446
+ // t.token.type must be FOR
1447
+ body = this.newNode({ type: COMP_TAIL });
1448
+
1449
+ do {
1450
+ // Comprehension tails are always for..in loops.
1451
+ n = this.newNode({ type: FOR_IN, isLoop: true });
1452
+ if (this.match(IDENTIFIER)) {
1453
+ // But sometimes they're for each..in.
1454
+ if (this.mozillaMode && this.t.token.value === "each")
1455
+ n.isEach = true;
1456
+ else
1457
+ this.t.unget();
1458
+ }
1459
+ p = this.MaybeLeftParen();
1460
+ switch(this.t.get()) {
1461
+ case LEFT_BRACKET:
1462
+ case LEFT_CURLY:
1463
+ this.t.unget();
1464
+ // Destructured left side of for in comprehension tails.
1465
+ n.iterator = this.DestructuringExpression();
1466
+ break;
1467
+
1468
+ case IDENTIFIER:
1469
+ n.iterator = n3 = this.newNode({ type: IDENTIFIER });
1470
+ n3.name = n3.value;
1471
+ n.varDecl = n2 = this.newNode({ type: VAR });
1472
+ n2.push(n3);
1473
+ this.x.parentScript.varDecls.push(n3);
1474
+ // Don't add to varDecls since the semantics of comprehensions is
1475
+ // such that the variables are in their own function when
1476
+ // desugared.
1477
+ break;
1478
+
1479
+ default:
1480
+ this.fail("missing identifier");
1481
+ }
1482
+ this.mustMatch(IN);
1483
+ n.object = this.Expression();
1484
+ this.MaybeRightParen(p);
1485
+ body.push(n);
1486
+ } while (this.match(FOR));
1487
+
1488
+ // Optional guard.
1489
+ if (this.match(IF))
1490
+ body.guard = this.HeadExpression();
1491
+
1492
+ return body;
1493
+ }
1494
+
1495
+ Pp.HeadExpression = function HeadExpression() {
1496
+ var p = this.MaybeLeftParen();
1497
+ var n = this.ParenExpression();
1498
+ this.MaybeRightParen(p);
1499
+ if (p === END && !n.parenthesized) {
1500
+ var tt = this.peek();
1501
+ if (tt !== LEFT_CURLY && !definitions.isStatementStartCode[tt])
1502
+ this.fail("Unparenthesized head followed by unbraced body");
1503
+ }
1504
+ return n;
1505
+ }
1506
+
1507
+ Pp.ParenExpression = function ParenExpression() {
1508
+ // Always accept the 'in' operator in a parenthesized expression,
1509
+ // where it's unambiguous, even if we might be parsing the init of a
1510
+ // for statement.
1511
+ var x2 = this.x.update({
1512
+ inForLoopInit: this.x.inForLoopInit && (this.t.token.type === LEFT_PAREN)
1513
+ });
1514
+ var n = this.withContext(x2, function() {
1515
+ return this.Expression();
1516
+ });
1517
+ if (this.match(FOR)) {
1518
+ if (n.type === YIELD && !n.parenthesized)
1519
+ this.fail("Yield expression must be parenthesized");
1520
+ if (n.type === COMMA && !n.parenthesized)
1521
+ this.fail("Generator expression must be parenthesized");
1522
+ n = this.GeneratorExpression(n);
1523
+ }
1524
+
1525
+ return n;
1526
+ }
1527
+
1528
+ /*
1529
+ * Expression :: () -> node
1530
+ *
1531
+ * Top-down expression parser matched against SpiderMonkey.
1532
+ */
1533
+ Pp.Expression = function Expression() {
1534
+ var n, n2;
1535
+
1536
+ n = this.AssignExpression();
1537
+ if (this.match(COMMA)) {
1538
+ n2 = this.newNode({ type: COMMA });
1539
+ n2.push(n);
1540
+ n = n2;
1541
+ do {
1542
+ n2 = n.children[n.children.length-1];
1543
+ if (n2.type === YIELD && !n2.parenthesized)
1544
+ this.fail("Yield expression must be parenthesized");
1545
+ n.push(this.AssignExpression());
1546
+ } while (this.match(COMMA));
1547
+ }
1548
+
1549
+ return n;
1550
+ }
1551
+
1552
+ Pp.AssignExpression = function AssignExpression() {
1553
+ var n, lhs;
1554
+
1555
+ // Have to treat yield like an operand because it could be the leftmost
1556
+ // operand of the expression.
1557
+ if (this.match(YIELD, true))
1558
+ return this.ReturnOrYield();
1559
+
1560
+ n = this.newNode({ type: ASSIGN });
1561
+ lhs = this.ConditionalExpression();
1562
+
1563
+ if (!this.match(ASSIGN)) {
1564
+ return lhs;
1565
+ }
1566
+
1567
+ n.blockComment = this.t.lastBlockComment();
1568
+
1569
+ switch (lhs.type) {
1570
+ case OBJECT_INIT:
1571
+ case ARRAY_INIT:
1572
+ lhs.destructuredNames = this.checkDestructuring(lhs);
1573
+ // FALL THROUGH
1574
+ case IDENTIFIER: case DOT: case INDEX: case CALL:
1575
+ break;
1576
+ default:
1577
+ this.fail("Bad left-hand side of assignment");
1578
+ break;
1579
+ }
1580
+
1581
+ n.assignOp = lhs.assignOp = this.t.token.assignOp;
1582
+ n.push(lhs);
1583
+ n.push(this.AssignExpression());
1584
+
1585
+ return n;
1586
+ }
1587
+
1588
+ Pp.ConditionalExpression = function ConditionalExpression() {
1589
+ var n, n2;
1590
+
1591
+ n = this.OrExpression();
1592
+ if (this.match(HOOK)) {
1593
+ n2 = n;
1594
+ n = this.newNode({ type: HOOK });
1595
+ n.push(n2);
1596
+ /*
1597
+ * Always accept the 'in' operator in the middle clause of a ternary,
1598
+ * where it's unambiguous, even if we might be parsing the init of a
1599
+ * for statement.
1600
+ */
1601
+ var x2 = this.x.update({ inForLoopInit: false });
1602
+ this.withContext(x2, function() {
1603
+ n.push(this.AssignExpression());
1604
+ });
1605
+ if (!this.match(COLON))
1606
+ this.fail("missing : after ?");
1607
+ n.push(this.AssignExpression());
1608
+ }
1609
+
1610
+ return n;
1611
+ }
1612
+
1613
+ Pp.OrExpression = function OrExpression() {
1614
+ var n, n2;
1615
+
1616
+ n = this.AndExpression();
1617
+ while (this.match(OR)) {
1618
+ n2 = this.newNode();
1619
+ n2.push(n);
1620
+ n2.push(this.AndExpression());
1621
+ n = n2;
1622
+ }
1623
+
1624
+ return n;
1625
+ }
1626
+
1627
+ Pp.AndExpression = function AndExpression() {
1628
+ var n, n2;
1629
+
1630
+ n = this.BitwiseOrExpression();
1631
+ while (this.match(AND)) {
1632
+ n2 = this.newNode();
1633
+ n2.push(n);
1634
+ n2.push(this.BitwiseOrExpression());
1635
+ n = n2;
1636
+ }
1637
+
1638
+ return n;
1639
+ }
1640
+
1641
+ Pp.BitwiseOrExpression = function BitwiseOrExpression() {
1642
+ var n, n2;
1643
+
1644
+ n = this.BitwiseXorExpression();
1645
+ while (this.match(BITWISE_OR)) {
1646
+ n2 = this.newNode();
1647
+ n2.push(n);
1648
+ n2.push(this.BitwiseXorExpression());
1649
+ n = n2;
1650
+ }
1651
+
1652
+ return n;
1653
+ }
1654
+
1655
+ Pp.BitwiseXorExpression = function BitwiseXorExpression() {
1656
+ var n, n2;
1657
+
1658
+ n = this.BitwiseAndExpression();
1659
+ while (this.match(BITWISE_XOR)) {
1660
+ n2 = this.newNode();
1661
+ n2.push(n);
1662
+ n2.push(this.BitwiseAndExpression());
1663
+ n = n2;
1664
+ }
1665
+
1666
+ return n;
1667
+ }
1668
+
1669
+ Pp.BitwiseAndExpression = function BitwiseAndExpression() {
1670
+ var n, n2;
1671
+
1672
+ n = this.EqualityExpression();
1673
+ while (this.match(BITWISE_AND)) {
1674
+ n2 = this.newNode();
1675
+ n2.push(n);
1676
+ n2.push(this.EqualityExpression());
1677
+ n = n2;
1678
+ }
1679
+
1680
+ return n;
1681
+ }
1682
+
1683
+ Pp.EqualityExpression = function EqualityExpression() {
1684
+ var n, n2;
1685
+
1686
+ n = this.RelationalExpression();
1687
+ while (this.match(EQ) || this.match(NE) ||
1688
+ this.match(STRICT_EQ) || this.match(STRICT_NE)) {
1689
+ n2 = this.newNode();
1690
+ n2.push(n);
1691
+ n2.push(this.RelationalExpression());
1692
+ n = n2;
1693
+ }
1694
+
1695
+ return n;
1696
+ }
1697
+
1698
+ Pp.RelationalExpression = function RelationalExpression() {
1699
+ var n, n2;
1700
+
1701
+ /*
1702
+ * Uses of the in operator in shiftExprs are always unambiguous,
1703
+ * so unset the flag that prohibits recognizing it.
1704
+ */
1705
+ var x2 = this.x.update({ inForLoopInit: false });
1706
+ this.withContext(x2, function() {
1707
+ n = this.ShiftExpression();
1708
+ while ((this.match(LT) || this.match(LE) || this.match(GE) || this.match(GT) ||
1709
+ (!this.x.inForLoopInit && this.match(IN)) ||
1710
+ this.match(INSTANCEOF))) {
1711
+ n2 = this.newNode();
1712
+ n2.push(n);
1713
+ n2.push(this.ShiftExpression());
1714
+ n = n2;
1715
+ }
1716
+ });
1717
+
1718
+ return n;
1719
+ }
1720
+
1721
+ Pp.ShiftExpression = function ShiftExpression() {
1722
+ var n, n2;
1723
+
1724
+ n = this.AddExpression();
1725
+ while (this.match(LSH) || this.match(RSH) || this.match(URSH)) {
1726
+ n2 = this.newNode();
1727
+ n2.push(n);
1728
+ n2.push(this.AddExpression());
1729
+ n = n2;
1730
+ }
1731
+
1732
+ return n;
1733
+ }
1734
+
1735
+ Pp.AddExpression = function AddExpression() {
1736
+ var n, n2;
1737
+
1738
+ n = this.MultiplyExpression();
1739
+ while (this.match(PLUS) || this.match(MINUS)) {
1740
+ n2 = this.newNode();
1741
+ n2.push(n);
1742
+ n2.push(this.MultiplyExpression());
1743
+ n = n2;
1744
+ }
1745
+
1746
+ return n;
1747
+ }
1748
+
1749
+ Pp.MultiplyExpression = function MultiplyExpression() {
1750
+ var n, n2;
1751
+
1752
+ n = this.UnaryExpression();
1753
+ while (this.match(MUL) || this.match(DIV) || this.match(MOD)) {
1754
+ n2 = this.newNode();
1755
+ n2.push(n);
1756
+ n2.push(this.UnaryExpression());
1757
+ n = n2;
1758
+ }
1759
+
1760
+ return n;
1761
+ }
1762
+
1763
+ Pp.UnaryExpression = function UnaryExpression() {
1764
+ var n, n2, tt;
1765
+
1766
+ switch (tt = this.t.get(true)) {
1767
+ case DELETE: case VOID: case TYPEOF:
1768
+ case NOT: case BITWISE_NOT: case PLUS: case MINUS:
1769
+ if (tt === PLUS)
1770
+ n = this.newNode({ type: UNARY_PLUS });
1771
+ else if (tt === MINUS)
1772
+ n = this.newNode({ type: UNARY_MINUS });
1773
+ else
1774
+ n = this.newNode();
1775
+ n.push(this.UnaryExpression());
1776
+ break;
1777
+
1778
+ case INCREMENT:
1779
+ case DECREMENT:
1780
+ // Prefix increment/decrement.
1781
+ n = this.newNode();
1782
+ n.push(this.MemberExpression(true));
1783
+ break;
1784
+
1785
+ default:
1786
+ this.t.unget();
1787
+ n = this.MemberExpression(true);
1788
+
1789
+ // Don't look across a newline boundary for a postfix {in,de}crement.
1790
+ if (this.t.tokens[(this.t.tokenIndex + this.t.lookahead - 1) & 3].lineno ===
1791
+ this.t.lineno) {
1792
+ if (this.match(INCREMENT) || this.match(DECREMENT)) {
1793
+ n2 = this.newNode({ postfix: true });
1794
+ n2.push(n);
1795
+ n = n2;
1796
+ }
1797
+ }
1798
+ break;
1799
+ }
1800
+
1801
+ return n;
1802
+ }
1803
+
1804
+ Pp.MemberExpression = function MemberExpression(allowCallSyntax) {
1805
+ var n, n2, name, tt;
1806
+
1807
+ if (this.match(NEW)) {
1808
+ n = this.newNode();
1809
+ n.push(this.MemberExpression(false));
1810
+ if (this.match(LEFT_PAREN)) {
1811
+ n.type = NEW_WITH_ARGS;
1812
+ n.push(this.ArgumentList());
1813
+ }
1814
+ } else {
1815
+ n = this.PrimaryExpression();
1816
+ }
1817
+
1818
+ while ((tt = this.t.get()) !== END) {
1819
+ switch (tt) {
1820
+ case DOT:
1821
+ n2 = this.newNode();
1822
+ n2.push(n);
1823
+ n2.push(this.IdentifierName());
1824
+ break;
1825
+
1826
+ case LEFT_BRACKET:
1827
+ n2 = this.newNode({ type: INDEX });
1828
+ n2.push(n);
1829
+ n2.push(this.Expression());
1830
+ this.mustMatch(RIGHT_BRACKET);
1831
+ break;
1832
+
1833
+ case LEFT_PAREN:
1834
+ if (allowCallSyntax) {
1835
+ n2 = this.newNode({ type: CALL });
1836
+ n2.push(n);
1837
+ n2.push(this.ArgumentList());
1838
+ break;
1839
+ }
1840
+
1841
+ // FALL THROUGH
1842
+ default:
1843
+ this.t.unget();
1844
+ return n;
1845
+ }
1846
+
1847
+ n = n2;
1848
+ }
1849
+
1850
+ return n;
1851
+ }
1852
+
1853
+ Pp.ArgumentList = function ArgumentList() {
1854
+ var n, n2;
1855
+
1856
+ n = this.newNode({ type: LIST });
1857
+ if (this.match(RIGHT_PAREN, true))
1858
+ return n;
1859
+ do {
1860
+ n2 = this.AssignExpression();
1861
+ if (n2.type === YIELD && !n2.parenthesized && this.peek() === COMMA)
1862
+ this.fail("Yield expression must be parenthesized");
1863
+ if (this.match(FOR)) {
1864
+ n2 = this.GeneratorExpression(n2);
1865
+ if (n.children.length > 1 || this.peek(true) === COMMA)
1866
+ this.fail("Generator expression must be parenthesized");
1867
+ }
1868
+ n.push(n2);
1869
+ } while (this.match(COMMA));
1870
+ this.mustMatch(RIGHT_PAREN);
1871
+
1872
+ return n;
1873
+ }
1874
+
1875
+ Pp.PrimaryExpression = function PrimaryExpression() {
1876
+ var n, n2, tt = this.t.get(true);
1877
+
1878
+ switch (tt) {
1879
+ case FUNCTION:
1880
+ n = this.FunctionDefinition(false, EXPRESSED_FORM);
1881
+ break;
1882
+
1883
+ case LEFT_BRACKET:
1884
+ n = this.newNode({ type: ARRAY_INIT });
1885
+ while ((tt = this.peek(true)) !== RIGHT_BRACKET) {
1886
+ if (tt === COMMA) {
1887
+ this.t.get();
1888
+ n.push(null);
1889
+ continue;
1890
+ }
1891
+ n.push(this.AssignExpression());
1892
+ if (tt !== COMMA && !this.match(COMMA))
1893
+ break;
1894
+ }
1895
+
1896
+ // If we matched exactly one element and got a FOR, we have an
1897
+ // array comprehension.
1898
+ if (n.children.length === 1 && this.match(FOR)) {
1899
+ n2 = this.newNode({ type: ARRAY_COMP,
1900
+ expression: n.children[0],
1901
+ tail: this.ComprehensionTail() });
1902
+ n = n2;
1903
+ }
1904
+ this.mustMatch(RIGHT_BRACKET);
1905
+ break;
1906
+
1907
+ case LEFT_CURLY:
1908
+ var id, fd;
1909
+ n = this.newNode({ type: OBJECT_INIT });
1910
+
1911
+ object_init:
1912
+ if (!this.match(RIGHT_CURLY)) {
1913
+ do {
1914
+ tt = this.t.get();
1915
+ if ((this.t.token.value === "get" || this.t.token.value === "set") &&
1916
+ this.peek() === IDENTIFIER) {
1917
+ n.push(this.FunctionDefinition(true, EXPRESSED_FORM));
1918
+ } else {
1919
+ var comments = this.t.blockComments;
1920
+ switch (tt) {
1921
+ case IDENTIFIER: case NUMBER: case STRING:
1922
+ id = this.newNode({ type: IDENTIFIER });
1923
+ break;
1924
+ case RIGHT_CURLY:
1925
+ break object_init;
1926
+ default:
1927
+ if (this.t.token.value in definitions.keywords) {
1928
+ id = this.newNode({ type: IDENTIFIER });
1929
+ break;
1930
+ }
1931
+ this.fail("Invalid property name");
1932
+ }
1933
+ if (this.match(COLON)) {
1934
+ n2 = this.newNode({ type: PROPERTY_INIT });
1935
+ n2.push(id);
1936
+ n2.push(this.AssignExpression());
1937
+ n2.blockComments = comments;
1938
+ n.push(n2);
1939
+ } else {
1940
+ // Support, e.g., |var {x, y} = o| as destructuring shorthand
1941
+ // for |var {x: x, y: y} = o|, per proposed JS2/ES4 for JS1.8.
1942
+ if (this.peek() !== COMMA && this.peek() !== RIGHT_CURLY)
1943
+ this.fail("missing : after property");
1944
+ n.push(id);
1945
+ }
1946
+ }
1947
+ } while (this.match(COMMA));
1948
+ this.mustMatch(RIGHT_CURLY);
1949
+ }
1950
+ break;
1951
+
1952
+ case LEFT_PAREN:
1953
+ n = this.ParenExpression();
1954
+ this.mustMatch(RIGHT_PAREN);
1955
+ n.parenthesized = true;
1956
+ break;
1957
+
1958
+ case LET:
1959
+ n = this.LetBlock(false);
1960
+ break;
1961
+
1962
+ case NULL: case THIS: case TRUE: case FALSE:
1963
+ case IDENTIFIER: case NUMBER: case STRING: case REGEXP:
1964
+ n = this.newNode();
1965
+ break;
1966
+
1967
+ default:
1968
+ this.fail("missing operand; found " + definitions.tokens[tt]);
1969
+ break;
1970
+ }
1971
+
1972
+ return n;
1973
+ }
1974
+
1975
+ /*
1976
+ * parse :: (source, filename, line number) -> node
1977
+ */
1978
+ function parse(s, f, l) {
1979
+ var t = new Tokenizer(s, f, l, options.allowHTMLComments);
1980
+ var p = new Parser(t);
1981
+ return p.Script(false, false, true);
1982
+ }
1983
+
1984
+ /*
1985
+ * parseFunction :: (source, boolean,
1986
+ * DECLARED_FORM or EXPRESSED_FORM or STATEMENT_FORM,
1987
+ * filename, line number)
1988
+ * -> node
1989
+ */
1990
+ function parseFunction(s, requireName, form, f, l) {
1991
+ var t = new Tokenizer(s, f, l);
1992
+ var p = new Parser(t);
1993
+ p.x = new StaticContext(null, null, false, false, false);
1994
+ return p.FunctionDefinition(requireName, form);
1995
+ }
1996
+
1997
+ /*
1998
+ * parseStdin :: (source, {line number}, string, (string) -> boolean) -> program node
1999
+ */
2000
+ function parseStdin(s, ln, prefix, isCommand) {
2001
+ // the special .begin command is only recognized at the beginning
2002
+ if (s.match(/^[\s]*\.begin[\s]*$/)) {
2003
+ ++ln.value;
2004
+ return parseMultiline(ln, prefix);
2005
+ }
2006
+
2007
+ // commands at the beginning are treated as the entire input
2008
+ if (isCommand(s.trim()))
2009
+ s = "";
2010
+
2011
+ for (;;) {
2012
+ try {
2013
+ var t = new Tokenizer(s, "stdin", ln.value, false);
2014
+ var p = new Parser(t);
2015
+ var n = p.Script(false, false);
2016
+ ln.value = t.lineno;
2017
+ return n;
2018
+ } catch (e) {
2019
+ if (!p.unexpectedEOF)
2020
+ throw e;
2021
+
2022
+ // commands in the middle are not treated as part of the input
2023
+ var more;
2024
+ do {
2025
+ if (prefix)
2026
+ putstr(prefix);
2027
+ more = readline();
2028
+ if (!more)
2029
+ throw e;
2030
+ } while (isCommand(more.trim()));
2031
+
2032
+ s += "\n" + more;
2033
+ }
2034
+ }
2035
+ }
2036
+
2037
+ /*
2038
+ * parseMultiline :: ({line number}, string | null) -> program node
2039
+ */
2040
+ function parseMultiline(ln, prefix) {
2041
+ var s = "";
2042
+ for (;;) {
2043
+ if (prefix)
2044
+ putstr(prefix);
2045
+ var more = readline();
2046
+ if (more === null)
2047
+ return null;
2048
+ // the only command recognized in multiline mode is .end
2049
+ if (more.match(/^[\s]*\.end[\s]*$/))
2050
+ break;
2051
+ s += "\n" + more;
2052
+ }
2053
+ var t = new Tokenizer(s, "stdin", ln.value, false);
2054
+ var p = new Parser(t);
2055
+ var n = p.Script(false, false);
2056
+ ln.value = t.lineno;
2057
+ return n;
2058
+ }
2059
+
2060
+ exports.parse = parse;
2061
+ exports.parseStdin = parseStdin;
2062
+ exports.parseFunction = parseFunction;
2063
+ exports.Node = Node;
2064
+ exports.DECLARED_FORM = DECLARED_FORM;
2065
+ exports.EXPRESSED_FORM = EXPRESSED_FORM;
2066
+ exports.STATEMENT_FORM = STATEMENT_FORM;
2067
+ exports.Tokenizer = Tokenizer;
2068
+ exports.Parser = Parser;
2069
+ exports.Module = Module;
2070
+ exports.Export = Export;
2071
+
2072
+ });