laser 0.7.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +14 -0
  4. data/LICENSE +661 -0
  5. data/README.md +158 -0
  6. data/Rakefile +104 -0
  7. data/VERSION +1 -0
  8. data/bin/laser +7 -0
  9. data/design_docs/goals.md +57 -0
  10. data/design_docs/object_regex.md +426 -0
  11. data/design_docs/type_annotations.md +80 -0
  12. data/ext/laser/BasicBlock.cpp +572 -0
  13. data/ext/laser/BasicBlock.h +118 -0
  14. data/ext/laser/extconf.rb +3 -0
  15. data/features/laser.feature +25 -0
  16. data/features/step_definitions/laser_steps.rb +39 -0
  17. data/features/support/env.rb +14 -0
  18. data/features/support/testdata/1_input +1 -0
  19. data/features/support/testdata/1_output +1 -0
  20. data/features/support/testdata/2_input +4 -0
  21. data/features/support/testdata/2_output +4 -0
  22. data/features/support/testdata/3_input +8 -0
  23. data/features/support/testdata/3_output +11 -0
  24. data/features/support/testdata/4_input +5 -0
  25. data/features/support/testdata/4_output +5 -0
  26. data/features/support/testdata/5_input +13 -0
  27. data/laser.gemspec +382 -0
  28. data/lib/laser.rb +98 -0
  29. data/lib/laser/analysis/annotations.rb +95 -0
  30. data/lib/laser/analysis/annotations/annotation_config.yaml +3 -0
  31. data/lib/laser/analysis/annotations/comment_attachment_annotation.rb +66 -0
  32. data/lib/laser/analysis/annotations/node_pointers_annotation.rb +36 -0
  33. data/lib/laser/analysis/annotations/runtime_annotation.rb +55 -0
  34. data/lib/laser/analysis/argument_expansion.rb +132 -0
  35. data/lib/laser/analysis/arity.rb +34 -0
  36. data/lib/laser/analysis/bindings.rb +144 -0
  37. data/lib/laser/analysis/bootstrap/bootstrap.rb +298 -0
  38. data/lib/laser/analysis/bootstrap/laser_class.rb +106 -0
  39. data/lib/laser/analysis/bootstrap/laser_method.rb +255 -0
  40. data/lib/laser/analysis/bootstrap/laser_module.rb +403 -0
  41. data/lib/laser/analysis/bootstrap/laser_module_copy.rb +74 -0
  42. data/lib/laser/analysis/bootstrap/laser_object.rb +69 -0
  43. data/lib/laser/analysis/bootstrap/laser_proc.rb +150 -0
  44. data/lib/laser/analysis/bootstrap/laser_singleton_class.rb +44 -0
  45. data/lib/laser/analysis/comments.rb +35 -0
  46. data/lib/laser/analysis/control_flow.rb +28 -0
  47. data/lib/laser/analysis/control_flow/alias_analysis.rb +31 -0
  48. data/lib/laser/analysis/control_flow/basic_block.rb +105 -0
  49. data/lib/laser/analysis/control_flow/cfg_builder.rb +2505 -0
  50. data/lib/laser/analysis/control_flow/cfg_instruction.rb +190 -0
  51. data/lib/laser/analysis/control_flow/constant_propagation.rb +742 -0
  52. data/lib/laser/analysis/control_flow/control_flow_graph.rb +370 -0
  53. data/lib/laser/analysis/control_flow/lifetime_analysis.rb +91 -0
  54. data/lib/laser/analysis/control_flow/method_call_search.rb +26 -0
  55. data/lib/laser/analysis/control_flow/raise_properties.rb +25 -0
  56. data/lib/laser/analysis/control_flow/simulation.rb +385 -0
  57. data/lib/laser/analysis/control_flow/static_single_assignment.rb +185 -0
  58. data/lib/laser/analysis/control_flow/unreachability_analysis.rb +57 -0
  59. data/lib/laser/analysis/control_flow/unused_variables.rb +91 -0
  60. data/lib/laser/analysis/control_flow/yield_properties.rb +103 -0
  61. data/lib/laser/analysis/errors.rb +131 -0
  62. data/lib/laser/analysis/laser_utils.rb +18 -0
  63. data/lib/laser/analysis/lexical_analysis.rb +172 -0
  64. data/lib/laser/analysis/method_call.rb +68 -0
  65. data/lib/laser/analysis/protocol_registry.rb +30 -0
  66. data/lib/laser/analysis/scope.rb +118 -0
  67. data/lib/laser/analysis/sexp.rb +159 -0
  68. data/lib/laser/analysis/sexp_analysis.rb +40 -0
  69. data/lib/laser/analysis/sexp_extensions/constant_extraction.rb +115 -0
  70. data/lib/laser/analysis/sexp_extensions/source_location.rb +164 -0
  71. data/lib/laser/analysis/sexp_extensions/type_inference.rb +47 -0
  72. data/lib/laser/analysis/signature.rb +76 -0
  73. data/lib/laser/analysis/special_methods/send.rb +67 -0
  74. data/lib/laser/analysis/unused_methods.rb +21 -0
  75. data/lib/laser/analysis/visitor.rb +141 -0
  76. data/lib/laser/annotation_parser/annotations.treetop +126 -0
  77. data/lib/laser/annotation_parser/annotations_parser.rb +748 -0
  78. data/lib/laser/annotation_parser/class_annotations.treetop +82 -0
  79. data/lib/laser/annotation_parser/class_annotations_parser.rb +654 -0
  80. data/lib/laser/annotation_parser/overload.treetop +24 -0
  81. data/lib/laser/annotation_parser/overload_parser.rb +167 -0
  82. data/lib/laser/annotation_parser/parsers.rb +6 -0
  83. data/lib/laser/annotation_parser/structural.treetop +37 -0
  84. data/lib/laser/annotation_parser/structural_parser.rb +406 -0
  85. data/lib/laser/annotation_parser/useful_parsers.treetop +47 -0
  86. data/lib/laser/annotation_parser/useful_parsers_parser.rb +674 -0
  87. data/lib/laser/rake/task.rb +46 -0
  88. data/lib/laser/runner.rb +189 -0
  89. data/lib/laser/scanner.rb +169 -0
  90. data/lib/laser/standard_library/_thread.rb +110 -0
  91. data/lib/laser/standard_library/abbrev.rb +103 -0
  92. data/lib/laser/standard_library/array.rb +418 -0
  93. data/lib/laser/standard_library/base64.rb +91 -0
  94. data/lib/laser/standard_library/basic_object.rb +55 -0
  95. data/lib/laser/standard_library/benchmark.rb +556 -0
  96. data/lib/laser/standard_library/bignum.rb +185 -0
  97. data/lib/laser/standard_library/cgi.rb +275 -0
  98. data/lib/laser/standard_library/cgi/cookie.rb +147 -0
  99. data/lib/laser/standard_library/cgi/core.rb +791 -0
  100. data/lib/laser/standard_library/cgi/html.rb +1021 -0
  101. data/lib/laser/standard_library/cgi/session.rb +537 -0
  102. data/lib/laser/standard_library/cgi/session/pstore.rb +111 -0
  103. data/lib/laser/standard_library/cgi/util.rb +188 -0
  104. data/lib/laser/standard_library/class_definitions.rb +333 -0
  105. data/lib/laser/standard_library/comparable.rb +125 -0
  106. data/lib/laser/standard_library/complex.rb +162 -0
  107. data/lib/laser/standard_library/enumerable.rb +178 -0
  108. data/lib/laser/standard_library/exceptions.rb +135 -0
  109. data/lib/laser/standard_library/fixnum.rb +188 -0
  110. data/lib/laser/standard_library/float.rb +180 -0
  111. data/lib/laser/standard_library/hash.rb +237 -0
  112. data/lib/laser/standard_library/integer.rb +123 -0
  113. data/lib/laser/standard_library/laser_magic.rb +7 -0
  114. data/lib/laser/standard_library/nil_false_true.rb +113 -0
  115. data/lib/laser/standard_library/numbers.rb +192 -0
  116. data/lib/laser/standard_library/proc.rb +31 -0
  117. data/lib/laser/standard_library/set.rb +1348 -0
  118. data/lib/laser/standard_library/string.rb +666 -0
  119. data/lib/laser/standard_library/stringio.rb +2 -0
  120. data/lib/laser/standard_library/symbol.rb +125 -0
  121. data/lib/laser/standard_library/tsort.rb +242 -0
  122. data/lib/laser/support/acts_as_struct.rb +66 -0
  123. data/lib/laser/support/frequency.rb +55 -0
  124. data/lib/laser/support/inheritable_attributes.rb +145 -0
  125. data/lib/laser/support/module_extensions.rb +94 -0
  126. data/lib/laser/support/placeholder_object.rb +13 -0
  127. data/lib/laser/third_party/rgl/adjacency.rb +221 -0
  128. data/lib/laser/third_party/rgl/base.rb +228 -0
  129. data/lib/laser/third_party/rgl/bidirectional.rb +39 -0
  130. data/lib/laser/third_party/rgl/condensation.rb +47 -0
  131. data/lib/laser/third_party/rgl/connected_components.rb +138 -0
  132. data/lib/laser/third_party/rgl/control_flow.rb +170 -0
  133. data/lib/laser/third_party/rgl/depth_first_spanning_tree.rb +37 -0
  134. data/lib/laser/third_party/rgl/dominators.rb +124 -0
  135. data/lib/laser/third_party/rgl/dot.rb +93 -0
  136. data/lib/laser/third_party/rgl/graphxml.rb +51 -0
  137. data/lib/laser/third_party/rgl/implicit.rb +174 -0
  138. data/lib/laser/third_party/rgl/mutable.rb +117 -0
  139. data/lib/laser/third_party/rgl/rdot.rb +445 -0
  140. data/lib/laser/third_party/rgl/topsort.rb +72 -0
  141. data/lib/laser/third_party/rgl/transitivity.rb +180 -0
  142. data/lib/laser/third_party/rgl/traversal.rb +348 -0
  143. data/lib/laser/types/types.rb +433 -0
  144. data/lib/laser/version.rb +14 -0
  145. data/lib/laser/warning.rb +149 -0
  146. data/lib/laser/warning_sets/default.yml +13 -0
  147. data/lib/laser/warnings/assignment_in_condition.rb +20 -0
  148. data/lib/laser/warnings/comment_spacing.rb +31 -0
  149. data/lib/laser/warnings/extra_blank_lines.rb +30 -0
  150. data/lib/laser/warnings/extra_whitespace.rb +16 -0
  151. data/lib/laser/warnings/hash_symbol_18_warning.rb +63 -0
  152. data/lib/laser/warnings/hash_symbol_19_warning.rb +29 -0
  153. data/lib/laser/warnings/line_length.rb +115 -0
  154. data/lib/laser/warnings/misaligned_unindentation.rb +17 -0
  155. data/lib/laser/warnings/operator_spacing.rb +68 -0
  156. data/lib/laser/warnings/parens_on_declaration.rb +30 -0
  157. data/lib/laser/warnings/rescue_exception.rb +42 -0
  158. data/lib/laser/warnings/semicolon.rb +25 -0
  159. data/lib/laser/warnings/sexp_errors.rb +24 -0
  160. data/lib/laser/warnings/uncalled_method_warning.rb +7 -0
  161. data/lib/laser/warnings/useless_double_quotes.rb +38 -0
  162. data/spec/analysis_specs/annotations_spec.rb +47 -0
  163. data/spec/analysis_specs/annotations_specs/comment_attachment_spec.rb +68 -0
  164. data/spec/analysis_specs/annotations_specs/node_pointers_annotation_spec.rb +90 -0
  165. data/spec/analysis_specs/annotations_specs/runtime_annotation_spec.rb +135 -0
  166. data/spec/analysis_specs/annotations_specs/spec_helper.rb +33 -0
  167. data/spec/analysis_specs/argument_expansion_spec.rb +113 -0
  168. data/spec/analysis_specs/bindings_spec.rb +36 -0
  169. data/spec/analysis_specs/comment_spec.rb +93 -0
  170. data/spec/analysis_specs/control_flow_specs/cfg_instruction_spec.rb +111 -0
  171. data/spec/analysis_specs/control_flow_specs/constant_propagation_spec.rb +560 -0
  172. data/spec/analysis_specs/control_flow_specs/control_flow_graph_spec.rb +5 -0
  173. data/spec/analysis_specs/control_flow_specs/raise_properties_spec.rb +310 -0
  174. data/spec/analysis_specs/control_flow_specs/raise_type_inference_spec.rb +301 -0
  175. data/spec/analysis_specs/control_flow_specs/return_type_inference_spec.rb +431 -0
  176. data/spec/analysis_specs/control_flow_specs/simulation_spec.rb +158 -0
  177. data/spec/analysis_specs/control_flow_specs/spec_helper.rb +110 -0
  178. data/spec/analysis_specs/control_flow_specs/tuple_misuse_inference_spec.rb +125 -0
  179. data/spec/analysis_specs/control_flow_specs/unreachability_analysis_spec.rb +76 -0
  180. data/spec/analysis_specs/control_flow_specs/unused_variable_spec.rb +99 -0
  181. data/spec/analysis_specs/control_flow_specs/yield_properties_spec.rb +372 -0
  182. data/spec/analysis_specs/error_spec.rb +30 -0
  183. data/spec/analysis_specs/laser_class_spec.rb +322 -0
  184. data/spec/analysis_specs/lexical_analysis_spec.rb +184 -0
  185. data/spec/analysis_specs/protocol_registry_spec.rb +63 -0
  186. data/spec/analysis_specs/scope_annotation_spec.rb +1013 -0
  187. data/spec/analysis_specs/scope_spec.rb +126 -0
  188. data/spec/analysis_specs/sexp_analysis_spec.rb +30 -0
  189. data/spec/analysis_specs/sexp_extension_specs/constant_extraction_spec.rb +309 -0
  190. data/spec/analysis_specs/sexp_extension_specs/source_location_spec.rb +231 -0
  191. data/spec/analysis_specs/sexp_extension_specs/spec_helper.rb +1 -0
  192. data/spec/analysis_specs/sexp_extension_specs/type_inference_spec.rb +252 -0
  193. data/spec/analysis_specs/sexp_spec.rb +167 -0
  194. data/spec/analysis_specs/spec_helper.rb +27 -0
  195. data/spec/analysis_specs/unused_methods_spec.rb +65 -0
  196. data/spec/analysis_specs/visitor_spec.rb +64 -0
  197. data/spec/annotation_parser_specs/annotations_parser_spec.rb +89 -0
  198. data/spec/annotation_parser_specs/class_annotation_parser_spec.rb +120 -0
  199. data/spec/annotation_parser_specs/overload_parser_spec.rb +39 -0
  200. data/spec/annotation_parser_specs/parsers_spec.rb +14 -0
  201. data/spec/annotation_parser_specs/spec_helper.rb +1 -0
  202. data/spec/annotation_parser_specs/structural_parser_spec.rb +67 -0
  203. data/spec/laser_spec.rb +14 -0
  204. data/spec/rake_specs/spec_helper.rb +1 -0
  205. data/spec/rake_specs/task_spec.rb +67 -0
  206. data/spec/runner_spec.rb +207 -0
  207. data/spec/scanner_spec.rb +75 -0
  208. data/spec/spec_helper.rb +121 -0
  209. data/spec/standard_library/exceptions_spec.rb +19 -0
  210. data/spec/standard_library/globals_spec.rb +14 -0
  211. data/spec/standard_library/set_spec.rb +31 -0
  212. data/spec/standard_library/spec_helper.rb +1 -0
  213. data/spec/standard_library/standard_library_spec.rb +302 -0
  214. data/spec/support_specs/acts_as_struct_spec.rb +94 -0
  215. data/spec/support_specs/frequency_spec.rb +23 -0
  216. data/spec/support_specs/module_extensions_spec.rb +117 -0
  217. data/spec/support_specs/spec_helper.rb +1 -0
  218. data/spec/type_specs/spec_helper.rb +1 -0
  219. data/spec/type_specs/types_spec.rb +133 -0
  220. data/spec/warning_spec.rb +95 -0
  221. data/spec/warning_specs/assignment_in_condition_spec.rb +68 -0
  222. data/spec/warning_specs/comment_spacing_spec.rb +65 -0
  223. data/spec/warning_specs/extra_blank_lines_spec.rb +70 -0
  224. data/spec/warning_specs/extra_whitespace_spec.rb +33 -0
  225. data/spec/warning_specs/hash_symbol_18_warning_spec.rb +89 -0
  226. data/spec/warning_specs/hash_symbol_19_warning_spec.rb +63 -0
  227. data/spec/warning_specs/line_length_spec.rb +173 -0
  228. data/spec/warning_specs/misaligned_unindentation_spec.rb +35 -0
  229. data/spec/warning_specs/operator_spacing_spec.rb +104 -0
  230. data/spec/warning_specs/parens_on_declaration_spec.rb +57 -0
  231. data/spec/warning_specs/rescue_exception_spec.rb +105 -0
  232. data/spec/warning_specs/semicolon_spec.rb +58 -0
  233. data/spec/warning_specs/spec_helper.rb +1 -0
  234. data/spec/warning_specs/useless_double_quotes_spec.rb +74 -0
  235. data/status_reports/2010/12/2010-12-14.md +163 -0
  236. data/status_reports/2010/12/2010-12-23.md +298 -0
  237. data/status_reports/2010/12/2010-12-24.md +6 -0
  238. data/test/third_party_tests/rgl_tests/TestComponents.rb +65 -0
  239. data/test/third_party_tests/rgl_tests/TestCycles.rb +61 -0
  240. data/test/third_party_tests/rgl_tests/TestDirectedGraph.rb +125 -0
  241. data/test/third_party_tests/rgl_tests/TestDot.rb +18 -0
  242. data/test/third_party_tests/rgl_tests/TestEdge.rb +34 -0
  243. data/test/third_party_tests/rgl_tests/TestGraph.rb +71 -0
  244. data/test/third_party_tests/rgl_tests/TestGraphXML.rb +57 -0
  245. data/test/third_party_tests/rgl_tests/TestImplicit.rb +52 -0
  246. data/test/third_party_tests/rgl_tests/TestRdot.rb +863 -0
  247. data/test/third_party_tests/rgl_tests/TestTransitivity.rb +129 -0
  248. data/test/third_party_tests/rgl_tests/TestTraversal.rb +220 -0
  249. data/test/third_party_tests/rgl_tests/TestUnDirectedGraph.rb +102 -0
  250. data/test/third_party_tests/rgl_tests/examples/north/Graph.log +128 -0
  251. data/test/third_party_tests/rgl_tests/examples/north/g.10.0.graphml +28 -0
  252. data/test/third_party_tests/rgl_tests/examples/north/g.10.1.graphml +28 -0
  253. data/test/third_party_tests/rgl_tests/examples/north/g.10.11.graphml +31 -0
  254. data/test/third_party_tests/rgl_tests/examples/north/g.10.12.graphml +27 -0
  255. data/test/third_party_tests/rgl_tests/examples/north/g.10.13.graphml +27 -0
  256. data/test/third_party_tests/rgl_tests/examples/north/g.10.14.graphml +27 -0
  257. data/test/third_party_tests/rgl_tests/examples/north/g.10.15.graphml +26 -0
  258. data/test/third_party_tests/rgl_tests/examples/north/g.10.16.graphml +26 -0
  259. data/test/third_party_tests/rgl_tests/examples/north/g.10.17.graphml +26 -0
  260. data/test/third_party_tests/rgl_tests/examples/north/g.10.19.graphml +37 -0
  261. data/test/third_party_tests/rgl_tests/examples/north/g.10.2.graphml +28 -0
  262. data/test/third_party_tests/rgl_tests/examples/north/g.10.20.graphml +38 -0
  263. data/test/third_party_tests/rgl_tests/examples/north/g.10.22.graphml +43 -0
  264. data/test/third_party_tests/rgl_tests/examples/north/g.10.24.graphml +30 -0
  265. data/test/third_party_tests/rgl_tests/examples/north/g.10.25.graphml +45 -0
  266. data/test/third_party_tests/rgl_tests/examples/north/g.10.27.graphml +38 -0
  267. data/test/third_party_tests/rgl_tests/examples/north/g.10.28.graphml +30 -0
  268. data/test/third_party_tests/rgl_tests/examples/north/g.10.29.graphml +38 -0
  269. data/test/third_party_tests/rgl_tests/examples/north/g.10.3.graphml +26 -0
  270. data/test/third_party_tests/rgl_tests/examples/north/g.10.30.graphml +34 -0
  271. data/test/third_party_tests/rgl_tests/examples/north/g.10.31.graphml +42 -0
  272. data/test/third_party_tests/rgl_tests/examples/north/g.10.34.graphml +42 -0
  273. data/test/third_party_tests/rgl_tests/examples/north/g.10.37.graphml +28 -0
  274. data/test/third_party_tests/rgl_tests/examples/north/g.10.38.graphml +38 -0
  275. data/test/third_party_tests/rgl_tests/examples/north/g.10.39.graphml +36 -0
  276. data/test/third_party_tests/rgl_tests/examples/north/g.10.4.graphml +26 -0
  277. data/test/third_party_tests/rgl_tests/examples/north/g.10.40.graphml +37 -0
  278. data/test/third_party_tests/rgl_tests/examples/north/g.10.41.graphml +37 -0
  279. data/test/third_party_tests/rgl_tests/examples/north/g.10.42.graphml +26 -0
  280. data/test/third_party_tests/rgl_tests/examples/north/g.10.45.graphml +28 -0
  281. data/test/third_party_tests/rgl_tests/examples/north/g.10.46.graphml +32 -0
  282. data/test/third_party_tests/rgl_tests/examples/north/g.10.5.graphml +31 -0
  283. data/test/third_party_tests/rgl_tests/examples/north/g.10.50.graphml +30 -0
  284. data/test/third_party_tests/rgl_tests/examples/north/g.10.56.graphml +29 -0
  285. data/test/third_party_tests/rgl_tests/examples/north/g.10.57.graphml +32 -0
  286. data/test/third_party_tests/rgl_tests/examples/north/g.10.58.graphml +32 -0
  287. data/test/third_party_tests/rgl_tests/examples/north/g.10.6.graphml +26 -0
  288. data/test/third_party_tests/rgl_tests/examples/north/g.10.60.graphml +32 -0
  289. data/test/third_party_tests/rgl_tests/examples/north/g.10.61.graphml +34 -0
  290. data/test/third_party_tests/rgl_tests/examples/north/g.10.62.graphml +34 -0
  291. data/test/third_party_tests/rgl_tests/examples/north/g.10.68.graphml +30 -0
  292. data/test/third_party_tests/rgl_tests/examples/north/g.10.69.graphml +32 -0
  293. data/test/third_party_tests/rgl_tests/examples/north/g.10.7.graphml +29 -0
  294. data/test/third_party_tests/rgl_tests/examples/north/g.10.70.graphml +26 -0
  295. data/test/third_party_tests/rgl_tests/examples/north/g.10.71.graphml +27 -0
  296. data/test/third_party_tests/rgl_tests/examples/north/g.10.72.graphml +28 -0
  297. data/test/third_party_tests/rgl_tests/examples/north/g.10.74.graphml +29 -0
  298. data/test/third_party_tests/rgl_tests/examples/north/g.10.75.graphml +29 -0
  299. data/test/third_party_tests/rgl_tests/examples/north/g.10.78.graphml +27 -0
  300. data/test/third_party_tests/rgl_tests/examples/north/g.10.79.graphml +34 -0
  301. data/test/third_party_tests/rgl_tests/examples/north/g.10.8.graphml +29 -0
  302. data/test/third_party_tests/rgl_tests/examples/north/g.10.80.graphml +34 -0
  303. data/test/third_party_tests/rgl_tests/examples/north/g.10.82.graphml +35 -0
  304. data/test/third_party_tests/rgl_tests/examples/north/g.10.83.graphml +32 -0
  305. data/test/third_party_tests/rgl_tests/examples/north/g.10.85.graphml +34 -0
  306. data/test/third_party_tests/rgl_tests/examples/north/g.10.86.graphml +34 -0
  307. data/test/third_party_tests/rgl_tests/examples/north/g.10.88.graphml +37 -0
  308. data/test/third_party_tests/rgl_tests/examples/north/g.10.89.graphml +29 -0
  309. data/test/third_party_tests/rgl_tests/examples/north/g.10.9.graphml +26 -0
  310. data/test/third_party_tests/rgl_tests/examples/north/g.10.90.graphml +32 -0
  311. data/test/third_party_tests/rgl_tests/examples/north/g.10.91.graphml +31 -0
  312. data/test/third_party_tests/rgl_tests/examples/north/g.10.92.graphml +26 -0
  313. data/test/third_party_tests/rgl_tests/examples/north/g.10.93.graphml +32 -0
  314. data/test/third_party_tests/rgl_tests/examples/north/g.10.94.graphml +34 -0
  315. data/test/third_party_tests/rgl_tests/examples/north/g.12.8.graphml +40 -0
  316. data/test/third_party_tests/rgl_tests/examples/north/g.14.9.graphml +36 -0
  317. data/test/third_party_tests/rgl_tests/test_helper.rb +7 -0
  318. data/test/third_party_tests/test_inheritable_attributes.rb +187 -0
  319. metadata +470 -0
@@ -0,0 +1,126 @@
1
+ module Laser
2
+ module Parsers
3
+ grammar Annotation
4
+ include Class
5
+ include Structural
6
+ include Overload
7
+ include GeneralPurpose
8
+
9
+ rule named_annotation
10
+ named_type_annotation / named_literal_annotation
11
+ end
12
+
13
+ rule named_type_annotation
14
+ space* annotation_name ':' space* type space* {
15
+ def literal?
16
+ false
17
+ end
18
+
19
+ def literal
20
+ raise TypeError.new('This annotation is not a literal. Call #literal? first.')
21
+ end
22
+
23
+ def type?
24
+ true
25
+ end
26
+
27
+ def type
28
+ super.type
29
+ end
30
+
31
+ def name
32
+ annotation_name.text_value
33
+ end
34
+ }
35
+ end
36
+
37
+ rule named_literal_annotation
38
+ space* annotation_name ':' space* literal space* {
39
+ def literal?
40
+ true
41
+ end
42
+
43
+ def literal
44
+ super.literal
45
+ end
46
+
47
+ def type?
48
+ false
49
+ end
50
+
51
+ def type
52
+ raise TypeError.new('This annotation is not a type. Call #type? first.')
53
+ end
54
+
55
+ def name
56
+ annotation_name.text_value
57
+ end
58
+ }
59
+ end
60
+
61
+ rule literal
62
+ 'false' {
63
+ def literal
64
+ false
65
+ end
66
+ } / 'true' {
67
+ def literal
68
+ true
69
+ end
70
+ } / 'nil' {
71
+ def literal
72
+ nil
73
+ end
74
+ } / ('never' / 'maybe' / 'always' / 'required' / 'optional' / 'foolish' / 'ignored') {
75
+ def literal
76
+ text_value.to_sym
77
+ end
78
+ }
79
+ end
80
+
81
+ rule type
82
+ union_type / non_union_type / empty_type
83
+ end
84
+
85
+ rule union_type
86
+ non_union_type rest_members:(space* '|' space* non_union_type)+ {
87
+ def type
88
+ Types::UnionType.new([non_union_type, *rest_members].map(&:type))
89
+ end
90
+
91
+ def rest_members
92
+ super.elements.map(&:non_union_type)
93
+ end
94
+ }
95
+ end
96
+
97
+ rule non_union_type
98
+ (top / self_type / function_type / class_based_constraint / structural_constraint)
99
+ end
100
+
101
+ rule empty_type
102
+ 'empty' {
103
+ def type
104
+ Types::EMPTY
105
+ end
106
+ }
107
+ end
108
+
109
+ rule top
110
+ "Top" {
111
+ def type
112
+ []
113
+ end
114
+ }
115
+ end
116
+
117
+ rule self_type
118
+ "self" {
119
+ def type
120
+ Types::SelfType.new
121
+ end
122
+ }
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,748 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Laser
5
+ module Parsers
6
+ module Annotation
7
+ include Treetop::Runtime
8
+
9
+ def root
10
+ @root ||= :named_annotation
11
+ end
12
+
13
+ include Class
14
+
15
+ include Structural
16
+
17
+ include Overload
18
+
19
+ include GeneralPurpose
20
+
21
+ def _nt_named_annotation
22
+ start_index = index
23
+ if node_cache[:named_annotation].has_key?(index)
24
+ cached = node_cache[:named_annotation][index]
25
+ if cached
26
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
27
+ @index = cached.interval.end
28
+ end
29
+ return cached
30
+ end
31
+
32
+ i0 = index
33
+ r1 = _nt_named_type_annotation
34
+ if r1
35
+ r0 = r1
36
+ else
37
+ r2 = _nt_named_literal_annotation
38
+ if r2
39
+ r0 = r2
40
+ else
41
+ @index = i0
42
+ r0 = nil
43
+ end
44
+ end
45
+
46
+ node_cache[:named_annotation][start_index] = r0
47
+
48
+ r0
49
+ end
50
+
51
+ module NamedTypeAnnotation0
52
+ def annotation_name
53
+ elements[1]
54
+ end
55
+
56
+ def type
57
+ elements[4]
58
+ end
59
+
60
+ end
61
+
62
+ module NamedTypeAnnotation1
63
+ def literal?
64
+ false
65
+ end
66
+
67
+ def literal
68
+ raise TypeError.new('This annotation is not a literal. Call #literal? first.')
69
+ end
70
+
71
+ def type?
72
+ true
73
+ end
74
+
75
+ def type
76
+ super.type
77
+ end
78
+
79
+ def name
80
+ annotation_name.text_value
81
+ end
82
+ end
83
+
84
+ def _nt_named_type_annotation
85
+ start_index = index
86
+ if node_cache[:named_type_annotation].has_key?(index)
87
+ cached = node_cache[:named_type_annotation][index]
88
+ if cached
89
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
90
+ @index = cached.interval.end
91
+ end
92
+ return cached
93
+ end
94
+
95
+ i0, s0 = index, []
96
+ s1, i1 = [], index
97
+ loop do
98
+ r2 = _nt_space
99
+ if r2
100
+ s1 << r2
101
+ else
102
+ break
103
+ end
104
+ end
105
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
106
+ s0 << r1
107
+ if r1
108
+ r3 = _nt_annotation_name
109
+ s0 << r3
110
+ if r3
111
+ if has_terminal?(':', false, index)
112
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
113
+ @index += 1
114
+ else
115
+ terminal_parse_failure(':')
116
+ r4 = nil
117
+ end
118
+ s0 << r4
119
+ if r4
120
+ s5, i5 = [], index
121
+ loop do
122
+ r6 = _nt_space
123
+ if r6
124
+ s5 << r6
125
+ else
126
+ break
127
+ end
128
+ end
129
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
130
+ s0 << r5
131
+ if r5
132
+ r7 = _nt_type
133
+ s0 << r7
134
+ if r7
135
+ s8, i8 = [], index
136
+ loop do
137
+ r9 = _nt_space
138
+ if r9
139
+ s8 << r9
140
+ else
141
+ break
142
+ end
143
+ end
144
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
145
+ s0 << r8
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+ if s0.last
152
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
153
+ r0.extend(NamedTypeAnnotation0)
154
+ r0.extend(NamedTypeAnnotation1)
155
+ else
156
+ @index = i0
157
+ r0 = nil
158
+ end
159
+
160
+ node_cache[:named_type_annotation][start_index] = r0
161
+
162
+ r0
163
+ end
164
+
165
+ module NamedLiteralAnnotation0
166
+ def annotation_name
167
+ elements[1]
168
+ end
169
+
170
+ def literal
171
+ elements[4]
172
+ end
173
+
174
+ end
175
+
176
+ module NamedLiteralAnnotation1
177
+ def literal?
178
+ true
179
+ end
180
+
181
+ def literal
182
+ super.literal
183
+ end
184
+
185
+ def type?
186
+ false
187
+ end
188
+
189
+ def type
190
+ raise TypeError.new('This annotation is not a type. Call #type? first.')
191
+ end
192
+
193
+ def name
194
+ annotation_name.text_value
195
+ end
196
+ end
197
+
198
+ def _nt_named_literal_annotation
199
+ start_index = index
200
+ if node_cache[:named_literal_annotation].has_key?(index)
201
+ cached = node_cache[:named_literal_annotation][index]
202
+ if cached
203
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
204
+ @index = cached.interval.end
205
+ end
206
+ return cached
207
+ end
208
+
209
+ i0, s0 = index, []
210
+ s1, i1 = [], index
211
+ loop do
212
+ r2 = _nt_space
213
+ if r2
214
+ s1 << r2
215
+ else
216
+ break
217
+ end
218
+ end
219
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
220
+ s0 << r1
221
+ if r1
222
+ r3 = _nt_annotation_name
223
+ s0 << r3
224
+ if r3
225
+ if has_terminal?(':', false, index)
226
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
227
+ @index += 1
228
+ else
229
+ terminal_parse_failure(':')
230
+ r4 = nil
231
+ end
232
+ s0 << r4
233
+ if r4
234
+ s5, i5 = [], index
235
+ loop do
236
+ r6 = _nt_space
237
+ if r6
238
+ s5 << r6
239
+ else
240
+ break
241
+ end
242
+ end
243
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
244
+ s0 << r5
245
+ if r5
246
+ r7 = _nt_literal
247
+ s0 << r7
248
+ if r7
249
+ s8, i8 = [], index
250
+ loop do
251
+ r9 = _nt_space
252
+ if r9
253
+ s8 << r9
254
+ else
255
+ break
256
+ end
257
+ end
258
+ r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
259
+ s0 << r8
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
265
+ if s0.last
266
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
267
+ r0.extend(NamedLiteralAnnotation0)
268
+ r0.extend(NamedLiteralAnnotation1)
269
+ else
270
+ @index = i0
271
+ r0 = nil
272
+ end
273
+
274
+ node_cache[:named_literal_annotation][start_index] = r0
275
+
276
+ r0
277
+ end
278
+
279
+ module Literal0
280
+
281
+ def literal
282
+ false
283
+ end
284
+ end
285
+
286
+ module Literal1
287
+ def literal
288
+ true
289
+ end
290
+ end
291
+
292
+ module Literal2
293
+ def literal
294
+ nil
295
+ end
296
+ end
297
+
298
+ module Literal3
299
+ def literal
300
+ text_value.to_sym
301
+ end
302
+ end
303
+
304
+ def _nt_literal
305
+ start_index = index
306
+ if node_cache[:literal].has_key?(index)
307
+ cached = node_cache[:literal][index]
308
+ if cached
309
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
310
+ @index = cached.interval.end
311
+ end
312
+ return cached
313
+ end
314
+
315
+ i0 = index
316
+ if has_terminal?('false', false, index)
317
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 5))
318
+ r1.extend(Literal0)
319
+ @index += 5
320
+ else
321
+ terminal_parse_failure('false')
322
+ r1 = nil
323
+ end
324
+ if r1
325
+ r0 = r1
326
+ else
327
+ if has_terminal?('true', false, index)
328
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 4))
329
+ r2.extend(Literal1)
330
+ @index += 4
331
+ else
332
+ terminal_parse_failure('true')
333
+ r2 = nil
334
+ end
335
+ if r2
336
+ r0 = r2
337
+ else
338
+ if has_terminal?('nil', false, index)
339
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
340
+ r3.extend(Literal2)
341
+ @index += 3
342
+ else
343
+ terminal_parse_failure('nil')
344
+ r3 = nil
345
+ end
346
+ if r3
347
+ r0 = r3
348
+ else
349
+ i4 = index
350
+ if has_terminal?('never', false, index)
351
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 5))
352
+ @index += 5
353
+ else
354
+ terminal_parse_failure('never')
355
+ r5 = nil
356
+ end
357
+ if r5
358
+ r4 = r5
359
+ r4.extend(Literal3)
360
+ else
361
+ if has_terminal?('maybe', false, index)
362
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 5))
363
+ @index += 5
364
+ else
365
+ terminal_parse_failure('maybe')
366
+ r6 = nil
367
+ end
368
+ if r6
369
+ r4 = r6
370
+ r4.extend(Literal3)
371
+ else
372
+ if has_terminal?('always', false, index)
373
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 6))
374
+ @index += 6
375
+ else
376
+ terminal_parse_failure('always')
377
+ r7 = nil
378
+ end
379
+ if r7
380
+ r4 = r7
381
+ r4.extend(Literal3)
382
+ else
383
+ if has_terminal?('required', false, index)
384
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 8))
385
+ @index += 8
386
+ else
387
+ terminal_parse_failure('required')
388
+ r8 = nil
389
+ end
390
+ if r8
391
+ r4 = r8
392
+ r4.extend(Literal3)
393
+ else
394
+ if has_terminal?('optional', false, index)
395
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 8))
396
+ @index += 8
397
+ else
398
+ terminal_parse_failure('optional')
399
+ r9 = nil
400
+ end
401
+ if r9
402
+ r4 = r9
403
+ r4.extend(Literal3)
404
+ else
405
+ if has_terminal?('foolish', false, index)
406
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 7))
407
+ @index += 7
408
+ else
409
+ terminal_parse_failure('foolish')
410
+ r10 = nil
411
+ end
412
+ if r10
413
+ r4 = r10
414
+ r4.extend(Literal3)
415
+ else
416
+ if has_terminal?('ignored', false, index)
417
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 7))
418
+ @index += 7
419
+ else
420
+ terminal_parse_failure('ignored')
421
+ r11 = nil
422
+ end
423
+ if r11
424
+ r4 = r11
425
+ r4.extend(Literal3)
426
+ else
427
+ @index = i4
428
+ r4 = nil
429
+ end
430
+ end
431
+ end
432
+ end
433
+ end
434
+ end
435
+ end
436
+ if r4
437
+ r0 = r4
438
+ else
439
+ @index = i0
440
+ r0 = nil
441
+ end
442
+ end
443
+ end
444
+ end
445
+
446
+ node_cache[:literal][start_index] = r0
447
+
448
+ r0
449
+ end
450
+
451
+ def _nt_type
452
+ start_index = index
453
+ if node_cache[:type].has_key?(index)
454
+ cached = node_cache[:type][index]
455
+ if cached
456
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
457
+ @index = cached.interval.end
458
+ end
459
+ return cached
460
+ end
461
+
462
+ i0 = index
463
+ r1 = _nt_union_type
464
+ if r1
465
+ r0 = r1
466
+ else
467
+ r2 = _nt_non_union_type
468
+ if r2
469
+ r0 = r2
470
+ else
471
+ r3 = _nt_empty_type
472
+ if r3
473
+ r0 = r3
474
+ else
475
+ @index = i0
476
+ r0 = nil
477
+ end
478
+ end
479
+ end
480
+
481
+ node_cache[:type][start_index] = r0
482
+
483
+ r0
484
+ end
485
+
486
+ module UnionType0
487
+ def non_union_type
488
+ elements[3]
489
+ end
490
+ end
491
+
492
+ module UnionType1
493
+ def non_union_type
494
+ elements[0]
495
+ end
496
+
497
+ def rest_members
498
+ elements[1]
499
+ end
500
+ end
501
+
502
+ module UnionType2
503
+ def type
504
+ Types::UnionType.new([non_union_type, *rest_members].map(&:type))
505
+ end
506
+
507
+ def rest_members
508
+ super.elements.map(&:non_union_type)
509
+ end
510
+ end
511
+
512
+ def _nt_union_type
513
+ start_index = index
514
+ if node_cache[:union_type].has_key?(index)
515
+ cached = node_cache[:union_type][index]
516
+ if cached
517
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
518
+ @index = cached.interval.end
519
+ end
520
+ return cached
521
+ end
522
+
523
+ i0, s0 = index, []
524
+ r1 = _nt_non_union_type
525
+ s0 << r1
526
+ if r1
527
+ s2, i2 = [], index
528
+ loop do
529
+ i3, s3 = index, []
530
+ s4, i4 = [], index
531
+ loop do
532
+ r5 = _nt_space
533
+ if r5
534
+ s4 << r5
535
+ else
536
+ break
537
+ end
538
+ end
539
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
540
+ s3 << r4
541
+ if r4
542
+ if has_terminal?('|', false, index)
543
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
544
+ @index += 1
545
+ else
546
+ terminal_parse_failure('|')
547
+ r6 = nil
548
+ end
549
+ s3 << r6
550
+ if r6
551
+ s7, i7 = [], index
552
+ loop do
553
+ r8 = _nt_space
554
+ if r8
555
+ s7 << r8
556
+ else
557
+ break
558
+ end
559
+ end
560
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
561
+ s3 << r7
562
+ if r7
563
+ r9 = _nt_non_union_type
564
+ s3 << r9
565
+ end
566
+ end
567
+ end
568
+ if s3.last
569
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
570
+ r3.extend(UnionType0)
571
+ else
572
+ @index = i3
573
+ r3 = nil
574
+ end
575
+ if r3
576
+ s2 << r3
577
+ else
578
+ break
579
+ end
580
+ end
581
+ if s2.empty?
582
+ @index = i2
583
+ r2 = nil
584
+ else
585
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
586
+ end
587
+ s0 << r2
588
+ end
589
+ if s0.last
590
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
591
+ r0.extend(UnionType1)
592
+ r0.extend(UnionType2)
593
+ else
594
+ @index = i0
595
+ r0 = nil
596
+ end
597
+
598
+ node_cache[:union_type][start_index] = r0
599
+
600
+ r0
601
+ end
602
+
603
+ def _nt_non_union_type
604
+ start_index = index
605
+ if node_cache[:non_union_type].has_key?(index)
606
+ cached = node_cache[:non_union_type][index]
607
+ if cached
608
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
609
+ @index = cached.interval.end
610
+ end
611
+ return cached
612
+ end
613
+
614
+ i0 = index
615
+ r1 = _nt_top
616
+ if r1
617
+ r0 = r1
618
+ else
619
+ r2 = _nt_self_type
620
+ if r2
621
+ r0 = r2
622
+ else
623
+ r3 = _nt_function_type
624
+ if r3
625
+ r0 = r3
626
+ else
627
+ r4 = _nt_class_based_constraint
628
+ if r4
629
+ r0 = r4
630
+ else
631
+ r5 = _nt_structural_constraint
632
+ if r5
633
+ r0 = r5
634
+ else
635
+ @index = i0
636
+ r0 = nil
637
+ end
638
+ end
639
+ end
640
+ end
641
+ end
642
+
643
+ node_cache[:non_union_type][start_index] = r0
644
+
645
+ r0
646
+ end
647
+
648
+ module EmptyType0
649
+ def type
650
+ Types::EMPTY
651
+ end
652
+ end
653
+
654
+ def _nt_empty_type
655
+ start_index = index
656
+ if node_cache[:empty_type].has_key?(index)
657
+ cached = node_cache[:empty_type][index]
658
+ if cached
659
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
660
+ @index = cached.interval.end
661
+ end
662
+ return cached
663
+ end
664
+
665
+ if has_terminal?('empty', false, index)
666
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 5))
667
+ r0.extend(EmptyType0)
668
+ @index += 5
669
+ else
670
+ terminal_parse_failure('empty')
671
+ r0 = nil
672
+ end
673
+
674
+ node_cache[:empty_type][start_index] = r0
675
+
676
+ r0
677
+ end
678
+
679
+ module Top0
680
+ def type
681
+ []
682
+ end
683
+ end
684
+
685
+ def _nt_top
686
+ start_index = index
687
+ if node_cache[:top].has_key?(index)
688
+ cached = node_cache[:top][index]
689
+ if cached
690
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
691
+ @index = cached.interval.end
692
+ end
693
+ return cached
694
+ end
695
+
696
+ if has_terminal?("Top", false, index)
697
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 3))
698
+ r0.extend(Top0)
699
+ @index += 3
700
+ else
701
+ terminal_parse_failure("Top")
702
+ r0 = nil
703
+ end
704
+
705
+ node_cache[:top][start_index] = r0
706
+
707
+ r0
708
+ end
709
+
710
+ module SelfType0
711
+ def type
712
+ Types::SelfType.new
713
+ end
714
+ end
715
+
716
+ def _nt_self_type
717
+ start_index = index
718
+ if node_cache[:self_type].has_key?(index)
719
+ cached = node_cache[:self_type][index]
720
+ if cached
721
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
722
+ @index = cached.interval.end
723
+ end
724
+ return cached
725
+ end
726
+
727
+ if has_terminal?("self", false, index)
728
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 4))
729
+ r0.extend(SelfType0)
730
+ @index += 4
731
+ else
732
+ terminal_parse_failure("self")
733
+ r0 = nil
734
+ end
735
+
736
+ node_cache[:self_type][start_index] = r0
737
+
738
+ r0
739
+ end
740
+
741
+ end
742
+
743
+ class AnnotationParser < Treetop::Runtime::CompiledParser
744
+ include Annotation
745
+ end
746
+
747
+ end
748
+ end