laser 0.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/LICENSE +661 -0
- data/README.md +158 -0
- data/Rakefile +104 -0
- data/VERSION +1 -0
- data/bin/laser +7 -0
- data/design_docs/goals.md +57 -0
- data/design_docs/object_regex.md +426 -0
- data/design_docs/type_annotations.md +80 -0
- data/ext/laser/BasicBlock.cpp +572 -0
- data/ext/laser/BasicBlock.h +118 -0
- data/ext/laser/extconf.rb +3 -0
- data/features/laser.feature +25 -0
- data/features/step_definitions/laser_steps.rb +39 -0
- data/features/support/env.rb +14 -0
- data/features/support/testdata/1_input +1 -0
- data/features/support/testdata/1_output +1 -0
- data/features/support/testdata/2_input +4 -0
- data/features/support/testdata/2_output +4 -0
- data/features/support/testdata/3_input +8 -0
- data/features/support/testdata/3_output +11 -0
- data/features/support/testdata/4_input +5 -0
- data/features/support/testdata/4_output +5 -0
- data/features/support/testdata/5_input +13 -0
- data/laser.gemspec +382 -0
- data/lib/laser.rb +98 -0
- data/lib/laser/analysis/annotations.rb +95 -0
- data/lib/laser/analysis/annotations/annotation_config.yaml +3 -0
- data/lib/laser/analysis/annotations/comment_attachment_annotation.rb +66 -0
- data/lib/laser/analysis/annotations/node_pointers_annotation.rb +36 -0
- data/lib/laser/analysis/annotations/runtime_annotation.rb +55 -0
- data/lib/laser/analysis/argument_expansion.rb +132 -0
- data/lib/laser/analysis/arity.rb +34 -0
- data/lib/laser/analysis/bindings.rb +144 -0
- data/lib/laser/analysis/bootstrap/bootstrap.rb +298 -0
- data/lib/laser/analysis/bootstrap/laser_class.rb +106 -0
- data/lib/laser/analysis/bootstrap/laser_method.rb +255 -0
- data/lib/laser/analysis/bootstrap/laser_module.rb +403 -0
- data/lib/laser/analysis/bootstrap/laser_module_copy.rb +74 -0
- data/lib/laser/analysis/bootstrap/laser_object.rb +69 -0
- data/lib/laser/analysis/bootstrap/laser_proc.rb +150 -0
- data/lib/laser/analysis/bootstrap/laser_singleton_class.rb +44 -0
- data/lib/laser/analysis/comments.rb +35 -0
- data/lib/laser/analysis/control_flow.rb +28 -0
- data/lib/laser/analysis/control_flow/alias_analysis.rb +31 -0
- data/lib/laser/analysis/control_flow/basic_block.rb +105 -0
- data/lib/laser/analysis/control_flow/cfg_builder.rb +2505 -0
- data/lib/laser/analysis/control_flow/cfg_instruction.rb +190 -0
- data/lib/laser/analysis/control_flow/constant_propagation.rb +742 -0
- data/lib/laser/analysis/control_flow/control_flow_graph.rb +370 -0
- data/lib/laser/analysis/control_flow/lifetime_analysis.rb +91 -0
- data/lib/laser/analysis/control_flow/method_call_search.rb +26 -0
- data/lib/laser/analysis/control_flow/raise_properties.rb +25 -0
- data/lib/laser/analysis/control_flow/simulation.rb +385 -0
- data/lib/laser/analysis/control_flow/static_single_assignment.rb +185 -0
- data/lib/laser/analysis/control_flow/unreachability_analysis.rb +57 -0
- data/lib/laser/analysis/control_flow/unused_variables.rb +91 -0
- data/lib/laser/analysis/control_flow/yield_properties.rb +103 -0
- data/lib/laser/analysis/errors.rb +131 -0
- data/lib/laser/analysis/laser_utils.rb +18 -0
- data/lib/laser/analysis/lexical_analysis.rb +172 -0
- data/lib/laser/analysis/method_call.rb +68 -0
- data/lib/laser/analysis/protocol_registry.rb +30 -0
- data/lib/laser/analysis/scope.rb +118 -0
- data/lib/laser/analysis/sexp.rb +159 -0
- data/lib/laser/analysis/sexp_analysis.rb +40 -0
- data/lib/laser/analysis/sexp_extensions/constant_extraction.rb +115 -0
- data/lib/laser/analysis/sexp_extensions/source_location.rb +164 -0
- data/lib/laser/analysis/sexp_extensions/type_inference.rb +47 -0
- data/lib/laser/analysis/signature.rb +76 -0
- data/lib/laser/analysis/special_methods/send.rb +67 -0
- data/lib/laser/analysis/unused_methods.rb +21 -0
- data/lib/laser/analysis/visitor.rb +141 -0
- data/lib/laser/annotation_parser/annotations.treetop +126 -0
- data/lib/laser/annotation_parser/annotations_parser.rb +748 -0
- data/lib/laser/annotation_parser/class_annotations.treetop +82 -0
- data/lib/laser/annotation_parser/class_annotations_parser.rb +654 -0
- data/lib/laser/annotation_parser/overload.treetop +24 -0
- data/lib/laser/annotation_parser/overload_parser.rb +167 -0
- data/lib/laser/annotation_parser/parsers.rb +6 -0
- data/lib/laser/annotation_parser/structural.treetop +37 -0
- data/lib/laser/annotation_parser/structural_parser.rb +406 -0
- data/lib/laser/annotation_parser/useful_parsers.treetop +47 -0
- data/lib/laser/annotation_parser/useful_parsers_parser.rb +674 -0
- data/lib/laser/rake/task.rb +46 -0
- data/lib/laser/runner.rb +189 -0
- data/lib/laser/scanner.rb +169 -0
- data/lib/laser/standard_library/_thread.rb +110 -0
- data/lib/laser/standard_library/abbrev.rb +103 -0
- data/lib/laser/standard_library/array.rb +418 -0
- data/lib/laser/standard_library/base64.rb +91 -0
- data/lib/laser/standard_library/basic_object.rb +55 -0
- data/lib/laser/standard_library/benchmark.rb +556 -0
- data/lib/laser/standard_library/bignum.rb +185 -0
- data/lib/laser/standard_library/cgi.rb +275 -0
- data/lib/laser/standard_library/cgi/cookie.rb +147 -0
- data/lib/laser/standard_library/cgi/core.rb +791 -0
- data/lib/laser/standard_library/cgi/html.rb +1021 -0
- data/lib/laser/standard_library/cgi/session.rb +537 -0
- data/lib/laser/standard_library/cgi/session/pstore.rb +111 -0
- data/lib/laser/standard_library/cgi/util.rb +188 -0
- data/lib/laser/standard_library/class_definitions.rb +333 -0
- data/lib/laser/standard_library/comparable.rb +125 -0
- data/lib/laser/standard_library/complex.rb +162 -0
- data/lib/laser/standard_library/enumerable.rb +178 -0
- data/lib/laser/standard_library/exceptions.rb +135 -0
- data/lib/laser/standard_library/fixnum.rb +188 -0
- data/lib/laser/standard_library/float.rb +180 -0
- data/lib/laser/standard_library/hash.rb +237 -0
- data/lib/laser/standard_library/integer.rb +123 -0
- data/lib/laser/standard_library/laser_magic.rb +7 -0
- data/lib/laser/standard_library/nil_false_true.rb +113 -0
- data/lib/laser/standard_library/numbers.rb +192 -0
- data/lib/laser/standard_library/proc.rb +31 -0
- data/lib/laser/standard_library/set.rb +1348 -0
- data/lib/laser/standard_library/string.rb +666 -0
- data/lib/laser/standard_library/stringio.rb +2 -0
- data/lib/laser/standard_library/symbol.rb +125 -0
- data/lib/laser/standard_library/tsort.rb +242 -0
- data/lib/laser/support/acts_as_struct.rb +66 -0
- data/lib/laser/support/frequency.rb +55 -0
- data/lib/laser/support/inheritable_attributes.rb +145 -0
- data/lib/laser/support/module_extensions.rb +94 -0
- data/lib/laser/support/placeholder_object.rb +13 -0
- data/lib/laser/third_party/rgl/adjacency.rb +221 -0
- data/lib/laser/third_party/rgl/base.rb +228 -0
- data/lib/laser/third_party/rgl/bidirectional.rb +39 -0
- data/lib/laser/third_party/rgl/condensation.rb +47 -0
- data/lib/laser/third_party/rgl/connected_components.rb +138 -0
- data/lib/laser/third_party/rgl/control_flow.rb +170 -0
- data/lib/laser/third_party/rgl/depth_first_spanning_tree.rb +37 -0
- data/lib/laser/third_party/rgl/dominators.rb +124 -0
- data/lib/laser/third_party/rgl/dot.rb +93 -0
- data/lib/laser/third_party/rgl/graphxml.rb +51 -0
- data/lib/laser/third_party/rgl/implicit.rb +174 -0
- data/lib/laser/third_party/rgl/mutable.rb +117 -0
- data/lib/laser/third_party/rgl/rdot.rb +445 -0
- data/lib/laser/third_party/rgl/topsort.rb +72 -0
- data/lib/laser/third_party/rgl/transitivity.rb +180 -0
- data/lib/laser/third_party/rgl/traversal.rb +348 -0
- data/lib/laser/types/types.rb +433 -0
- data/lib/laser/version.rb +14 -0
- data/lib/laser/warning.rb +149 -0
- data/lib/laser/warning_sets/default.yml +13 -0
- data/lib/laser/warnings/assignment_in_condition.rb +20 -0
- data/lib/laser/warnings/comment_spacing.rb +31 -0
- data/lib/laser/warnings/extra_blank_lines.rb +30 -0
- data/lib/laser/warnings/extra_whitespace.rb +16 -0
- data/lib/laser/warnings/hash_symbol_18_warning.rb +63 -0
- data/lib/laser/warnings/hash_symbol_19_warning.rb +29 -0
- data/lib/laser/warnings/line_length.rb +115 -0
- data/lib/laser/warnings/misaligned_unindentation.rb +17 -0
- data/lib/laser/warnings/operator_spacing.rb +68 -0
- data/lib/laser/warnings/parens_on_declaration.rb +30 -0
- data/lib/laser/warnings/rescue_exception.rb +42 -0
- data/lib/laser/warnings/semicolon.rb +25 -0
- data/lib/laser/warnings/sexp_errors.rb +24 -0
- data/lib/laser/warnings/uncalled_method_warning.rb +7 -0
- data/lib/laser/warnings/useless_double_quotes.rb +38 -0
- data/spec/analysis_specs/annotations_spec.rb +47 -0
- data/spec/analysis_specs/annotations_specs/comment_attachment_spec.rb +68 -0
- data/spec/analysis_specs/annotations_specs/node_pointers_annotation_spec.rb +90 -0
- data/spec/analysis_specs/annotations_specs/runtime_annotation_spec.rb +135 -0
- data/spec/analysis_specs/annotations_specs/spec_helper.rb +33 -0
- data/spec/analysis_specs/argument_expansion_spec.rb +113 -0
- data/spec/analysis_specs/bindings_spec.rb +36 -0
- data/spec/analysis_specs/comment_spec.rb +93 -0
- data/spec/analysis_specs/control_flow_specs/cfg_instruction_spec.rb +111 -0
- data/spec/analysis_specs/control_flow_specs/constant_propagation_spec.rb +560 -0
- data/spec/analysis_specs/control_flow_specs/control_flow_graph_spec.rb +5 -0
- data/spec/analysis_specs/control_flow_specs/raise_properties_spec.rb +310 -0
- data/spec/analysis_specs/control_flow_specs/raise_type_inference_spec.rb +301 -0
- data/spec/analysis_specs/control_flow_specs/return_type_inference_spec.rb +431 -0
- data/spec/analysis_specs/control_flow_specs/simulation_spec.rb +158 -0
- data/spec/analysis_specs/control_flow_specs/spec_helper.rb +110 -0
- data/spec/analysis_specs/control_flow_specs/tuple_misuse_inference_spec.rb +125 -0
- data/spec/analysis_specs/control_flow_specs/unreachability_analysis_spec.rb +76 -0
- data/spec/analysis_specs/control_flow_specs/unused_variable_spec.rb +99 -0
- data/spec/analysis_specs/control_flow_specs/yield_properties_spec.rb +372 -0
- data/spec/analysis_specs/error_spec.rb +30 -0
- data/spec/analysis_specs/laser_class_spec.rb +322 -0
- data/spec/analysis_specs/lexical_analysis_spec.rb +184 -0
- data/spec/analysis_specs/protocol_registry_spec.rb +63 -0
- data/spec/analysis_specs/scope_annotation_spec.rb +1013 -0
- data/spec/analysis_specs/scope_spec.rb +126 -0
- data/spec/analysis_specs/sexp_analysis_spec.rb +30 -0
- data/spec/analysis_specs/sexp_extension_specs/constant_extraction_spec.rb +309 -0
- data/spec/analysis_specs/sexp_extension_specs/source_location_spec.rb +231 -0
- data/spec/analysis_specs/sexp_extension_specs/spec_helper.rb +1 -0
- data/spec/analysis_specs/sexp_extension_specs/type_inference_spec.rb +252 -0
- data/spec/analysis_specs/sexp_spec.rb +167 -0
- data/spec/analysis_specs/spec_helper.rb +27 -0
- data/spec/analysis_specs/unused_methods_spec.rb +65 -0
- data/spec/analysis_specs/visitor_spec.rb +64 -0
- data/spec/annotation_parser_specs/annotations_parser_spec.rb +89 -0
- data/spec/annotation_parser_specs/class_annotation_parser_spec.rb +120 -0
- data/spec/annotation_parser_specs/overload_parser_spec.rb +39 -0
- data/spec/annotation_parser_specs/parsers_spec.rb +14 -0
- data/spec/annotation_parser_specs/spec_helper.rb +1 -0
- data/spec/annotation_parser_specs/structural_parser_spec.rb +67 -0
- data/spec/laser_spec.rb +14 -0
- data/spec/rake_specs/spec_helper.rb +1 -0
- data/spec/rake_specs/task_spec.rb +67 -0
- data/spec/runner_spec.rb +207 -0
- data/spec/scanner_spec.rb +75 -0
- data/spec/spec_helper.rb +121 -0
- data/spec/standard_library/exceptions_spec.rb +19 -0
- data/spec/standard_library/globals_spec.rb +14 -0
- data/spec/standard_library/set_spec.rb +31 -0
- data/spec/standard_library/spec_helper.rb +1 -0
- data/spec/standard_library/standard_library_spec.rb +302 -0
- data/spec/support_specs/acts_as_struct_spec.rb +94 -0
- data/spec/support_specs/frequency_spec.rb +23 -0
- data/spec/support_specs/module_extensions_spec.rb +117 -0
- data/spec/support_specs/spec_helper.rb +1 -0
- data/spec/type_specs/spec_helper.rb +1 -0
- data/spec/type_specs/types_spec.rb +133 -0
- data/spec/warning_spec.rb +95 -0
- data/spec/warning_specs/assignment_in_condition_spec.rb +68 -0
- data/spec/warning_specs/comment_spacing_spec.rb +65 -0
- data/spec/warning_specs/extra_blank_lines_spec.rb +70 -0
- data/spec/warning_specs/extra_whitespace_spec.rb +33 -0
- data/spec/warning_specs/hash_symbol_18_warning_spec.rb +89 -0
- data/spec/warning_specs/hash_symbol_19_warning_spec.rb +63 -0
- data/spec/warning_specs/line_length_spec.rb +173 -0
- data/spec/warning_specs/misaligned_unindentation_spec.rb +35 -0
- data/spec/warning_specs/operator_spacing_spec.rb +104 -0
- data/spec/warning_specs/parens_on_declaration_spec.rb +57 -0
- data/spec/warning_specs/rescue_exception_spec.rb +105 -0
- data/spec/warning_specs/semicolon_spec.rb +58 -0
- data/spec/warning_specs/spec_helper.rb +1 -0
- data/spec/warning_specs/useless_double_quotes_spec.rb +74 -0
- data/status_reports/2010/12/2010-12-14.md +163 -0
- data/status_reports/2010/12/2010-12-23.md +298 -0
- data/status_reports/2010/12/2010-12-24.md +6 -0
- data/test/third_party_tests/rgl_tests/TestComponents.rb +65 -0
- data/test/third_party_tests/rgl_tests/TestCycles.rb +61 -0
- data/test/third_party_tests/rgl_tests/TestDirectedGraph.rb +125 -0
- data/test/third_party_tests/rgl_tests/TestDot.rb +18 -0
- data/test/third_party_tests/rgl_tests/TestEdge.rb +34 -0
- data/test/third_party_tests/rgl_tests/TestGraph.rb +71 -0
- data/test/third_party_tests/rgl_tests/TestGraphXML.rb +57 -0
- data/test/third_party_tests/rgl_tests/TestImplicit.rb +52 -0
- data/test/third_party_tests/rgl_tests/TestRdot.rb +863 -0
- data/test/third_party_tests/rgl_tests/TestTransitivity.rb +129 -0
- data/test/third_party_tests/rgl_tests/TestTraversal.rb +220 -0
- data/test/third_party_tests/rgl_tests/TestUnDirectedGraph.rb +102 -0
- data/test/third_party_tests/rgl_tests/examples/north/Graph.log +128 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.0.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.1.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.11.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.12.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.13.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.14.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.15.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.16.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.17.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.19.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.2.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.20.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.22.graphml +43 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.24.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.25.graphml +45 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.27.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.28.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.29.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.3.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.30.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.31.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.34.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.37.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.38.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.39.graphml +36 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.4.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.40.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.41.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.42.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.45.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.46.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.5.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.50.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.56.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.57.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.58.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.6.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.60.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.61.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.62.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.68.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.69.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.7.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.70.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.71.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.72.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.74.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.75.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.78.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.79.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.8.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.80.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.82.graphml +35 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.83.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.85.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.86.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.88.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.89.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.9.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.90.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.91.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.92.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.93.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.94.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.12.8.graphml +40 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.14.9.graphml +36 -0
- data/test/third_party_tests/rgl_tests/test_helper.rb +7 -0
- data/test/third_party_tests/test_inheritable_attributes.rb +187 -0
- metadata +470 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'laser/annotation_parser/useful_parsers_parser'
|
2
|
+
module Laser
|
3
|
+
module Parsers
|
4
|
+
grammar Overload
|
5
|
+
include GeneralPurpose
|
6
|
+
rule function_type
|
7
|
+
parenthesized_type_list space* '->' space* return_type:type {
|
8
|
+
def type
|
9
|
+
result = Types::GenericType.new(
|
10
|
+
Types::PROC,
|
11
|
+
[Types::TupleType.new(parenthesized_type_list.all_types), return_type.type])
|
12
|
+
end
|
13
|
+
} / parenthesized_type_list space* return_type:type {
|
14
|
+
def type
|
15
|
+
result = Types::GenericType.new(
|
16
|
+
Types::PROC,
|
17
|
+
[Types::TupleType.new(parenthesized_type_list.all_types), return_type.type])
|
18
|
+
end
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
require 'laser/annotation_parser/useful_parsers_parser'
|
5
|
+
module Laser
|
6
|
+
module Parsers
|
7
|
+
module Overload
|
8
|
+
include Treetop::Runtime
|
9
|
+
|
10
|
+
def root
|
11
|
+
@root ||= :function_type
|
12
|
+
end
|
13
|
+
|
14
|
+
include GeneralPurpose
|
15
|
+
|
16
|
+
module FunctionType0
|
17
|
+
def parenthesized_type_list
|
18
|
+
elements[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
def return_type
|
22
|
+
elements[4]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module FunctionType1
|
27
|
+
def type
|
28
|
+
result = Types::GenericType.new(
|
29
|
+
Types::PROC,
|
30
|
+
[Types::TupleType.new(parenthesized_type_list.all_types), return_type.type])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module FunctionType2
|
35
|
+
def parenthesized_type_list
|
36
|
+
elements[0]
|
37
|
+
end
|
38
|
+
|
39
|
+
def return_type
|
40
|
+
elements[2]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module FunctionType3
|
45
|
+
def type
|
46
|
+
result = Types::GenericType.new(
|
47
|
+
Types::PROC,
|
48
|
+
[Types::TupleType.new(parenthesized_type_list.all_types), return_type.type])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _nt_function_type
|
53
|
+
start_index = index
|
54
|
+
if node_cache[:function_type].has_key?(index)
|
55
|
+
cached = node_cache[:function_type][index]
|
56
|
+
if cached
|
57
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
58
|
+
@index = cached.interval.end
|
59
|
+
end
|
60
|
+
return cached
|
61
|
+
end
|
62
|
+
|
63
|
+
i0 = index
|
64
|
+
i1, s1 = index, []
|
65
|
+
r2 = _nt_parenthesized_type_list
|
66
|
+
s1 << r2
|
67
|
+
if r2
|
68
|
+
s3, i3 = [], index
|
69
|
+
loop do
|
70
|
+
r4 = _nt_space
|
71
|
+
if r4
|
72
|
+
s3 << r4
|
73
|
+
else
|
74
|
+
break
|
75
|
+
end
|
76
|
+
end
|
77
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
78
|
+
s1 << r3
|
79
|
+
if r3
|
80
|
+
if has_terminal?('->', false, index)
|
81
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
82
|
+
@index += 2
|
83
|
+
else
|
84
|
+
terminal_parse_failure('->')
|
85
|
+
r5 = nil
|
86
|
+
end
|
87
|
+
s1 << r5
|
88
|
+
if r5
|
89
|
+
s6, i6 = [], index
|
90
|
+
loop do
|
91
|
+
r7 = _nt_space
|
92
|
+
if r7
|
93
|
+
s6 << r7
|
94
|
+
else
|
95
|
+
break
|
96
|
+
end
|
97
|
+
end
|
98
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
99
|
+
s1 << r6
|
100
|
+
if r6
|
101
|
+
r8 = _nt_type
|
102
|
+
s1 << r8
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
if s1.last
|
108
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
109
|
+
r1.extend(FunctionType0)
|
110
|
+
r1.extend(FunctionType1)
|
111
|
+
else
|
112
|
+
@index = i1
|
113
|
+
r1 = nil
|
114
|
+
end
|
115
|
+
if r1
|
116
|
+
r0 = r1
|
117
|
+
else
|
118
|
+
i9, s9 = index, []
|
119
|
+
r10 = _nt_parenthesized_type_list
|
120
|
+
s9 << r10
|
121
|
+
if r10
|
122
|
+
s11, i11 = [], index
|
123
|
+
loop do
|
124
|
+
r12 = _nt_space
|
125
|
+
if r12
|
126
|
+
s11 << r12
|
127
|
+
else
|
128
|
+
break
|
129
|
+
end
|
130
|
+
end
|
131
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
132
|
+
s9 << r11
|
133
|
+
if r11
|
134
|
+
r13 = _nt_type
|
135
|
+
s9 << r13
|
136
|
+
end
|
137
|
+
end
|
138
|
+
if s9.last
|
139
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
140
|
+
r9.extend(FunctionType2)
|
141
|
+
r9.extend(FunctionType3)
|
142
|
+
else
|
143
|
+
@index = i9
|
144
|
+
r9 = nil
|
145
|
+
end
|
146
|
+
if r9
|
147
|
+
r0 = r9
|
148
|
+
else
|
149
|
+
@index = i0
|
150
|
+
r0 = nil
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
node_cache[:function_type][start_index] = r0
|
155
|
+
|
156
|
+
r0
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
class OverloadParser < Treetop::Runtime::CompiledParser
|
162
|
+
include Overload
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'laser/annotation_parser/useful_parsers_parser'
|
2
|
+
module Laser
|
3
|
+
module Parsers
|
4
|
+
grammar Structural
|
5
|
+
include GeneralPurpose
|
6
|
+
rule structural_constraint
|
7
|
+
'#' method_name space* parenthesized_type_list space* '->' space* return_type:type {
|
8
|
+
def type
|
9
|
+
result = Types::StructuralType.new(
|
10
|
+
method_name.text_value, parenthesized_type_list.all_types,
|
11
|
+
return_type.type)
|
12
|
+
end
|
13
|
+
} / '#' method_name space* parenthesized_type_list space* return_type:type {
|
14
|
+
def type
|
15
|
+
result = Types::StructuralType.new(
|
16
|
+
method_name.text_value, parenthesized_type_list.all_types,
|
17
|
+
return_type.type)
|
18
|
+
end
|
19
|
+
} / '#' method_name space* parenthesized_type_list {
|
20
|
+
def type
|
21
|
+
result = Types::StructuralType.new(
|
22
|
+
method_name.text_value, parenthesized_type_list.all_types, [])
|
23
|
+
end
|
24
|
+
} / '#' method_name space* '->' space* return_type:type {
|
25
|
+
def type
|
26
|
+
result = Types::StructuralType.new(
|
27
|
+
method_name.text_value, [], return_type.type)
|
28
|
+
end
|
29
|
+
} / '#' method_name {
|
30
|
+
def type
|
31
|
+
result = Types::StructuralType.new(method_name.text_value, [], [])
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,406 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
require 'laser/annotation_parser/useful_parsers_parser'
|
5
|
+
module Laser
|
6
|
+
module Parsers
|
7
|
+
module Structural
|
8
|
+
include Treetop::Runtime
|
9
|
+
|
10
|
+
def root
|
11
|
+
@root ||= :structural_constraint
|
12
|
+
end
|
13
|
+
|
14
|
+
include GeneralPurpose
|
15
|
+
|
16
|
+
module StructuralConstraint0
|
17
|
+
def method_name
|
18
|
+
elements[1]
|
19
|
+
end
|
20
|
+
|
21
|
+
def parenthesized_type_list
|
22
|
+
elements[3]
|
23
|
+
end
|
24
|
+
|
25
|
+
def return_type
|
26
|
+
elements[7]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module StructuralConstraint1
|
31
|
+
def type
|
32
|
+
result = Types::StructuralType.new(
|
33
|
+
method_name.text_value, parenthesized_type_list.all_types,
|
34
|
+
return_type.type)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module StructuralConstraint2
|
39
|
+
def method_name
|
40
|
+
elements[1]
|
41
|
+
end
|
42
|
+
|
43
|
+
def parenthesized_type_list
|
44
|
+
elements[3]
|
45
|
+
end
|
46
|
+
|
47
|
+
def return_type
|
48
|
+
elements[5]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module StructuralConstraint3
|
53
|
+
def type
|
54
|
+
result = Types::StructuralType.new(
|
55
|
+
method_name.text_value, parenthesized_type_list.all_types,
|
56
|
+
return_type.type)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
module StructuralConstraint4
|
61
|
+
def method_name
|
62
|
+
elements[1]
|
63
|
+
end
|
64
|
+
|
65
|
+
def parenthesized_type_list
|
66
|
+
elements[3]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module StructuralConstraint5
|
71
|
+
def type
|
72
|
+
result = Types::StructuralType.new(
|
73
|
+
method_name.text_value, parenthesized_type_list.all_types, [])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
module StructuralConstraint6
|
78
|
+
def method_name
|
79
|
+
elements[1]
|
80
|
+
end
|
81
|
+
|
82
|
+
def return_type
|
83
|
+
elements[5]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
module StructuralConstraint7
|
88
|
+
def type
|
89
|
+
result = Types::StructuralType.new(
|
90
|
+
method_name.text_value, [], return_type.type)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module StructuralConstraint8
|
95
|
+
def method_name
|
96
|
+
elements[1]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
module StructuralConstraint9
|
101
|
+
def type
|
102
|
+
result = Types::StructuralType.new(method_name.text_value, [], [])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def _nt_structural_constraint
|
107
|
+
start_index = index
|
108
|
+
if node_cache[:structural_constraint].has_key?(index)
|
109
|
+
cached = node_cache[:structural_constraint][index]
|
110
|
+
if cached
|
111
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
112
|
+
@index = cached.interval.end
|
113
|
+
end
|
114
|
+
return cached
|
115
|
+
end
|
116
|
+
|
117
|
+
i0 = index
|
118
|
+
i1, s1 = index, []
|
119
|
+
if has_terminal?('#', false, index)
|
120
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
121
|
+
@index += 1
|
122
|
+
else
|
123
|
+
terminal_parse_failure('#')
|
124
|
+
r2 = nil
|
125
|
+
end
|
126
|
+
s1 << r2
|
127
|
+
if r2
|
128
|
+
r3 = _nt_method_name
|
129
|
+
s1 << r3
|
130
|
+
if r3
|
131
|
+
s4, i4 = [], index
|
132
|
+
loop do
|
133
|
+
r5 = _nt_space
|
134
|
+
if r5
|
135
|
+
s4 << r5
|
136
|
+
else
|
137
|
+
break
|
138
|
+
end
|
139
|
+
end
|
140
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
141
|
+
s1 << r4
|
142
|
+
if r4
|
143
|
+
r6 = _nt_parenthesized_type_list
|
144
|
+
s1 << r6
|
145
|
+
if r6
|
146
|
+
s7, i7 = [], index
|
147
|
+
loop do
|
148
|
+
r8 = _nt_space
|
149
|
+
if r8
|
150
|
+
s7 << r8
|
151
|
+
else
|
152
|
+
break
|
153
|
+
end
|
154
|
+
end
|
155
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
156
|
+
s1 << r7
|
157
|
+
if r7
|
158
|
+
if has_terminal?('->', false, index)
|
159
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
160
|
+
@index += 2
|
161
|
+
else
|
162
|
+
terminal_parse_failure('->')
|
163
|
+
r9 = nil
|
164
|
+
end
|
165
|
+
s1 << r9
|
166
|
+
if r9
|
167
|
+
s10, i10 = [], index
|
168
|
+
loop do
|
169
|
+
r11 = _nt_space
|
170
|
+
if r11
|
171
|
+
s10 << r11
|
172
|
+
else
|
173
|
+
break
|
174
|
+
end
|
175
|
+
end
|
176
|
+
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
177
|
+
s1 << r10
|
178
|
+
if r10
|
179
|
+
r12 = _nt_type
|
180
|
+
s1 << r12
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
if s1.last
|
189
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
190
|
+
r1.extend(StructuralConstraint0)
|
191
|
+
r1.extend(StructuralConstraint1)
|
192
|
+
else
|
193
|
+
@index = i1
|
194
|
+
r1 = nil
|
195
|
+
end
|
196
|
+
if r1
|
197
|
+
r0 = r1
|
198
|
+
else
|
199
|
+
i13, s13 = index, []
|
200
|
+
if has_terminal?('#', false, index)
|
201
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
202
|
+
@index += 1
|
203
|
+
else
|
204
|
+
terminal_parse_failure('#')
|
205
|
+
r14 = nil
|
206
|
+
end
|
207
|
+
s13 << r14
|
208
|
+
if r14
|
209
|
+
r15 = _nt_method_name
|
210
|
+
s13 << r15
|
211
|
+
if r15
|
212
|
+
s16, i16 = [], index
|
213
|
+
loop do
|
214
|
+
r17 = _nt_space
|
215
|
+
if r17
|
216
|
+
s16 << r17
|
217
|
+
else
|
218
|
+
break
|
219
|
+
end
|
220
|
+
end
|
221
|
+
r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
|
222
|
+
s13 << r16
|
223
|
+
if r16
|
224
|
+
r18 = _nt_parenthesized_type_list
|
225
|
+
s13 << r18
|
226
|
+
if r18
|
227
|
+
s19, i19 = [], index
|
228
|
+
loop do
|
229
|
+
r20 = _nt_space
|
230
|
+
if r20
|
231
|
+
s19 << r20
|
232
|
+
else
|
233
|
+
break
|
234
|
+
end
|
235
|
+
end
|
236
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
237
|
+
s13 << r19
|
238
|
+
if r19
|
239
|
+
r21 = _nt_type
|
240
|
+
s13 << r21
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
if s13.last
|
247
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
248
|
+
r13.extend(StructuralConstraint2)
|
249
|
+
r13.extend(StructuralConstraint3)
|
250
|
+
else
|
251
|
+
@index = i13
|
252
|
+
r13 = nil
|
253
|
+
end
|
254
|
+
if r13
|
255
|
+
r0 = r13
|
256
|
+
else
|
257
|
+
i22, s22 = index, []
|
258
|
+
if has_terminal?('#', false, index)
|
259
|
+
r23 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
260
|
+
@index += 1
|
261
|
+
else
|
262
|
+
terminal_parse_failure('#')
|
263
|
+
r23 = nil
|
264
|
+
end
|
265
|
+
s22 << r23
|
266
|
+
if r23
|
267
|
+
r24 = _nt_method_name
|
268
|
+
s22 << r24
|
269
|
+
if r24
|
270
|
+
s25, i25 = [], index
|
271
|
+
loop do
|
272
|
+
r26 = _nt_space
|
273
|
+
if r26
|
274
|
+
s25 << r26
|
275
|
+
else
|
276
|
+
break
|
277
|
+
end
|
278
|
+
end
|
279
|
+
r25 = instantiate_node(SyntaxNode,input, i25...index, s25)
|
280
|
+
s22 << r25
|
281
|
+
if r25
|
282
|
+
r27 = _nt_parenthesized_type_list
|
283
|
+
s22 << r27
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
if s22.last
|
288
|
+
r22 = instantiate_node(SyntaxNode,input, i22...index, s22)
|
289
|
+
r22.extend(StructuralConstraint4)
|
290
|
+
r22.extend(StructuralConstraint5)
|
291
|
+
else
|
292
|
+
@index = i22
|
293
|
+
r22 = nil
|
294
|
+
end
|
295
|
+
if r22
|
296
|
+
r0 = r22
|
297
|
+
else
|
298
|
+
i28, s28 = index, []
|
299
|
+
if has_terminal?('#', false, index)
|
300
|
+
r29 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
301
|
+
@index += 1
|
302
|
+
else
|
303
|
+
terminal_parse_failure('#')
|
304
|
+
r29 = nil
|
305
|
+
end
|
306
|
+
s28 << r29
|
307
|
+
if r29
|
308
|
+
r30 = _nt_method_name
|
309
|
+
s28 << r30
|
310
|
+
if r30
|
311
|
+
s31, i31 = [], index
|
312
|
+
loop do
|
313
|
+
r32 = _nt_space
|
314
|
+
if r32
|
315
|
+
s31 << r32
|
316
|
+
else
|
317
|
+
break
|
318
|
+
end
|
319
|
+
end
|
320
|
+
r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
|
321
|
+
s28 << r31
|
322
|
+
if r31
|
323
|
+
if has_terminal?('->', false, index)
|
324
|
+
r33 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
325
|
+
@index += 2
|
326
|
+
else
|
327
|
+
terminal_parse_failure('->')
|
328
|
+
r33 = nil
|
329
|
+
end
|
330
|
+
s28 << r33
|
331
|
+
if r33
|
332
|
+
s34, i34 = [], index
|
333
|
+
loop do
|
334
|
+
r35 = _nt_space
|
335
|
+
if r35
|
336
|
+
s34 << r35
|
337
|
+
else
|
338
|
+
break
|
339
|
+
end
|
340
|
+
end
|
341
|
+
r34 = instantiate_node(SyntaxNode,input, i34...index, s34)
|
342
|
+
s28 << r34
|
343
|
+
if r34
|
344
|
+
r36 = _nt_type
|
345
|
+
s28 << r36
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
if s28.last
|
352
|
+
r28 = instantiate_node(SyntaxNode,input, i28...index, s28)
|
353
|
+
r28.extend(StructuralConstraint6)
|
354
|
+
r28.extend(StructuralConstraint7)
|
355
|
+
else
|
356
|
+
@index = i28
|
357
|
+
r28 = nil
|
358
|
+
end
|
359
|
+
if r28
|
360
|
+
r0 = r28
|
361
|
+
else
|
362
|
+
i37, s37 = index, []
|
363
|
+
if has_terminal?('#', false, index)
|
364
|
+
r38 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
365
|
+
@index += 1
|
366
|
+
else
|
367
|
+
terminal_parse_failure('#')
|
368
|
+
r38 = nil
|
369
|
+
end
|
370
|
+
s37 << r38
|
371
|
+
if r38
|
372
|
+
r39 = _nt_method_name
|
373
|
+
s37 << r39
|
374
|
+
end
|
375
|
+
if s37.last
|
376
|
+
r37 = instantiate_node(SyntaxNode,input, i37...index, s37)
|
377
|
+
r37.extend(StructuralConstraint8)
|
378
|
+
r37.extend(StructuralConstraint9)
|
379
|
+
else
|
380
|
+
@index = i37
|
381
|
+
r37 = nil
|
382
|
+
end
|
383
|
+
if r37
|
384
|
+
r0 = r37
|
385
|
+
else
|
386
|
+
@index = i0
|
387
|
+
r0 = nil
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
node_cache[:structural_constraint][start_index] = r0
|
395
|
+
|
396
|
+
r0
|
397
|
+
end
|
398
|
+
|
399
|
+
end
|
400
|
+
|
401
|
+
class StructuralParser < Treetop::Runtime::CompiledParser
|
402
|
+
include Structural
|
403
|
+
end
|
404
|
+
|
405
|
+
end
|
406
|
+
end
|