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
@@ -0,0 +1,157 @@
|
|
1
|
+
# begin: ragel
|
2
|
+
=begin
|
3
|
+
%%{
|
4
|
+
machine bel;
|
5
|
+
|
6
|
+
include 'parameter.rl';
|
7
|
+
|
8
|
+
action start_function {
|
9
|
+
@buffers[:function] = []
|
10
|
+
}
|
11
|
+
|
12
|
+
action append_function {
|
13
|
+
@buffers[:function] << fc
|
14
|
+
}
|
15
|
+
|
16
|
+
action finish_function {
|
17
|
+
@buffers[:function] = identifier(utf8_string(@buffers[:function]))
|
18
|
+
}
|
19
|
+
|
20
|
+
action term_init {
|
21
|
+
@buffers[:term_stack] = [ term() ]
|
22
|
+
}
|
23
|
+
|
24
|
+
action inner_term_init {
|
25
|
+
@buffers[:term_stack] << term()
|
26
|
+
}
|
27
|
+
|
28
|
+
action term_fx {
|
29
|
+
fx = @buffers[:function]
|
30
|
+
@buffers[:term_stack][-1] = @buffers[:term_stack][-1] << function(fx)
|
31
|
+
}
|
32
|
+
|
33
|
+
action term_argument {
|
34
|
+
@buffers[:term_stack][-1] = @buffers[:term_stack][-1] << argument(@buffers[:parameter])
|
35
|
+
@buffers[:parameter] = nil
|
36
|
+
}
|
37
|
+
|
38
|
+
action fxbt {
|
39
|
+
fpc -= @buffers[:function].length + 1
|
40
|
+
fcall inner_term;
|
41
|
+
}
|
42
|
+
|
43
|
+
action fxret {
|
44
|
+
inner_term = @buffers[:term_stack].pop
|
45
|
+
@buffers[:term_stack][-1] = @buffers[:term_stack][-1] << argument(inner_term)
|
46
|
+
fret;
|
47
|
+
}
|
48
|
+
|
49
|
+
action yield_term_ast {
|
50
|
+
yield @buffers[:term_stack][-1]
|
51
|
+
}
|
52
|
+
|
53
|
+
inner_term :=
|
54
|
+
IDENT >inner_term_init >start_function $append_function %finish_function
|
55
|
+
SP*
|
56
|
+
'(' @term_fx
|
57
|
+
(
|
58
|
+
BEL_PARAMETER %term_argument |
|
59
|
+
IDENT >start_function $append_function '(' @fxbt
|
60
|
+
)
|
61
|
+
(
|
62
|
+
SP* ',' SP*
|
63
|
+
(
|
64
|
+
BEL_PARAMETER %term_argument |
|
65
|
+
IDENT >start_function $append_function '(' @fxbt
|
66
|
+
)
|
67
|
+
)*
|
68
|
+
')' @fxret;
|
69
|
+
|
70
|
+
outer_term =
|
71
|
+
IDENT >term_init >start_function $append_function %finish_function
|
72
|
+
SP*
|
73
|
+
'(' @term_fx
|
74
|
+
(
|
75
|
+
BEL_PARAMETER %term_argument |
|
76
|
+
IDENT >start_function $append_function '(' @fxbt
|
77
|
+
)
|
78
|
+
(
|
79
|
+
SP* ',' SP*
|
80
|
+
(
|
81
|
+
BEL_PARAMETER %term_argument |
|
82
|
+
IDENT >start_function $append_function '(' @fxbt
|
83
|
+
)
|
84
|
+
)*
|
85
|
+
')';
|
86
|
+
|
87
|
+
term :=
|
88
|
+
outer_term %yield_term_ast NL;
|
89
|
+
}%%
|
90
|
+
=end
|
91
|
+
# end: ragel
|
92
|
+
|
93
|
+
require_relative '../ast/node'
|
94
|
+
require_relative '../mixin/buffer'
|
95
|
+
require_relative '../nonblocking_io_wrapper'
|
96
|
+
|
97
|
+
module BELParser
|
98
|
+
module Parsers
|
99
|
+
module Expression
|
100
|
+
module Term
|
101
|
+
|
102
|
+
class << self
|
103
|
+
|
104
|
+
MAX_LENGTH = 1024 * 128 # 128K
|
105
|
+
|
106
|
+
def parse(content)
|
107
|
+
return nil unless content
|
108
|
+
|
109
|
+
Parser.new(content).each do |obj|
|
110
|
+
yield obj
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
class Parser
|
118
|
+
include Enumerable
|
119
|
+
include BELParser::Parsers::Buffer
|
120
|
+
include BELParser::Parsers::AST::Sexp
|
121
|
+
|
122
|
+
def initialize(content)
|
123
|
+
@content = content
|
124
|
+
# begin: ragel
|
125
|
+
%% write data;
|
126
|
+
# end: ragel
|
127
|
+
end
|
128
|
+
|
129
|
+
def each
|
130
|
+
@buffers = {}
|
131
|
+
stack = []
|
132
|
+
data = @content.unpack('C*')
|
133
|
+
p = 0
|
134
|
+
pe = data.length
|
135
|
+
eof = data.length
|
136
|
+
|
137
|
+
# begin: ragel
|
138
|
+
%% write init;
|
139
|
+
%% write exec;
|
140
|
+
# end: ragel
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if __FILE__ == $0
|
149
|
+
$stdin.each_line do |line|
|
150
|
+
BELParser::Parsers::Expression::Term.parse(line) { |obj|
|
151
|
+
puts obj.inspect
|
152
|
+
}
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# vim: ft=ruby ts=2 sw=2:
|
157
|
+
# encoding: utf-8
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative 'common'
|
2
|
+
require_relative 'expression'
|
3
|
+
require_relative 'bel_script'
|
4
|
+
|
5
|
+
# Top-level LINE module.
|
6
|
+
module LINE
|
7
|
+
include BELParser::Parsers::Common
|
8
|
+
include BELParser::Parsers::Expression
|
9
|
+
include BELParser::Parsers::BELScript
|
10
|
+
|
11
|
+
BEL_PARSERS = [
|
12
|
+
BELParser::Parsers::Common::BlankLine,
|
13
|
+
BELParser::Parsers::Common::CommentLine,
|
14
|
+
BELParser::Parsers::Common::Identifier,
|
15
|
+
BELParser::Parsers::Common::String,
|
16
|
+
BELParser::Parsers::Common::List,
|
17
|
+
BELParser::Parsers::Expression::Parameter,
|
18
|
+
BELParser::Parsers::Expression::Term,
|
19
|
+
BELParser::Parsers::Expression::Relationship,
|
20
|
+
BELParser::Parsers::Expression::Comment,
|
21
|
+
BELParser::Parsers::Expression::ObservedTerm,
|
22
|
+
BELParser::Parsers::Expression::SimpleStatement,
|
23
|
+
BELParser::Parsers::Expression::NestedStatement,
|
24
|
+
BELParser::Parsers::BELScript::DefineAnnotation,
|
25
|
+
BELParser::Parsers::BELScript::DefineNamespace,
|
26
|
+
BELParser::Parsers::BELScript::Set,
|
27
|
+
BELParser::Parsers::BELScript::Unset
|
28
|
+
].freeze
|
29
|
+
|
30
|
+
# rubocop:disable MethodLength, AbcSize
|
31
|
+
def self.parse(io)
|
32
|
+
# single line transform
|
33
|
+
line_enum = io
|
34
|
+
.each_line
|
35
|
+
.lazy
|
36
|
+
.map { |line| LINE.normalize_line_terminators(line) }
|
37
|
+
|
38
|
+
# multi-line transform
|
39
|
+
loop do
|
40
|
+
begin
|
41
|
+
line = line_enum.next
|
42
|
+
|
43
|
+
while line.end_with?("\\\n")
|
44
|
+
line.chomp!("\\\n")
|
45
|
+
line += line_enum.next
|
46
|
+
end
|
47
|
+
|
48
|
+
BEL_PARSERS.each do |parser|
|
49
|
+
# rubocop:disable BlockDelimiters
|
50
|
+
parser.parse(line) { |obj|
|
51
|
+
puts "parser: #{parser.inspect},"\
|
52
|
+
"line: #{line.strip},"\
|
53
|
+
"object: \n#{obj.inspect}"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
rescue StopIteration
|
57
|
+
return
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.normalize_line_terminators(string)
|
63
|
+
return nil unless string
|
64
|
+
string.strip + "\n"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.map_empty_line(string)
|
68
|
+
if LINE.match_empty_line(string)
|
69
|
+
nil
|
70
|
+
else
|
71
|
+
string
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.map_comment_line(string)
|
76
|
+
if LINE.match_comment_line(string)
|
77
|
+
nil
|
78
|
+
else
|
79
|
+
string
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.match_empty_line(string)
|
84
|
+
string =~ /^\s*$/
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.match_comment_line(string)
|
88
|
+
string =~ /^\s*#/
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
LINE.parse($stdin) if FILE == $PROGRAM_NAME
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Provides a platform-independent, non-blocking wrapper for reading an
|
2
|
+
# {http://ruby-doc.org/core-2.2.2/IO.html IO}-like object. This wrapper
|
3
|
+
# object must be enumerated using the {#each} method.
|
4
|
+
class NonblockingIOWrapper
|
5
|
+
# Initialize this wrapper around the +io+ object and read at most
|
6
|
+
# +read_length+ bytes in a non-blocking manner.
|
7
|
+
#
|
8
|
+
# @param [IO] io an IO-like object
|
9
|
+
# @param [Fixnum] read_length the buffer length to read
|
10
|
+
def initialize(io, read_length = (128 * 1024))
|
11
|
+
@io = io
|
12
|
+
@read_length = read_length
|
13
|
+
@read_method = nonblocking_read(@io)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Yields each buffer read from the wrapped IO-like object to the provided
|
17
|
+
# block (e.g. +{ |block| ... }+). The read length is set on {#initialize}.
|
18
|
+
#
|
19
|
+
# @yield the buffers read from the IO-like object
|
20
|
+
# @yieldparam [String] buffer the read buffer as uninterpreted bytes
|
21
|
+
def each
|
22
|
+
while (buffer = @read_method.call(@read_length))
|
23
|
+
yield buffer
|
24
|
+
end
|
25
|
+
rescue IO::WaitReadable
|
26
|
+
IO.select([@io])
|
27
|
+
retry
|
28
|
+
# rubocop:disable HandleExceptions
|
29
|
+
rescue EOFError
|
30
|
+
# end of stream; parsing complete
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# Returns the method, appropriate for your platform, to read IO in a
|
36
|
+
# non-blocking manner.
|
37
|
+
#
|
38
|
+
# @example Call directly.
|
39
|
+
# nonblocking_read(StringIO.new('hello')).call(4)
|
40
|
+
#
|
41
|
+
# @param [IO] io an IO-like object
|
42
|
+
# @return [Method] a non-blocking read method
|
43
|
+
def nonblocking_read(io)
|
44
|
+
if Gem.win_platform?
|
45
|
+
io.method(:sysread)
|
46
|
+
else
|
47
|
+
io.method(:read_nonblock)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'bel_parser/vendor/ast'
|
2
|
+
|
3
|
+
module BELParser
|
4
|
+
module Parsers
|
5
|
+
|
6
|
+
def serialize(ast_node)
|
7
|
+
serializer = Serializer.new
|
8
|
+
serializer.process(ast_node)
|
9
|
+
serializer.string
|
10
|
+
end
|
11
|
+
|
12
|
+
# Defines an {AST::Processor::Mixin AST processor} that serializes
|
13
|
+
# all {AST::Node AST node} to a string.
|
14
|
+
class Serializer
|
15
|
+
include ::AST::Processor::Mixin
|
16
|
+
|
17
|
+
attr_reader :string
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@string = ''
|
21
|
+
end
|
22
|
+
|
23
|
+
def on_annotation_definition(annotation_definition_node)
|
24
|
+
@string << 'DEFINE ANNOTATION '
|
25
|
+
process(annotation_definition_node.keyword)
|
26
|
+
@string << ' AS '
|
27
|
+
process(annotation_definition_node.domain)
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_argument(argument_node)
|
31
|
+
@string << ', ' if @separate_by_comma
|
32
|
+
|
33
|
+
process(argument_node.child)
|
34
|
+
@separate_by_comma = true
|
35
|
+
end
|
36
|
+
|
37
|
+
def on_blank_line(blank_line_node)
|
38
|
+
@string << ''
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_comment_line(comment_line_node)
|
42
|
+
@string << %(##{comment_line_node.children[0]})
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_document_property(document_property_node)
|
46
|
+
name = document_property_node.name.identifier.string_literal
|
47
|
+
value = document_property_node.value.children[0].string_literal
|
48
|
+
@string << %(SET DOCUMENT #{name} = #{value})
|
49
|
+
end
|
50
|
+
|
51
|
+
def on_domain(domain_node)
|
52
|
+
process(domain_node.child)
|
53
|
+
end
|
54
|
+
|
55
|
+
def on_function(function_node)
|
56
|
+
@string << function_node.identifier.string_literal
|
57
|
+
end
|
58
|
+
|
59
|
+
def on_identifier(identifier_node)
|
60
|
+
@string << identifier_node.string_literal
|
61
|
+
end
|
62
|
+
|
63
|
+
def on_keyword(keyword_node)
|
64
|
+
process(keyword_node.identifier)
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_list(list_node)
|
68
|
+
items = list_node.list_items
|
69
|
+
if !items || items.empty?
|
70
|
+
@string << '{}'
|
71
|
+
else
|
72
|
+
@string << '{ '
|
73
|
+
process(items[0])
|
74
|
+
items[1..-1].each do |rest_item|
|
75
|
+
@string << ', '
|
76
|
+
process(rest_item)
|
77
|
+
end
|
78
|
+
@string << ' }'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def on_list_item(list_item_node)
|
83
|
+
process(list_item_node.children[0])
|
84
|
+
end
|
85
|
+
|
86
|
+
def on_name(name_node)
|
87
|
+
process(name_node.identifier)
|
88
|
+
end
|
89
|
+
|
90
|
+
def on_namespace_definition(namespace_definition_node)
|
91
|
+
@string << 'DEFINE NAMESPACE '
|
92
|
+
process(namespace_definition_node.keyword)
|
93
|
+
@string << ' AS '
|
94
|
+
process(namespace_definition_node.domain)
|
95
|
+
end
|
96
|
+
|
97
|
+
def on_nested_statement(nested_statement_node)
|
98
|
+
process(nested_statement_node.statement)
|
99
|
+
end
|
100
|
+
|
101
|
+
def on_object(object_node)
|
102
|
+
process(object_node.child)
|
103
|
+
end
|
104
|
+
|
105
|
+
def on_observed_term(observed_term_node)
|
106
|
+
process(observed_term_node.statement)
|
107
|
+
end
|
108
|
+
|
109
|
+
def on_parameter(param_node)
|
110
|
+
process(param_node.prefix)
|
111
|
+
process(param_node.value)
|
112
|
+
end
|
113
|
+
|
114
|
+
def on_pattern(pattern_node)
|
115
|
+
@string << 'PATTERN '
|
116
|
+
process(pattern_node.string)
|
117
|
+
end
|
118
|
+
|
119
|
+
def on_prefix(prefix_node)
|
120
|
+
prefix = prefix_node.identifier
|
121
|
+
@string << "#{prefix.string_literal}:" unless prefix.nil?
|
122
|
+
end
|
123
|
+
|
124
|
+
def on_relationship(relationship_node)
|
125
|
+
@string << " #{relationship_node.string_literal} "
|
126
|
+
end
|
127
|
+
|
128
|
+
def on_set(set_node)
|
129
|
+
@string << 'SET '
|
130
|
+
process(set_node.name)
|
131
|
+
@string << ' = '
|
132
|
+
process(set_node.value)
|
133
|
+
end
|
134
|
+
|
135
|
+
def on_simple_statement(simple_statement_node)
|
136
|
+
process(simple_statement_node.statement)
|
137
|
+
end
|
138
|
+
|
139
|
+
def on_statement(statement_node)
|
140
|
+
process(statement_node.subject)
|
141
|
+
return if statement_node.object.child.nil?
|
142
|
+
|
143
|
+
process(statement_node.relationship)
|
144
|
+
object_node = statement_node.object
|
145
|
+
if object_node.statement?
|
146
|
+
@string << '('
|
147
|
+
process(object_node)
|
148
|
+
@string << ')'
|
149
|
+
else
|
150
|
+
process(object_node)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def on_string(string_node)
|
155
|
+
@string << string_node.string_literal
|
156
|
+
end
|
157
|
+
|
158
|
+
def on_subject(subject_node)
|
159
|
+
process(subject_node.term)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Called when visiting nodes of type +term+.
|
163
|
+
def on_term(term_node)
|
164
|
+
@separate_by_comma = false
|
165
|
+
process(term_node.function)
|
166
|
+
@string << '('
|
167
|
+
term_node.arguments.each { |arg| process(arg) }
|
168
|
+
@string << ')'
|
169
|
+
end
|
170
|
+
|
171
|
+
def on_unset(unset_node)
|
172
|
+
@string << 'UNSET '
|
173
|
+
process(unset_node.name)
|
174
|
+
end
|
175
|
+
|
176
|
+
def on_url(url_node)
|
177
|
+
@string << 'URL '
|
178
|
+
process(url_node.string)
|
179
|
+
end
|
180
|
+
|
181
|
+
def on_value(value_node)
|
182
|
+
process(value_node.children[0])
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
if __FILE__ == $PROGRAM_NAME
|
189
|
+
$LOAD_PATH.unshift(
|
190
|
+
File.join(
|
191
|
+
File.expand_path(File.dirname(__FILE__)),
|
192
|
+
'..',
|
193
|
+
'..',
|
194
|
+
'..',
|
195
|
+
'lib'))
|
196
|
+
require 'bel_parser'
|
197
|
+
|
198
|
+
types = ARGV.map(&:to_sym)
|
199
|
+
generator = BELParser::ASTGenerator.new($stdin)
|
200
|
+
BELParser::ASTFilter.new(generator, *types).each do |(num, line, results)|
|
201
|
+
serializer = BELParser::Parsers::Serializer.new
|
202
|
+
serializer.process(results.first)
|
203
|
+
puts serializer.string
|
204
|
+
end
|
205
|
+
end
|