bel_parser 1.0.0.alpha.27-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemspec-java +32 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +191 -0
- data/README.md +20 -0
- data/VERSION +1 -0
- data/bin/bel2_validator +62 -0
- data/bin/bel_script_reader +132 -0
- data/lib/bel/translator/plugins/bel_script.rb +38 -0
- data/lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb +125 -0
- data/lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb +109 -0
- data/lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb +100 -0
- data/lib/bel/translator/plugins/bel_script/nanopub_serialization.rb +79 -0
- data/lib/bel/translator/plugins/bel_script/reader.rb +39 -0
- data/lib/bel/translator/plugins/bel_script/translator.rb +37 -0
- data/lib/bel/translator/plugins/bel_script/writer.rb +180 -0
- data/lib/bel_parser.rb +23 -0
- data/lib/bel_parser/ast_filter.rb +44 -0
- data/lib/bel_parser/ast_generator.rb +83 -0
- data/lib/bel_parser/expression.rb +3 -0
- data/lib/bel_parser/expression/filter.rb +31 -0
- data/lib/bel_parser/expression/parser.rb +72 -0
- data/lib/bel_parser/expression/validator.rb +79 -0
- data/lib/bel_parser/language.rb +114 -0
- data/lib/bel_parser/language/amino_acid.rb +68 -0
- data/lib/bel_parser/language/apply_namespace_encoding.rb +98 -0
- data/lib/bel_parser/language/base_specification.rb +82 -0
- data/lib/bel_parser/language/covalent_protein_modification.rb +56 -0
- data/lib/bel_parser/language/expression_validator.rb +68 -0
- data/lib/bel_parser/language/function.rb +67 -0
- data/lib/bel_parser/language/relationship.rb +102 -0
- data/lib/bel_parser/language/semantics.rb +40 -0
- data/lib/bel_parser/language/semantics/deeply_nested_statement.rb +65 -0
- data/lib/bel_parser/language/semantics/function_deprecation.rb +43 -0
- data/lib/bel_parser/language/semantics/list_function_subject.rb +45 -0
- data/lib/bel_parser/language/semantics/multiple_subject_object.rb +55 -0
- data/lib/bel_parser/language/semantics/non_causal_nested_statement.rb +50 -0
- data/lib/bel_parser/language/semantics/non_object_list.rb +56 -0
- data/lib/bel_parser/language/semantics/relationship_deprecation.rb +44 -0
- data/lib/bel_parser/language/semantics/relationship_not_listable.rb +60 -0
- data/lib/bel_parser/language/semantics/signature_mapping.rb +83 -0
- data/lib/bel_parser/language/semantics_ast.rb +784 -0
- data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
- data/lib/bel_parser/language/semantics_function.rb +16 -0
- data/lib/bel_parser/language/semantics_match.rb +28 -0
- data/lib/bel_parser/language/semantics_result.rb +33 -0
- data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
- data/lib/bel_parser/language/semantics_warning.rb +27 -0
- data/lib/bel_parser/language/signature.rb +39 -0
- data/lib/bel_parser/language/specification.rb +118 -0
- data/lib/bel_parser/language/syntax.rb +38 -0
- data/lib/bel_parser/language/syntax/invalid_function.rb +39 -0
- data/lib/bel_parser/language/syntax/invalid_relationship.rb +42 -0
- data/lib/bel_parser/language/syntax/undefined_namespace.rb +49 -0
- data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +44 -0
- data/lib/bel_parser/language/syntax_error.rb +32 -0
- data/lib/bel_parser/language/syntax_function.rb +16 -0
- data/lib/bel_parser/language/syntax_result.rb +32 -0
- data/lib/bel_parser/language/syntax_warning.rb +27 -0
- data/lib/bel_parser/language/version1_0.rb +20 -0
- data/lib/bel_parser/language/version1_0/functions/abundance.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/biological_process.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/catalytic_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/cell_secretion.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/cell_surface_expression.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/chaperone_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +115 -0
- data/lib/bel_parser/language/version1_0/functions/composite_abundance.rb +81 -0
- data/lib/bel_parser/language/version1_0/functions/degradation.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/fusion.rb +287 -0
- data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +122 -0
- data/lib/bel_parser/language/version1_0/functions/gtp_bound_activity.rb +113 -0
- data/lib/bel_parser/language/version1_0/functions/kinase_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/list.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +85 -0
- data/lib/bel_parser/language/version1_0/functions/molecular_activity.rb +82 -0
- data/lib/bel_parser/language/version1_0/functions/pathology.rb +83 -0
- data/lib/bel_parser/language/version1_0/functions/peptidase_activity.rb +112 -0
- data/lib/bel_parser/language/version1_0/functions/phosphatase_activity.rb +112 -0
- data/lib/bel_parser/language/version1_0/functions/products.rb +79 -0
- data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +234 -0
- data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +179 -0
- data/lib/bel_parser/language/version1_0/functions/reactants.rb +79 -0
- data/lib/bel_parser/language/version1_0/functions/reaction.rb +86 -0
- data/lib/bel_parser/language/version1_0/functions/ribosylation_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +122 -0
- data/lib/bel_parser/language/version1_0/functions/substitution.rb +93 -0
- data/lib/bel_parser/language/version1_0/functions/transcriptional_activity.rb +114 -0
- data/lib/bel_parser/language/version1_0/functions/translocation.rb +98 -0
- data/lib/bel_parser/language/version1_0/functions/transport_activity.rb +115 -0
- data/lib/bel_parser/language/version1_0/functions/truncation.rb +81 -0
- data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +61 -0
- data/lib/bel_parser/language/version1_0/relationships/analogous.rb +41 -0
- data/lib/bel_parser/language/version1_0/relationships/association.rb +42 -0
- data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +42 -0
- data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +50 -0
- data/lib/bel_parser/language/version1_0/relationships/decreases.rb +63 -0
- data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +56 -0
- data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +56 -0
- data/lib/bel_parser/language/version1_0/relationships/has_component.rb +62 -0
- data/lib/bel_parser/language/version1_0/relationships/has_components.rb +61 -0
- data/lib/bel_parser/language/version1_0/relationships/has_member.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/has_members.rb +57 -0
- data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/has_product.rb +60 -0
- data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/includes.rb +59 -0
- data/lib/bel_parser/language/version1_0/relationships/increases.rb +63 -0
- data/lib/bel_parser/language/version1_0/relationships/is_a.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +50 -0
- data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +48 -0
- data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +46 -0
- data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +44 -0
- data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +53 -0
- data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +60 -0
- data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +55 -0
- data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +53 -0
- data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +54 -0
- data/lib/bel_parser/language/version1_0/relationships/translocates.rb +57 -0
- data/lib/bel_parser/language/version1_0/return_types/abundance.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/return_types/biological_process.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/catalytic_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/chaperone_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/complex_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/fusion.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/gene_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/gtp_bound_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/kinase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/list.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/micro_rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/molecular_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/pathology.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/peptidase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/phosphatase_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/products.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/protein_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/protein_modification.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/reactants.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/ribosylation_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/substitution.rb +17 -0
- data/lib/bel_parser/language/version1_0/return_types/transcriptional_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/transport_activity.rb +20 -0
- data/lib/bel_parser/language/version1_0/return_types/truncation.rb +17 -0
- data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0.rb +20 -0
- data/lib/bel_parser/language/version2_0/functions/abundance.rb +161 -0
- data/lib/bel_parser/language/version2_0/functions/activity.rb +118 -0
- data/lib/bel_parser/language/version2_0/functions/biological_process.rb +84 -0
- data/lib/bel_parser/language/version2_0/functions/cell_secretion.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/cell_surface_expression.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +190 -0
- data/lib/bel_parser/language/version2_0/functions/composite_abundance.rb +81 -0
- data/lib/bel_parser/language/version2_0/functions/degradation.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/fragment.rb +116 -0
- data/lib/bel_parser/language/version2_0/functions/from_location.rb +85 -0
- data/lib/bel_parser/language/version2_0/functions/fusion.rb +203 -0
- data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +192 -0
- data/lib/bel_parser/language/version2_0/functions/list.rb +114 -0
- data/lib/bel_parser/language/version2_0/functions/location.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +163 -0
- data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +86 -0
- data/lib/bel_parser/language/version2_0/functions/pathology.rb +83 -0
- data/lib/bel_parser/language/version2_0/functions/products.rb +79 -0
- data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +270 -0
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +172 -0
- data/lib/bel_parser/language/version2_0/functions/reactants.rb +79 -0
- data/lib/bel_parser/language/version2_0/functions/reaction.rb +86 -0
- data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +192 -0
- data/lib/bel_parser/language/version2_0/functions/to_location.rb +84 -0
- data/lib/bel_parser/language/version2_0/functions/translocation.rb +91 -0
- data/lib/bel_parser/language/version2_0/functions/variant.rb +80 -0
- data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +61 -0
- data/lib/bel_parser/language/version2_0/relationships/analogous.rb +45 -0
- data/lib/bel_parser/language/version2_0/relationships/association.rb +42 -0
- data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +46 -0
- data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +50 -0
- data/lib/bel_parser/language/version2_0/relationships/decreases.rb +63 -0
- data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +56 -0
- data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +56 -0
- data/lib/bel_parser/language/version2_0/relationships/has_component.rb +62 -0
- data/lib/bel_parser/language/version2_0/relationships/has_components.rb +61 -0
- data/lib/bel_parser/language/version2_0/relationships/has_member.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/has_members.rb +57 -0
- data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/has_product.rb +60 -0
- data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/includes.rb +59 -0
- data/lib/bel_parser/language/version2_0/relationships/increases.rb +63 -0
- data/lib/bel_parser/language/version2_0/relationships/is_a.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +50 -0
- data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +46 -0
- data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +48 -0
- data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +53 -0
- data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +60 -0
- data/lib/bel_parser/language/version2_0/relationships/regulates.rb +51 -0
- data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +55 -0
- data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +53 -0
- data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +54 -0
- data/lib/bel_parser/language/version2_0/relationships/translocates.rb +57 -0
- data/lib/bel_parser/language/version2_0/return_types/abundance.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/activity.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/return_types/biological_process.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/complex_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/fragment.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/from_location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/fusion.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/gene_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/list.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/micro_rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/molecular_activity.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/pathology.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/products.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/protein_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/protein_modification.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/reactants.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/rna_abundance.rb +17 -0
- data/lib/bel_parser/language/version2_0/return_types/to_location.rb +20 -0
- data/lib/bel_parser/language/version2_0/return_types/variant.rb +20 -0
- data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/mixin/line_continuator.rb +15 -0
- data/lib/bel_parser/mixin/line_mapping.rb +14 -0
- data/lib/bel_parser/parsers/ast/node.rb +987 -0
- data/lib/bel_parser/parsers/ast/sexp.rb +8 -0
- data/lib/bel_parser/parsers/bel_script.rb +5 -0
- data/lib/bel_parser/parsers/bel_script/define_annotation.rb +5920 -0
- data/lib/bel_parser/parsers/bel_script/define_annotation.rl +141 -0
- data/lib/bel_parser/parsers/bel_script/define_namespace.rb +1780 -0
- data/lib/bel_parser/parsers/bel_script/define_namespace.rl +121 -0
- data/lib/bel_parser/parsers/bel_script/set.rb +5008 -0
- data/lib/bel_parser/parsers/bel_script/set.rl +116 -0
- data/lib/bel_parser/parsers/bel_script/set_document.rb +7722 -0
- data/lib/bel_parser/parsers/bel_script/set_document.rl +97 -0
- data/lib/bel_parser/parsers/bel_script/unset.rb +706 -0
- data/lib/bel_parser/parsers/bel_script/unset.rl +95 -0
- data/lib/bel_parser/parsers/common.rb +5 -0
- data/lib/bel_parser/parsers/common/blank_line.rb +211 -0
- data/lib/bel_parser/parsers/common/blank_line.rl +81 -0
- data/lib/bel_parser/parsers/common/comment_line.rb +245 -0
- data/lib/bel_parser/parsers/common/comment_line.rl +97 -0
- data/lib/bel_parser/parsers/common/common.rb +7 -0
- data/lib/bel_parser/parsers/common/common.rl +13 -0
- data/lib/bel_parser/parsers/common/identifier.rb +289 -0
- data/lib/bel_parser/parsers/common/identifier.rl +106 -0
- data/lib/bel_parser/parsers/common/list.rb +2388 -0
- data/lib/bel_parser/parsers/common/list.rl +146 -0
- data/lib/bel_parser/parsers/common/string.rb +271 -0
- data/lib/bel_parser/parsers/common/string.rl +107 -0
- data/lib/bel_parser/parsers/expression.rb +7 -0
- data/lib/bel_parser/parsers/expression/comment.rb +239 -0
- data/lib/bel_parser/parsers/expression/comment.rl +97 -0
- data/lib/bel_parser/parsers/expression/nested_statement.rb +17802 -0
- data/lib/bel_parser/parsers/expression/nested_statement.rl +141 -0
- data/lib/bel_parser/parsers/expression/observed_term.rb +7291 -0
- data/lib/bel_parser/parsers/expression/observed_term.rl +92 -0
- data/lib/bel_parser/parsers/expression/parameter.rb +1506 -0
- data/lib/bel_parser/parsers/expression/parameter.rl +97 -0
- data/lib/bel_parser/parsers/expression/relationship.rb +254 -0
- data/lib/bel_parser/parsers/expression/relationship.rl +98 -0
- data/lib/bel_parser/parsers/expression/simple_statement.rb +10475 -0
- data/lib/bel_parser/parsers/expression/simple_statement.rl +112 -0
- data/lib/bel_parser/parsers/expression/term.rb +3989 -0
- data/lib/bel_parser/parsers/expression/term.rl +157 -0
- data/lib/bel_parser/parsers/line_parser.rb +92 -0
- data/lib/bel_parser/parsers/mixin/buffer.rb +10 -0
- data/lib/bel_parser/parsers/nonblocking_io_wrapper.rb +50 -0
- data/lib/bel_parser/parsers/serializer.rb +205 -0
- data/lib/bel_parser/quoting.rb +177 -0
- data/lib/bel_parser/resource/concept.rb +56 -0
- data/lib/bel_parser/resource/concept_scheme.rb +35 -0
- data/lib/bel_parser/resource/dataset.rb +34 -0
- data/lib/bel_parser/resource/eager_reader.rb +89 -0
- data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
- data/lib/bel_parser/resource/file_resource.rb +21 -0
- data/lib/bel_parser/resource/file_resource_value.rb +24 -0
- data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
- data/lib/bel_parser/resource/lru_cache.rb +111 -0
- data/lib/bel_parser/resource/lru_reader.rb +34 -0
- data/lib/bel_parser/resource/reader.rb +18 -0
- data/lib/bel_parser/resource/resource_url_reader.rb +181 -0
- data/lib/bel_parser/resource/sparql_reader.rb +179 -0
- data/lib/bel_parser/resource/value.rb +31 -0
- data/lib/bel_parser/script.rb +8 -0
- data/lib/bel_parser/script/filter.rb +35 -0
- data/lib/bel_parser/script/first_node.rb +21 -0
- data/lib/bel_parser/script/keywords.rb +32 -0
- data/lib/bel_parser/script/nanopub_mapper.rb +182 -0
- data/lib/bel_parser/script/parser.rb +51 -0
- data/lib/bel_parser/script/state/annotation_definition.rb +62 -0
- data/lib/bel_parser/script/state/bel_version.rb +36 -0
- data/lib/bel_parser/script/state/document_property.rb +29 -0
- data/lib/bel_parser/script/state/namespace_definition.rb +32 -0
- data/lib/bel_parser/script/state/set.rb +82 -0
- data/lib/bel_parser/script/state/unset.rb +46 -0
- data/lib/bel_parser/script/state_aggregator.rb +49 -0
- data/lib/bel_parser/script/state_function.rb +10 -0
- data/lib/bel_parser/script/syntax/expression_validation.rb +46 -0
- data/lib/bel_parser/script/syntax/invalid_regex_pattern.rb +49 -0
- data/lib/bel_parser/script/syntax/undefined_annotation.rb +61 -0
- data/lib/bel_parser/script/syntax/undefined_annotation_value.rb +84 -0
- data/lib/bel_parser/script/syntax/unresolvable_namespace.rb +54 -0
- data/lib/bel_parser/script/syntax/unsupported_bel_version.rb +59 -0
- data/lib/bel_parser/script/validator.rb +65 -0
- data/lib/bel_parser/vendor/ast.rb +17 -0
- data/lib/bel_parser/vendor/ast/node.rb +254 -0
- data/lib/bel_parser/vendor/ast/processor.rb +12 -0
- data/lib/bel_parser/vendor/ast/processor/mixin.rb +282 -0
- data/lib/bel_parser/vendor/ast/sexp.rb +30 -0
- metadata +390 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e921d76566be607de95fcb0cc81def38fb66fbc
|
4
|
+
data.tar.gz: 07403998d6fdaeca6d9a3380a3fc55480470d7f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 437d7fd653d991fe0e7f3db14e42f210b61744e25f6395b7a673bba701ad43dc5ae920254683916347867402d4c04b3232f518f709ad867cdc3aee0b471338c6
|
7
|
+
data.tar.gz: 61f465297d02cf000a853f1b1048acd359529b3bdef234aa10f9494c58c51e5b042eab8b0f99a0868bdbb387108fda6b1679cf3edfc972db7539c3ba98cff6a3
|
data/.gemspec-java
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'bel_parser'
|
3
|
+
spec.version = File.read(
|
4
|
+
File.join(
|
5
|
+
File.expand_path(File.dirname(__FILE__)),
|
6
|
+
'VERSION'))
|
7
|
+
spec.summary = %q{Parser for Biolgical Expression Language.}
|
8
|
+
spec.description = %q{Implements language versions 1.0 and 2.0.}
|
9
|
+
spec.license = 'Apache-2.0'
|
10
|
+
spec.authors = [
|
11
|
+
'Anthony Bargnesi',
|
12
|
+
'Nick Bargnesi',
|
13
|
+
]
|
14
|
+
spec.date = %q{2016-05-09}
|
15
|
+
spec.email = %q{abargnesi@selventa.com}
|
16
|
+
spec.files = [
|
17
|
+
Dir.glob('lib/**/*.{rb,rl}'),
|
18
|
+
__FILE__,
|
19
|
+
'VERSION',
|
20
|
+
'CHANGELOG.md',
|
21
|
+
'LICENSE',
|
22
|
+
'README.md'
|
23
|
+
].flatten!
|
24
|
+
spec.executables = Dir.glob('bin/*').map(&File.method(:basename))
|
25
|
+
spec.homepage = 'https://github.com/OpenBEL/bel_parser'
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
spec.required_ruby_version = '>= 2.0.0'
|
28
|
+
|
29
|
+
spec.platform = 'java'
|
30
|
+
spec.add_runtime_dependency 'dbm-mapdb3', '~> 0.6.0.beta'
|
31
|
+
end
|
32
|
+
# vim: ft=ruby
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to bel_parser will be documented in this file. The curated log begins at changes to version 1.0.0.
|
3
|
+
|
4
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
|
+
|
6
|
+
## [1.0.0][1.0.0] - TBD
|
7
|
+
|
8
|
+
### Added
|
9
|
+
|
10
|
+
[1.0.0]: https://github.com/OpenBEL/bel_parser/compare/0.0.0...1.0.0
|
data/LICENSE
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
13
|
+
owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
21
|
+
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
23
|
+
permissions granted by this License.
|
24
|
+
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
27
|
+
files.
|
28
|
+
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
31
|
+
generated documentation, and conversions to other media types.
|
32
|
+
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
35
|
+
in or attached to the work (an example is provided in the Appendix below).
|
36
|
+
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
43
|
+
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
47
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
48
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
49
|
+
"submitted" means any form of electronic, verbal, or written communication sent
|
50
|
+
to the Licensor or its representatives, including but not limited to
|
51
|
+
communication on electronic mailing lists, source code control systems, and
|
52
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
53
|
+
the purpose of discussing and improving the Work, but excluding communication
|
54
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
55
|
+
owner as "Not a Contribution."
|
56
|
+
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
59
|
+
incorporated within the Work.
|
60
|
+
|
61
|
+
2. Grant of Copyright License.
|
62
|
+
|
63
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
64
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
65
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
66
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
67
|
+
Derivative Works in Source or Object form.
|
68
|
+
|
69
|
+
3. Grant of Patent License.
|
70
|
+
|
71
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
72
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
73
|
+
irrevocable (except as stated in this section) patent license to make, have
|
74
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
75
|
+
such license applies only to those patent claims licensable by such Contributor
|
76
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
77
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
78
|
+
submitted. If You institute patent litigation against any entity (including a
|
79
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
80
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
81
|
+
patent infringement, then any patent licenses granted to You under this License
|
82
|
+
for that Work shall terminate as of the date such litigation is filed.
|
83
|
+
|
84
|
+
4. Redistribution.
|
85
|
+
|
86
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
87
|
+
in any medium, with or without modifications, and in Source or Object form,
|
88
|
+
provided that You meet the following conditions:
|
89
|
+
|
90
|
+
You must give any other recipients of the Work or Derivative Works a copy of
|
91
|
+
this License; and
|
92
|
+
You must cause any modified files to carry prominent notices stating that You
|
93
|
+
changed the files; and
|
94
|
+
You must retain, in the Source form of any Derivative Works that You distribute,
|
95
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
96
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
97
|
+
Derivative Works; and
|
98
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
99
|
+
Derivative Works that You distribute must include a readable copy of the
|
100
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
101
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
102
|
+
following places: within a NOTICE text file distributed as part of the
|
103
|
+
Derivative Works; within the Source form or documentation, if provided along
|
104
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
105
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
106
|
+
the NOTICE file are for informational purposes only and do not modify the
|
107
|
+
License. You may add Your own attribution notices within Derivative Works that
|
108
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
109
|
+
provided that such additional attribution notices cannot be construed as
|
110
|
+
modifying the License.
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
114
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
115
|
+
with the conditions stated in this License.
|
116
|
+
|
117
|
+
5. Submission of Contributions.
|
118
|
+
|
119
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
120
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
121
|
+
conditions of this License, without any additional terms or conditions.
|
122
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
123
|
+
any separate license agreement you may have executed with Licensor regarding
|
124
|
+
such Contributions.
|
125
|
+
|
126
|
+
6. Trademarks.
|
127
|
+
|
128
|
+
This License does not grant permission to use the trade names, trademarks,
|
129
|
+
service marks, or product names of the Licensor, except as required for
|
130
|
+
reasonable and customary use in describing the origin of the Work and
|
131
|
+
reproducing the content of the NOTICE file.
|
132
|
+
|
133
|
+
7. Disclaimer of Warranty.
|
134
|
+
|
135
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
136
|
+
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
137
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
138
|
+
including, without limitation, any warranties or conditions of TITLE,
|
139
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
140
|
+
solely responsible for determining the appropriateness of using or
|
141
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
142
|
+
permissions under this License.
|
143
|
+
|
144
|
+
8. Limitation of Liability.
|
145
|
+
|
146
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
147
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
148
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
149
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
150
|
+
or consequential damages of any character arising as a result of this License or
|
151
|
+
out of the use or inability to use the Work (including but not limited to
|
152
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
153
|
+
any and all other commercial damages or losses), even if such Contributor has
|
154
|
+
been advised of the possibility of such damages.
|
155
|
+
|
156
|
+
9. Accepting Warranty or Additional Liability.
|
157
|
+
|
158
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
159
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
160
|
+
other liability obligations and/or rights consistent with this License. However,
|
161
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
162
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
163
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
165
|
+
accepting any such warranty or additional liability.
|
166
|
+
|
167
|
+
END OF TERMS AND CONDITIONS
|
168
|
+
|
169
|
+
APPENDIX: How to apply the Apache License to your work
|
170
|
+
|
171
|
+
To apply the Apache License to your work, attach the following boilerplate
|
172
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
173
|
+
identifying information. (Don't include the brackets!) The text should be
|
174
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
175
|
+
recommend that a file or class name and description of purpose be included on
|
176
|
+
the same "printed page" as the copyright notice for easier identification within
|
177
|
+
third-party archives.
|
178
|
+
|
179
|
+
Copyright 2013 OpenBEL Consortium
|
180
|
+
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182
|
+
you may not use this file except in compliance with the License.
|
183
|
+
You may obtain a copy of the License at
|
184
|
+
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
186
|
+
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190
|
+
See the License for the specific language governing permissions and
|
191
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# bel_parser
|
2
|
+
|
3
|
+
Parser for BEL expressions and the BEL Script document format.
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
gem install bel_parser --pre
|
8
|
+
|
9
|
+
### Getting Started
|
10
|
+
|
11
|
+
Two tools are available to try out:
|
12
|
+
1) bel_script_reader - will read a BEL Script with a specified BEL version and not any warning or errors with the script
|
13
|
+
|
14
|
+
2) bel2_validator - will read in lines and validate the BEL Statements
|
15
|
+
|
16
|
+
Example script using bel_parser module
|
17
|
+
|
18
|
+
examples/upgrade_kinase.rb
|
19
|
+
|
20
|
+
### Design
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0.alpha.27
|
data/bin/bel2_validator
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(
|
3
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
4
|
+
|
5
|
+
unless ARGV.first
|
6
|
+
program = File.basename($PROGRAM_NAME)
|
7
|
+
$stderr.puts <<-USAGE.gsub(/ {4}/, '')
|
8
|
+
usage: #{program} [BEL specification version] [PREFIX=URI]...
|
9
|
+
USAGE
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
def syntax_results(results)
|
14
|
+
results.select do |res|
|
15
|
+
res.is_a? BELParser::Language::Syntax::SyntaxResult
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def semantics_results(results)
|
20
|
+
results.select do |res|
|
21
|
+
res.is_a? BELParser::Language::Semantics::SemanticsResult
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'bel_parser'
|
26
|
+
require 'bel_parser/expression/validator'
|
27
|
+
require 'bel_parser/resource/resource_url_reader'
|
28
|
+
|
29
|
+
resource_reader = BELParser::Resource::ResourceURLReader.new(true)
|
30
|
+
namespaces =
|
31
|
+
Hash[
|
32
|
+
ARGV.map do |ns|
|
33
|
+
prefix, identifier = ns.split('=')
|
34
|
+
dataset = resource_reader.retrieve_resource(identifier)
|
35
|
+
dataset ? [prefix, dataset] : nil
|
36
|
+
end.compact
|
37
|
+
]
|
38
|
+
|
39
|
+
BELParser::Expression::Validator
|
40
|
+
.new(ARGV.first, namespaces, resource_reader)
|
41
|
+
.each($stdin) do |(line_number, line, ast, results)|
|
42
|
+
puts "#{line_number}: #{line}"
|
43
|
+
puts " AST Type: #{ast.type}"
|
44
|
+
|
45
|
+
puts " Syntax results:"
|
46
|
+
syntax_results(results).each do |res|
|
47
|
+
puts " #{res}"
|
48
|
+
end
|
49
|
+
|
50
|
+
puts " Semantics results:"
|
51
|
+
semantics_results(results).each do |res|
|
52
|
+
if res.is_a?(BELParser::Language::Semantics::SignatureMappingSuccess)
|
53
|
+
puts " Matched signature: #{res.signature.string_form}"
|
54
|
+
end
|
55
|
+
if res.is_a?(BELParser::Language::Semantics::SignatureMappingWarning)
|
56
|
+
puts " Failed signature: #{res.signature.string_form}"
|
57
|
+
res.results.select(&:failure?).each do |warning|
|
58
|
+
puts " #{warning}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(
|
3
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'bel_parser'
|
7
|
+
require 'bel_parser/resource/resource_url_reader'
|
8
|
+
|
9
|
+
options = {
|
10
|
+
spec: BELParser::Language.specification(
|
11
|
+
BELParser::Language.latest_supported_version)
|
12
|
+
}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = <<-USAGE.gsub(/^ {4}/, '')
|
15
|
+
Validates BEL Script with support for multiple BEL specifications.
|
16
|
+
|
17
|
+
Read from a BEL file.
|
18
|
+
usage: #$PROGRAM_NAME --file [FILE]
|
19
|
+
|
20
|
+
Read from standard input.
|
21
|
+
usage: #$PROGRAM_NAME
|
22
|
+
USAGE
|
23
|
+
|
24
|
+
opts.on('-f', '--file FILE', 'BEL script file to read.') do |bel|
|
25
|
+
options[:file] = bel
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on(
|
29
|
+
'-s',
|
30
|
+
'--specification VERSION',
|
31
|
+
'BEL specification version (e.g. 1.0, 2.0)') do |spec|
|
32
|
+
|
33
|
+
unless BELParser::Language.defines_version?(spec)
|
34
|
+
$stderr.puts %(Invalid BEL specification "#{spec}")
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
options[:spec] = BELParser::Language.specification(spec)
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on(
|
42
|
+
'-r',
|
43
|
+
'--[no-]reuse-resource-databases',
|
44
|
+
'Enable to reuse resource databases if they exist.') do |reuse|
|
45
|
+
|
46
|
+
options[:reuse] = reuse
|
47
|
+
end
|
48
|
+
end.parse!
|
49
|
+
|
50
|
+
file, spec = options.values_at(:file, :spec)
|
51
|
+
io =
|
52
|
+
if file
|
53
|
+
File.open(file, external_encoding: 'UTF-8')
|
54
|
+
else
|
55
|
+
$stdin
|
56
|
+
end
|
57
|
+
|
58
|
+
rr = BELParser::Resource::ResourceURLReader.new(options[:reuse])
|
59
|
+
namespaces = Hash[
|
60
|
+
ARGV.map do |ns|
|
61
|
+
prefix, identifier = ns.split('=')
|
62
|
+
dataset = rr.retrieve_resource(identifier)
|
63
|
+
dataset ? [prefix, dataset] : nil
|
64
|
+
end.compact
|
65
|
+
]
|
66
|
+
|
67
|
+
initial_state = {
|
68
|
+
resource_reader: rr,
|
69
|
+
specification: spec,
|
70
|
+
namespace_definitions: namespaces
|
71
|
+
}
|
72
|
+
|
73
|
+
module BELParser
|
74
|
+
module Script
|
75
|
+
# Reader assembles a BEL Script reader using the following pipeline:
|
76
|
+
#
|
77
|
+
# Generate -> Filter -> Pick One -> Aggregate State -> Validate Syntax
|
78
|
+
class Reader
|
79
|
+
SYN_ERR = BELParser::Language::Syntax::SyntaxError
|
80
|
+
SYN_WARN = BELParser::Language::Syntax::SyntaxWarning
|
81
|
+
SEM_WARN = BELParser::Language::Semantics::SemanticsWarning
|
82
|
+
|
83
|
+
def initialize(initial_state, io)
|
84
|
+
@validator =
|
85
|
+
Validator.new(
|
86
|
+
StateAggregator.new(
|
87
|
+
FirstNode.new(Filter.new(ASTGenerator.new(io))),
|
88
|
+
initial_state))
|
89
|
+
end
|
90
|
+
|
91
|
+
def read
|
92
|
+
@validator.each do |(line_number, line, ast_node, _)|
|
93
|
+
syntax_errors = ast_node.syntax_errors
|
94
|
+
errors = select(syntax_errors, SYN_ERR)
|
95
|
+
warnings =
|
96
|
+
select(syntax_errors, SYN_WARN) +
|
97
|
+
select(syntax_errors, SEM_WARN)
|
98
|
+
|
99
|
+
report(line_number, ast_node, errors, warnings)
|
100
|
+
|
101
|
+
unless errors.empty?
|
102
|
+
puts "Exiting due to error on line #{line_number}: #{line}"
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def select(list, cls)
|
111
|
+
list.select { |item| item.is_a?(cls) }
|
112
|
+
end
|
113
|
+
|
114
|
+
def report(line_number, ast, errors, warnings)
|
115
|
+
log = !errors.empty? || !warnings.empty?
|
116
|
+
if log
|
117
|
+
puts "On line #{line_number} for #{ast.type}"
|
118
|
+
puts " Errors:"
|
119
|
+
errors.each do |err|
|
120
|
+
puts " #{err}"
|
121
|
+
end
|
122
|
+
puts " Warnings:"
|
123
|
+
warnings.each do |warn|
|
124
|
+
puts " #{warn}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
BELParser::Script::Reader.new(initial_state, io).read
|