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.
Files changed (332) hide show
  1. checksums.yaml +7 -0
  2. data/.gemspec-java +32 -0
  3. data/CHANGELOG.md +10 -0
  4. data/LICENSE +191 -0
  5. data/README.md +20 -0
  6. data/VERSION +1 -0
  7. data/bin/bel2_validator +62 -0
  8. data/bin/bel_script_reader +132 -0
  9. data/lib/bel/translator/plugins/bel_script.rb +38 -0
  10. data/lib/bel/translator/plugins/bel_script/bel_citation_serialization.rb +125 -0
  11. data/lib/bel/translator/plugins/bel_script/bel_discrete_serialization.rb +109 -0
  12. data/lib/bel/translator/plugins/bel_script/bel_top_down_serialization.rb +100 -0
  13. data/lib/bel/translator/plugins/bel_script/nanopub_serialization.rb +79 -0
  14. data/lib/bel/translator/plugins/bel_script/reader.rb +39 -0
  15. data/lib/bel/translator/plugins/bel_script/translator.rb +37 -0
  16. data/lib/bel/translator/plugins/bel_script/writer.rb +180 -0
  17. data/lib/bel_parser.rb +23 -0
  18. data/lib/bel_parser/ast_filter.rb +44 -0
  19. data/lib/bel_parser/ast_generator.rb +83 -0
  20. data/lib/bel_parser/expression.rb +3 -0
  21. data/lib/bel_parser/expression/filter.rb +31 -0
  22. data/lib/bel_parser/expression/parser.rb +72 -0
  23. data/lib/bel_parser/expression/validator.rb +79 -0
  24. data/lib/bel_parser/language.rb +114 -0
  25. data/lib/bel_parser/language/amino_acid.rb +68 -0
  26. data/lib/bel_parser/language/apply_namespace_encoding.rb +98 -0
  27. data/lib/bel_parser/language/base_specification.rb +82 -0
  28. data/lib/bel_parser/language/covalent_protein_modification.rb +56 -0
  29. data/lib/bel_parser/language/expression_validator.rb +68 -0
  30. data/lib/bel_parser/language/function.rb +67 -0
  31. data/lib/bel_parser/language/relationship.rb +102 -0
  32. data/lib/bel_parser/language/semantics.rb +40 -0
  33. data/lib/bel_parser/language/semantics/deeply_nested_statement.rb +65 -0
  34. data/lib/bel_parser/language/semantics/function_deprecation.rb +43 -0
  35. data/lib/bel_parser/language/semantics/list_function_subject.rb +45 -0
  36. data/lib/bel_parser/language/semantics/multiple_subject_object.rb +55 -0
  37. data/lib/bel_parser/language/semantics/non_causal_nested_statement.rb +50 -0
  38. data/lib/bel_parser/language/semantics/non_object_list.rb +56 -0
  39. data/lib/bel_parser/language/semantics/relationship_deprecation.rb +44 -0
  40. data/lib/bel_parser/language/semantics/relationship_not_listable.rb +60 -0
  41. data/lib/bel_parser/language/semantics/signature_mapping.rb +83 -0
  42. data/lib/bel_parser/language/semantics_ast.rb +784 -0
  43. data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
  44. data/lib/bel_parser/language/semantics_function.rb +16 -0
  45. data/lib/bel_parser/language/semantics_match.rb +28 -0
  46. data/lib/bel_parser/language/semantics_result.rb +33 -0
  47. data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
  48. data/lib/bel_parser/language/semantics_warning.rb +27 -0
  49. data/lib/bel_parser/language/signature.rb +39 -0
  50. data/lib/bel_parser/language/specification.rb +118 -0
  51. data/lib/bel_parser/language/syntax.rb +38 -0
  52. data/lib/bel_parser/language/syntax/invalid_function.rb +39 -0
  53. data/lib/bel_parser/language/syntax/invalid_relationship.rb +42 -0
  54. data/lib/bel_parser/language/syntax/undefined_namespace.rb +49 -0
  55. data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +44 -0
  56. data/lib/bel_parser/language/syntax_error.rb +32 -0
  57. data/lib/bel_parser/language/syntax_function.rb +16 -0
  58. data/lib/bel_parser/language/syntax_result.rb +32 -0
  59. data/lib/bel_parser/language/syntax_warning.rb +27 -0
  60. data/lib/bel_parser/language/version1_0.rb +20 -0
  61. data/lib/bel_parser/language/version1_0/functions/abundance.rb +83 -0
  62. data/lib/bel_parser/language/version1_0/functions/biological_process.rb +83 -0
  63. data/lib/bel_parser/language/version1_0/functions/catalytic_activity.rb +114 -0
  64. data/lib/bel_parser/language/version1_0/functions/cell_secretion.rb +83 -0
  65. data/lib/bel_parser/language/version1_0/functions/cell_surface_expression.rb +83 -0
  66. data/lib/bel_parser/language/version1_0/functions/chaperone_activity.rb +114 -0
  67. data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +115 -0
  68. data/lib/bel_parser/language/version1_0/functions/composite_abundance.rb +81 -0
  69. data/lib/bel_parser/language/version1_0/functions/degradation.rb +83 -0
  70. data/lib/bel_parser/language/version1_0/functions/fusion.rb +287 -0
  71. data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +122 -0
  72. data/lib/bel_parser/language/version1_0/functions/gtp_bound_activity.rb +113 -0
  73. data/lib/bel_parser/language/version1_0/functions/kinase_activity.rb +114 -0
  74. data/lib/bel_parser/language/version1_0/functions/list.rb +114 -0
  75. data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +85 -0
  76. data/lib/bel_parser/language/version1_0/functions/molecular_activity.rb +82 -0
  77. data/lib/bel_parser/language/version1_0/functions/pathology.rb +83 -0
  78. data/lib/bel_parser/language/version1_0/functions/peptidase_activity.rb +112 -0
  79. data/lib/bel_parser/language/version1_0/functions/phosphatase_activity.rb +112 -0
  80. data/lib/bel_parser/language/version1_0/functions/products.rb +79 -0
  81. data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +234 -0
  82. data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +179 -0
  83. data/lib/bel_parser/language/version1_0/functions/reactants.rb +79 -0
  84. data/lib/bel_parser/language/version1_0/functions/reaction.rb +86 -0
  85. data/lib/bel_parser/language/version1_0/functions/ribosylation_activity.rb +114 -0
  86. data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +122 -0
  87. data/lib/bel_parser/language/version1_0/functions/substitution.rb +93 -0
  88. data/lib/bel_parser/language/version1_0/functions/transcriptional_activity.rb +114 -0
  89. data/lib/bel_parser/language/version1_0/functions/translocation.rb +98 -0
  90. data/lib/bel_parser/language/version1_0/functions/transport_activity.rb +115 -0
  91. data/lib/bel_parser/language/version1_0/functions/truncation.rb +81 -0
  92. data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +61 -0
  93. data/lib/bel_parser/language/version1_0/relationships/analogous.rb +41 -0
  94. data/lib/bel_parser/language/version1_0/relationships/association.rb +42 -0
  95. data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +42 -0
  96. data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +50 -0
  97. data/lib/bel_parser/language/version1_0/relationships/decreases.rb +63 -0
  98. data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +56 -0
  99. data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +56 -0
  100. data/lib/bel_parser/language/version1_0/relationships/has_component.rb +62 -0
  101. data/lib/bel_parser/language/version1_0/relationships/has_components.rb +61 -0
  102. data/lib/bel_parser/language/version1_0/relationships/has_member.rb +48 -0
  103. data/lib/bel_parser/language/version1_0/relationships/has_members.rb +57 -0
  104. data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +54 -0
  105. data/lib/bel_parser/language/version1_0/relationships/has_product.rb +60 -0
  106. data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +54 -0
  107. data/lib/bel_parser/language/version1_0/relationships/includes.rb +59 -0
  108. data/lib/bel_parser/language/version1_0/relationships/increases.rb +63 -0
  109. data/lib/bel_parser/language/version1_0/relationships/is_a.rb +48 -0
  110. data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +50 -0
  111. data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +48 -0
  112. data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +46 -0
  113. data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +44 -0
  114. data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +53 -0
  115. data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +60 -0
  116. data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +55 -0
  117. data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +53 -0
  118. data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +54 -0
  119. data/lib/bel_parser/language/version1_0/relationships/translocates.rb +57 -0
  120. data/lib/bel_parser/language/version1_0/return_types/abundance.rb +20 -0
  121. data/lib/bel_parser/language/version1_0/return_types/any.rb +74 -0
  122. data/lib/bel_parser/language/version1_0/return_types/biological_process.rb +17 -0
  123. data/lib/bel_parser/language/version1_0/return_types/catalytic_activity.rb +20 -0
  124. data/lib/bel_parser/language/version1_0/return_types/chaperone_activity.rb +20 -0
  125. data/lib/bel_parser/language/version1_0/return_types/complex_abundance.rb +17 -0
  126. data/lib/bel_parser/language/version1_0/return_types/fusion.rb +17 -0
  127. data/lib/bel_parser/language/version1_0/return_types/gene_abundance.rb +17 -0
  128. data/lib/bel_parser/language/version1_0/return_types/gtp_bound_activity.rb +20 -0
  129. data/lib/bel_parser/language/version1_0/return_types/kinase_activity.rb +20 -0
  130. data/lib/bel_parser/language/version1_0/return_types/list.rb +17 -0
  131. data/lib/bel_parser/language/version1_0/return_types/micro_rna_abundance.rb +17 -0
  132. data/lib/bel_parser/language/version1_0/return_types/molecular_activity.rb +20 -0
  133. data/lib/bel_parser/language/version1_0/return_types/pathology.rb +17 -0
  134. data/lib/bel_parser/language/version1_0/return_types/peptidase_activity.rb +20 -0
  135. data/lib/bel_parser/language/version1_0/return_types/phosphatase_activity.rb +20 -0
  136. data/lib/bel_parser/language/version1_0/return_types/products.rb +17 -0
  137. data/lib/bel_parser/language/version1_0/return_types/protein_abundance.rb +17 -0
  138. data/lib/bel_parser/language/version1_0/return_types/protein_modification.rb +17 -0
  139. data/lib/bel_parser/language/version1_0/return_types/reactants.rb +17 -0
  140. data/lib/bel_parser/language/version1_0/return_types/ribosylation_activity.rb +20 -0
  141. data/lib/bel_parser/language/version1_0/return_types/rna_abundance.rb +17 -0
  142. data/lib/bel_parser/language/version1_0/return_types/substitution.rb +17 -0
  143. data/lib/bel_parser/language/version1_0/return_types/transcriptional_activity.rb +20 -0
  144. data/lib/bel_parser/language/version1_0/return_types/transport_activity.rb +20 -0
  145. data/lib/bel_parser/language/version1_0/return_types/truncation.rb +17 -0
  146. data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
  147. data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
  148. data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
  149. data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
  150. data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
  151. data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
  152. data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
  153. data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
  154. data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
  155. data/lib/bel_parser/language/version2_0.rb +20 -0
  156. data/lib/bel_parser/language/version2_0/functions/abundance.rb +161 -0
  157. data/lib/bel_parser/language/version2_0/functions/activity.rb +118 -0
  158. data/lib/bel_parser/language/version2_0/functions/biological_process.rb +84 -0
  159. data/lib/bel_parser/language/version2_0/functions/cell_secretion.rb +83 -0
  160. data/lib/bel_parser/language/version2_0/functions/cell_surface_expression.rb +83 -0
  161. data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +190 -0
  162. data/lib/bel_parser/language/version2_0/functions/composite_abundance.rb +81 -0
  163. data/lib/bel_parser/language/version2_0/functions/degradation.rb +83 -0
  164. data/lib/bel_parser/language/version2_0/functions/fragment.rb +116 -0
  165. data/lib/bel_parser/language/version2_0/functions/from_location.rb +85 -0
  166. data/lib/bel_parser/language/version2_0/functions/fusion.rb +203 -0
  167. data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +192 -0
  168. data/lib/bel_parser/language/version2_0/functions/list.rb +114 -0
  169. data/lib/bel_parser/language/version2_0/functions/location.rb +83 -0
  170. data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +163 -0
  171. data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +86 -0
  172. data/lib/bel_parser/language/version2_0/functions/pathology.rb +83 -0
  173. data/lib/bel_parser/language/version2_0/functions/products.rb +79 -0
  174. data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +270 -0
  175. data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +172 -0
  176. data/lib/bel_parser/language/version2_0/functions/reactants.rb +79 -0
  177. data/lib/bel_parser/language/version2_0/functions/reaction.rb +86 -0
  178. data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +192 -0
  179. data/lib/bel_parser/language/version2_0/functions/to_location.rb +84 -0
  180. data/lib/bel_parser/language/version2_0/functions/translocation.rb +91 -0
  181. data/lib/bel_parser/language/version2_0/functions/variant.rb +80 -0
  182. data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +61 -0
  183. data/lib/bel_parser/language/version2_0/relationships/analogous.rb +45 -0
  184. data/lib/bel_parser/language/version2_0/relationships/association.rb +42 -0
  185. data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +46 -0
  186. data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +50 -0
  187. data/lib/bel_parser/language/version2_0/relationships/decreases.rb +63 -0
  188. data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +56 -0
  189. data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +56 -0
  190. data/lib/bel_parser/language/version2_0/relationships/has_component.rb +62 -0
  191. data/lib/bel_parser/language/version2_0/relationships/has_components.rb +61 -0
  192. data/lib/bel_parser/language/version2_0/relationships/has_member.rb +48 -0
  193. data/lib/bel_parser/language/version2_0/relationships/has_members.rb +57 -0
  194. data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +54 -0
  195. data/lib/bel_parser/language/version2_0/relationships/has_product.rb +60 -0
  196. data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +54 -0
  197. data/lib/bel_parser/language/version2_0/relationships/includes.rb +59 -0
  198. data/lib/bel_parser/language/version2_0/relationships/increases.rb +63 -0
  199. data/lib/bel_parser/language/version2_0/relationships/is_a.rb +48 -0
  200. data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +50 -0
  201. data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +48 -0
  202. data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +46 -0
  203. data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +48 -0
  204. data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +53 -0
  205. data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +60 -0
  206. data/lib/bel_parser/language/version2_0/relationships/regulates.rb +51 -0
  207. data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +55 -0
  208. data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +53 -0
  209. data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +54 -0
  210. data/lib/bel_parser/language/version2_0/relationships/translocates.rb +57 -0
  211. data/lib/bel_parser/language/version2_0/return_types/abundance.rb +20 -0
  212. data/lib/bel_parser/language/version2_0/return_types/activity.rb +20 -0
  213. data/lib/bel_parser/language/version2_0/return_types/any.rb +74 -0
  214. data/lib/bel_parser/language/version2_0/return_types/biological_process.rb +17 -0
  215. data/lib/bel_parser/language/version2_0/return_types/complex_abundance.rb +17 -0
  216. data/lib/bel_parser/language/version2_0/return_types/fragment.rb +20 -0
  217. data/lib/bel_parser/language/version2_0/return_types/from_location.rb +20 -0
  218. data/lib/bel_parser/language/version2_0/return_types/fusion.rb +17 -0
  219. data/lib/bel_parser/language/version2_0/return_types/gene_abundance.rb +17 -0
  220. data/lib/bel_parser/language/version2_0/return_types/list.rb +17 -0
  221. data/lib/bel_parser/language/version2_0/return_types/location.rb +20 -0
  222. data/lib/bel_parser/language/version2_0/return_types/micro_rna_abundance.rb +17 -0
  223. data/lib/bel_parser/language/version2_0/return_types/molecular_activity.rb +20 -0
  224. data/lib/bel_parser/language/version2_0/return_types/pathology.rb +17 -0
  225. data/lib/bel_parser/language/version2_0/return_types/products.rb +17 -0
  226. data/lib/bel_parser/language/version2_0/return_types/protein_abundance.rb +17 -0
  227. data/lib/bel_parser/language/version2_0/return_types/protein_modification.rb +17 -0
  228. data/lib/bel_parser/language/version2_0/return_types/reactants.rb +17 -0
  229. data/lib/bel_parser/language/version2_0/return_types/rna_abundance.rb +17 -0
  230. data/lib/bel_parser/language/version2_0/return_types/to_location.rb +20 -0
  231. data/lib/bel_parser/language/version2_0/return_types/variant.rb +20 -0
  232. data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
  233. data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
  234. data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
  235. data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
  236. data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
  237. data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
  238. data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
  239. data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
  240. data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
  241. data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
  242. data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
  243. data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
  244. data/lib/bel_parser/mixin/line_continuator.rb +15 -0
  245. data/lib/bel_parser/mixin/line_mapping.rb +14 -0
  246. data/lib/bel_parser/parsers/ast/node.rb +987 -0
  247. data/lib/bel_parser/parsers/ast/sexp.rb +8 -0
  248. data/lib/bel_parser/parsers/bel_script.rb +5 -0
  249. data/lib/bel_parser/parsers/bel_script/define_annotation.rb +5920 -0
  250. data/lib/bel_parser/parsers/bel_script/define_annotation.rl +141 -0
  251. data/lib/bel_parser/parsers/bel_script/define_namespace.rb +1780 -0
  252. data/lib/bel_parser/parsers/bel_script/define_namespace.rl +121 -0
  253. data/lib/bel_parser/parsers/bel_script/set.rb +5008 -0
  254. data/lib/bel_parser/parsers/bel_script/set.rl +116 -0
  255. data/lib/bel_parser/parsers/bel_script/set_document.rb +7722 -0
  256. data/lib/bel_parser/parsers/bel_script/set_document.rl +97 -0
  257. data/lib/bel_parser/parsers/bel_script/unset.rb +706 -0
  258. data/lib/bel_parser/parsers/bel_script/unset.rl +95 -0
  259. data/lib/bel_parser/parsers/common.rb +5 -0
  260. data/lib/bel_parser/parsers/common/blank_line.rb +211 -0
  261. data/lib/bel_parser/parsers/common/blank_line.rl +81 -0
  262. data/lib/bel_parser/parsers/common/comment_line.rb +245 -0
  263. data/lib/bel_parser/parsers/common/comment_line.rl +97 -0
  264. data/lib/bel_parser/parsers/common/common.rb +7 -0
  265. data/lib/bel_parser/parsers/common/common.rl +13 -0
  266. data/lib/bel_parser/parsers/common/identifier.rb +289 -0
  267. data/lib/bel_parser/parsers/common/identifier.rl +106 -0
  268. data/lib/bel_parser/parsers/common/list.rb +2388 -0
  269. data/lib/bel_parser/parsers/common/list.rl +146 -0
  270. data/lib/bel_parser/parsers/common/string.rb +271 -0
  271. data/lib/bel_parser/parsers/common/string.rl +107 -0
  272. data/lib/bel_parser/parsers/expression.rb +7 -0
  273. data/lib/bel_parser/parsers/expression/comment.rb +239 -0
  274. data/lib/bel_parser/parsers/expression/comment.rl +97 -0
  275. data/lib/bel_parser/parsers/expression/nested_statement.rb +17802 -0
  276. data/lib/bel_parser/parsers/expression/nested_statement.rl +141 -0
  277. data/lib/bel_parser/parsers/expression/observed_term.rb +7291 -0
  278. data/lib/bel_parser/parsers/expression/observed_term.rl +92 -0
  279. data/lib/bel_parser/parsers/expression/parameter.rb +1506 -0
  280. data/lib/bel_parser/parsers/expression/parameter.rl +97 -0
  281. data/lib/bel_parser/parsers/expression/relationship.rb +254 -0
  282. data/lib/bel_parser/parsers/expression/relationship.rl +98 -0
  283. data/lib/bel_parser/parsers/expression/simple_statement.rb +10475 -0
  284. data/lib/bel_parser/parsers/expression/simple_statement.rl +112 -0
  285. data/lib/bel_parser/parsers/expression/term.rb +3989 -0
  286. data/lib/bel_parser/parsers/expression/term.rl +157 -0
  287. data/lib/bel_parser/parsers/line_parser.rb +92 -0
  288. data/lib/bel_parser/parsers/mixin/buffer.rb +10 -0
  289. data/lib/bel_parser/parsers/nonblocking_io_wrapper.rb +50 -0
  290. data/lib/bel_parser/parsers/serializer.rb +205 -0
  291. data/lib/bel_parser/quoting.rb +177 -0
  292. data/lib/bel_parser/resource/concept.rb +56 -0
  293. data/lib/bel_parser/resource/concept_scheme.rb +35 -0
  294. data/lib/bel_parser/resource/dataset.rb +34 -0
  295. data/lib/bel_parser/resource/eager_reader.rb +89 -0
  296. data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
  297. data/lib/bel_parser/resource/file_resource.rb +21 -0
  298. data/lib/bel_parser/resource/file_resource_value.rb +24 -0
  299. data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
  300. data/lib/bel_parser/resource/lru_cache.rb +111 -0
  301. data/lib/bel_parser/resource/lru_reader.rb +34 -0
  302. data/lib/bel_parser/resource/reader.rb +18 -0
  303. data/lib/bel_parser/resource/resource_url_reader.rb +181 -0
  304. data/lib/bel_parser/resource/sparql_reader.rb +179 -0
  305. data/lib/bel_parser/resource/value.rb +31 -0
  306. data/lib/bel_parser/script.rb +8 -0
  307. data/lib/bel_parser/script/filter.rb +35 -0
  308. data/lib/bel_parser/script/first_node.rb +21 -0
  309. data/lib/bel_parser/script/keywords.rb +32 -0
  310. data/lib/bel_parser/script/nanopub_mapper.rb +182 -0
  311. data/lib/bel_parser/script/parser.rb +51 -0
  312. data/lib/bel_parser/script/state/annotation_definition.rb +62 -0
  313. data/lib/bel_parser/script/state/bel_version.rb +36 -0
  314. data/lib/bel_parser/script/state/document_property.rb +29 -0
  315. data/lib/bel_parser/script/state/namespace_definition.rb +32 -0
  316. data/lib/bel_parser/script/state/set.rb +82 -0
  317. data/lib/bel_parser/script/state/unset.rb +46 -0
  318. data/lib/bel_parser/script/state_aggregator.rb +49 -0
  319. data/lib/bel_parser/script/state_function.rb +10 -0
  320. data/lib/bel_parser/script/syntax/expression_validation.rb +46 -0
  321. data/lib/bel_parser/script/syntax/invalid_regex_pattern.rb +49 -0
  322. data/lib/bel_parser/script/syntax/undefined_annotation.rb +61 -0
  323. data/lib/bel_parser/script/syntax/undefined_annotation_value.rb +84 -0
  324. data/lib/bel_parser/script/syntax/unresolvable_namespace.rb +54 -0
  325. data/lib/bel_parser/script/syntax/unsupported_bel_version.rb +59 -0
  326. data/lib/bel_parser/script/validator.rb +65 -0
  327. data/lib/bel_parser/vendor/ast.rb +17 -0
  328. data/lib/bel_parser/vendor/ast/node.rb +254 -0
  329. data/lib/bel_parser/vendor/ast/processor.rb +12 -0
  330. data/lib/bel_parser/vendor/ast/processor/mixin.rb +282 -0
  331. data/lib/bel_parser/vendor/ast/sexp.rb +30 -0
  332. metadata +390 -0
@@ -0,0 +1,92 @@
1
+ # begin: ragel
2
+ =begin
3
+ %%{
4
+ machine bel;
5
+
6
+ include 'term.rl';
7
+ include 'comment.rl';
8
+
9
+ action yield_observed_term {
10
+ @buffers[:comment] ||= comment(nil)
11
+ yield observed_term(
12
+ statement(
13
+ subject(@buffers[:term_stack][-1]),
14
+ relationship(nil),
15
+ object(nil),
16
+ @buffers[:comment]))
17
+ }
18
+
19
+ observed_term :=
20
+ outer_term
21
+ SP*
22
+ COMMENT? %yield_observed_term
23
+ NL;
24
+ }%%
25
+ =end
26
+ # end: ragel
27
+
28
+ require_relative '../ast/node'
29
+ require_relative '../mixin/buffer'
30
+ require_relative '../nonblocking_io_wrapper'
31
+
32
+ module BELParser
33
+ module Parsers
34
+ module Expression
35
+ module ObservedTerm
36
+
37
+ class << self
38
+
39
+ MAX_LENGTH = 1024 * 128 # 128K
40
+
41
+ def parse(content)
42
+ return nil unless content
43
+
44
+ Parser.new(content).each do |obj|
45
+ yield obj
46
+ end
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ class Parser
53
+ include Enumerable
54
+ include BELParser::Parsers::Buffer
55
+ include BELParser::Parsers::AST::Sexp
56
+
57
+ def initialize(content)
58
+ @content = content
59
+ # begin: ragel
60
+ %% write data;
61
+ # end: ragel
62
+ end
63
+
64
+ def each
65
+ @buffers = {}
66
+ stack = []
67
+ data = @content.unpack('C*')
68
+ p = 0
69
+ pe = data.length
70
+ eof = data.length
71
+
72
+ # begin: ragel
73
+ %% write init;
74
+ %% write exec;
75
+ # end: ragel
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ if __FILE__ == $0
84
+ $stdin.each_line do |line|
85
+ BELParser::Parsers::Expression::ObservedTerm.parse(line) { |obj|
86
+ puts obj.inspect
87
+ }
88
+ end
89
+ end
90
+
91
+ # vim: ft=ruby ts=2 sw=2:
92
+ # encoding: utf-8
@@ -0,0 +1,1506 @@
1
+
2
+ # begin: ragel
3
+ =begin
4
+
5
+ class << self
6
+ attr_accessor :_bel_trans_keys
7
+ private :_bel_trans_keys, :_bel_trans_keys=
8
+ end
9
+ self._bel_trans_keys = [
10
+ 0, 0, 9, 122, 9, 122,
11
+ 34, 92, 10, 10, 92,
12
+ 92, 10, 122, 10, 122,
13
+ 48, 122, 10, 122, 34, 34,
14
+ 34, 92, 10, 10, 92,
15
+ 92, 0, 0, 0, 0,
16
+ 0, 0, 0
17
+ ]
18
+
19
+ class << self
20
+ attr_accessor :_bel_key_spans
21
+ private :_bel_key_spans, :_bel_key_spans=
22
+ end
23
+ self._bel_key_spans = [
24
+ 0, 114, 114, 59, 1, 1, 113, 113,
25
+ 75, 113, 1, 59, 1, 1, 0, 0,
26
+ 0
27
+ ]
28
+
29
+ class << self
30
+ attr_accessor :_bel_index_offsets
31
+ private :_bel_index_offsets, :_bel_index_offsets=
32
+ end
33
+ self._bel_index_offsets = [
34
+ 0, 0, 115, 230, 290, 292, 294, 408,
35
+ 522, 598, 712, 714, 774, 776, 778, 779,
36
+ 780
37
+ ]
38
+
39
+ class << self
40
+ attr_accessor :_bel_indicies
41
+ private :_bel_indicies, :_bel_indicies=
42
+ end
43
+ self._bel_indicies = [
44
+ 1, 0, 0, 0, 0, 0, 0, 0,
45
+ 0, 0, 0, 0, 0, 0, 0, 0,
46
+ 0, 0, 0, 0, 0, 0, 0, 1,
47
+ 0, 2, 0, 0, 0, 0, 0, 0,
48
+ 0, 0, 0, 0, 0, 0, 0, 3,
49
+ 3, 3, 3, 3, 3, 3, 3, 3,
50
+ 3, 0, 0, 0, 0, 0, 0, 0,
51
+ 3, 3, 3, 3, 3, 3, 3, 3,
52
+ 3, 3, 3, 3, 3, 3, 3, 3,
53
+ 3, 3, 3, 3, 3, 3, 3, 3,
54
+ 3, 3, 0, 0, 0, 0, 3, 0,
55
+ 3, 3, 3, 3, 3, 3, 3, 3,
56
+ 3, 3, 3, 3, 3, 3, 3, 3,
57
+ 3, 3, 3, 3, 3, 3, 3, 3,
58
+ 3, 3, 0, 1, 4, 4, 4, 4,
59
+ 4, 4, 4, 4, 4, 4, 4, 4,
60
+ 4, 4, 4, 4, 4, 4, 4, 4,
61
+ 4, 4, 1, 4, 2, 4, 4, 4,
62
+ 4, 4, 4, 4, 4, 4, 4, 4,
63
+ 4, 4, 5, 5, 5, 5, 5, 5,
64
+ 5, 5, 5, 5, 4, 4, 4, 4,
65
+ 4, 4, 4, 5, 5, 5, 5, 5,
66
+ 5, 5, 5, 5, 5, 5, 5, 5,
67
+ 5, 5, 5, 5, 5, 5, 5, 5,
68
+ 5, 5, 5, 5, 5, 4, 4, 4,
69
+ 4, 5, 4, 5, 5, 5, 5, 5,
70
+ 5, 5, 5, 5, 5, 5, 5, 5,
71
+ 5, 5, 5, 5, 5, 5, 5, 5,
72
+ 5, 5, 5, 5, 5, 4, 7, 6,
73
+ 6, 6, 6, 6, 6, 6, 6, 6,
74
+ 6, 6, 6, 6, 6, 6, 6, 6,
75
+ 6, 6, 6, 6, 6, 6, 6, 6,
76
+ 6, 6, 6, 6, 6, 6, 6, 6,
77
+ 6, 6, 6, 6, 6, 6, 6, 6,
78
+ 6, 6, 6, 6, 6, 6, 6, 6,
79
+ 6, 6, 6, 6, 6, 6, 6, 6,
80
+ 8, 6, 10, 9, 8, 6, 12, 11,
81
+ 11, 11, 11, 11, 11, 11, 11, 11,
82
+ 11, 11, 11, 11, 11, 11, 11, 11,
83
+ 11, 11, 11, 11, 11, 11, 11, 11,
84
+ 11, 11, 11, 11, 11, 11, 11, 11,
85
+ 11, 11, 11, 11, 13, 13, 13, 13,
86
+ 13, 13, 13, 13, 13, 13, 11, 11,
87
+ 11, 11, 11, 11, 11, 13, 13, 13,
88
+ 13, 13, 13, 13, 13, 13, 13, 13,
89
+ 13, 13, 13, 13, 13, 13, 13, 13,
90
+ 13, 13, 13, 13, 13, 13, 13, 11,
91
+ 11, 11, 11, 13, 11, 13, 13, 13,
92
+ 13, 13, 13, 13, 13, 13, 13, 13,
93
+ 13, 13, 13, 13, 13, 13, 13, 13,
94
+ 13, 13, 13, 13, 13, 13, 13, 11,
95
+ 12, 11, 11, 11, 11, 11, 11, 11,
96
+ 11, 11, 11, 11, 11, 11, 11, 11,
97
+ 11, 11, 11, 11, 11, 11, 11, 11,
98
+ 11, 11, 11, 11, 11, 11, 11, 11,
99
+ 11, 11, 11, 11, 11, 11, 14, 14,
100
+ 14, 14, 14, 14, 14, 14, 14, 14,
101
+ 15, 11, 11, 11, 11, 11, 11, 14,
102
+ 14, 14, 14, 14, 14, 14, 14, 14,
103
+ 14, 14, 14, 14, 14, 14, 14, 14,
104
+ 14, 14, 14, 14, 14, 14, 14, 14,
105
+ 14, 11, 11, 11, 11, 14, 11, 14,
106
+ 14, 14, 14, 14, 14, 14, 14, 14,
107
+ 14, 14, 14, 14, 14, 14, 14, 14,
108
+ 14, 14, 14, 14, 14, 14, 14, 14,
109
+ 14, 11, 17, 17, 17, 17, 17, 17,
110
+ 17, 17, 17, 17, 16, 16, 16, 16,
111
+ 16, 16, 16, 17, 17, 17, 17, 17,
112
+ 17, 17, 17, 17, 17, 17, 17, 17,
113
+ 17, 17, 17, 17, 17, 17, 17, 17,
114
+ 17, 17, 17, 17, 17, 16, 16, 16,
115
+ 16, 17, 16, 17, 17, 17, 17, 17,
116
+ 17, 17, 17, 17, 17, 17, 17, 17,
117
+ 17, 17, 17, 17, 17, 17, 17, 17,
118
+ 17, 17, 17, 17, 17, 16, 18, 16,
119
+ 16, 16, 16, 16, 16, 16, 16, 16,
120
+ 16, 16, 16, 16, 16, 16, 16, 16,
121
+ 16, 16, 16, 16, 16, 16, 16, 16,
122
+ 16, 16, 16, 16, 16, 16, 16, 16,
123
+ 16, 16, 16, 16, 19, 19, 19, 19,
124
+ 19, 19, 19, 19, 19, 19, 16, 16,
125
+ 16, 16, 16, 16, 16, 19, 19, 19,
126
+ 19, 19, 19, 19, 19, 19, 19, 19,
127
+ 19, 19, 19, 19, 19, 19, 19, 19,
128
+ 19, 19, 19, 19, 19, 19, 19, 16,
129
+ 16, 16, 16, 19, 16, 19, 19, 19,
130
+ 19, 19, 19, 19, 19, 19, 19, 19,
131
+ 19, 19, 19, 19, 19, 19, 19, 19,
132
+ 19, 19, 19, 19, 19, 19, 19, 16,
133
+ 21, 20, 23, 22, 22, 22, 22, 22,
134
+ 22, 22, 22, 22, 22, 22, 22, 22,
135
+ 22, 22, 22, 22, 22, 22, 22, 22,
136
+ 22, 22, 22, 22, 22, 22, 22, 22,
137
+ 22, 22, 22, 22, 22, 22, 22, 22,
138
+ 22, 22, 22, 22, 22, 22, 22, 22,
139
+ 22, 22, 22, 22, 22, 22, 22, 22,
140
+ 22, 22, 22, 22, 24, 22, 25, 20,
141
+ 24, 22, 26, 26, 26, 0
142
+ ]
143
+
144
+ class << self
145
+ attr_accessor :_bel_trans_targs
146
+ private :_bel_trans_targs, :_bel_trans_targs=
147
+ end
148
+ self._bel_trans_targs = [
149
+ 0, 2, 3, 7, 0, 6, 3, 4,
150
+ 5, 0, 14, 0, 14, 6, 7, 2,
151
+ 0, 9, 15, 9, 0, 11, 11, 12,
152
+ 13, 16, 0
153
+ ]
154
+
155
+ class << self
156
+ attr_accessor :_bel_trans_actions
157
+ private :_bel_trans_actions, :_bel_trans_actions=
158
+ end
159
+ self._bel_trans_actions = [
160
+ 1, 0, 2, 3, 4, 3, 6, 6,
161
+ 6, 5, 7, 8, 9, 10, 10, 11,
162
+ 12, 3, 13, 10, 14, 2, 6, 6,
163
+ 6, 15, 0
164
+ ]
165
+
166
+ class << self
167
+ attr_accessor :_bel_eof_actions
168
+ private :_bel_eof_actions, :_bel_eof_actions=
169
+ end
170
+ self._bel_eof_actions = [
171
+ 0, 1, 4, 5, 5, 5, 8, 8,
172
+ 12, 12, 14, 14, 14, 14, 0, 0,
173
+ 0
174
+ ]
175
+
176
+ class << self
177
+ attr_accessor :bel_start
178
+ end
179
+ self.bel_start = 1;
180
+ class << self
181
+ attr_accessor :bel_first_final
182
+ end
183
+ self.bel_first_final = 14;
184
+ class << self
185
+ attr_accessor :bel_error
186
+ end
187
+ self.bel_error = 0;
188
+
189
+ class << self
190
+ attr_accessor :bel_en_ident
191
+ end
192
+ self.bel_en_ident = 8;
193
+ class << self
194
+ attr_accessor :bel_en_string
195
+ end
196
+ self.bel_en_string = 10;
197
+ class << self
198
+ attr_accessor :bel_en_bel_parameter
199
+ end
200
+ self.bel_en_bel_parameter = 1;
201
+
202
+
203
+ begin
204
+ p ||= 0
205
+ pe ||= data.length
206
+ cs = bel_start
207
+ end
208
+
209
+ begin
210
+ testEof = false
211
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
212
+ _goto_level = 0
213
+ _resume = 10
214
+ _eof_trans = 15
215
+ _again = 20
216
+ _test_eof = 30
217
+ _out = 40
218
+ while true
219
+ if _goto_level <= 0
220
+ if p == pe
221
+ _goto_level = _test_eof
222
+ next
223
+ end
224
+ if cs == 0
225
+ _goto_level = _out
226
+ next
227
+ end
228
+ end
229
+ if _goto_level <= _resume
230
+ _keys = cs << 1
231
+ _inds = _bel_index_offsets[cs]
232
+ _slen = _bel_key_spans[cs]
233
+ _wide = data[p].ord
234
+ _trans = if ( _slen > 0 &&
235
+ _bel_trans_keys[_keys] <= _wide &&
236
+ _wide <= _bel_trans_keys[_keys + 1]
237
+ ) then
238
+ _bel_indicies[ _inds + _wide - _bel_trans_keys[_keys] ]
239
+ else
240
+ _bel_indicies[ _inds + _slen ]
241
+ end
242
+ cs = _bel_trans_targs[_trans]
243
+ if _bel_trans_actions[_trans] != 0
244
+ case _bel_trans_actions[_trans]
245
+ when 10 then
246
+ begin
247
+
248
+ (@buffers[:ident] ||= []) << data[p].ord
249
+ end
250
+ when 8 then
251
+ begin
252
+
253
+ unless @buffers[:ident].is_a?(::AST::Node)
254
+ @buffers[:ident] ||= []
255
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
256
+ end
257
+ end
258
+ when 6 then
259
+ begin
260
+
261
+ (@buffers[:string] ||= []) << data[p].ord
262
+ end
263
+ when 5 then
264
+ begin
265
+
266
+ @buffers[:string] ||= []
267
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
268
+ end
269
+ when 3 then
270
+ begin
271
+
272
+ @buffers[:ident] = []
273
+ end
274
+ begin
275
+
276
+ (@buffers[:ident] ||= []) << data[p].ord
277
+ end
278
+ when 13 then
279
+ begin
280
+
281
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
282
+ end
283
+ begin
284
+
285
+ yield @buffers[:ident]
286
+ end
287
+ when 11 then
288
+ begin
289
+
290
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
291
+ end
292
+ begin
293
+
294
+ @buffers[:parameter] = parameter(prefix(@buffers[:ident]))
295
+ end
296
+ when 12 then
297
+ begin
298
+
299
+ unless @buffers[:ident].is_a?(::AST::Node)
300
+ @buffers[:ident] ||= []
301
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
302
+ end
303
+ end
304
+ begin
305
+
306
+ @buffers[:ident] ||= []
307
+ yield @buffers[:ident]
308
+ end
309
+ when 1 then
310
+ begin
311
+
312
+ unless @buffers[:ident].is_a?(::AST::Node)
313
+ @buffers[:ident] ||= []
314
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
315
+ end
316
+ end
317
+ begin
318
+
319
+ @buffers[:string] ||= []
320
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
321
+ end
322
+ when 2 then
323
+ begin
324
+
325
+ @buffers[:string] = []
326
+ end
327
+ begin
328
+
329
+ (@buffers[:string] ||= []) << data[p].ord
330
+ end
331
+ when 15 then
332
+ begin
333
+
334
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
335
+ end
336
+ begin
337
+
338
+ yield @buffers[:string]
339
+ end
340
+ when 4 then
341
+ begin
342
+
343
+ @buffers[:string] ||= []
344
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
345
+ end
346
+ begin
347
+
348
+ unless @buffers[:ident].is_a?(::AST::Node)
349
+ @buffers[:ident] ||= []
350
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
351
+ end
352
+ end
353
+ when 14 then
354
+ begin
355
+
356
+ @buffers[:string] ||= []
357
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
358
+ end
359
+ begin
360
+
361
+ @buffers[:string] ||= []
362
+ yield @buffers[:string]
363
+ end
364
+ when 9 then
365
+ begin
366
+
367
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
368
+ end
369
+ begin
370
+
371
+ @buffers[:parameter] ||= parameter(prefix(nil))
372
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:ident])
373
+ end
374
+ begin
375
+
376
+ yield @buffers[:parameter]
377
+ end
378
+ when 7 then
379
+ begin
380
+
381
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
382
+ end
383
+ begin
384
+
385
+ @buffers[:parameter] ||= parameter(prefix(nil))
386
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:string])
387
+ end
388
+ begin
389
+
390
+ yield @buffers[:parameter]
391
+ end
392
+ end
393
+ end
394
+ end
395
+ if _goto_level <= _again
396
+ if cs == 0
397
+ _goto_level = _out
398
+ next
399
+ end
400
+ p += 1
401
+ if p != pe
402
+ _goto_level = _resume
403
+ next
404
+ end
405
+ end
406
+ if _goto_level <= _test_eof
407
+ if p == eof
408
+ case _bel_eof_actions[cs]
409
+ when 8 then
410
+ begin
411
+
412
+ unless @buffers[:ident].is_a?(::AST::Node)
413
+ @buffers[:ident] ||= []
414
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
415
+ end
416
+ end
417
+ when 5 then
418
+ begin
419
+
420
+ @buffers[:string] ||= []
421
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
422
+ end
423
+ when 12 then
424
+ begin
425
+
426
+ unless @buffers[:ident].is_a?(::AST::Node)
427
+ @buffers[:ident] ||= []
428
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
429
+ end
430
+ end
431
+ begin
432
+
433
+ @buffers[:ident] ||= []
434
+ yield @buffers[:ident]
435
+ end
436
+ when 1 then
437
+ begin
438
+
439
+ unless @buffers[:ident].is_a?(::AST::Node)
440
+ @buffers[:ident] ||= []
441
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
442
+ end
443
+ end
444
+ begin
445
+
446
+ @buffers[:string] ||= []
447
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
448
+ end
449
+ when 4 then
450
+ begin
451
+
452
+ @buffers[:string] ||= []
453
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
454
+ end
455
+ begin
456
+
457
+ unless @buffers[:ident].is_a?(::AST::Node)
458
+ @buffers[:ident] ||= []
459
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
460
+ end
461
+ end
462
+ when 14 then
463
+ begin
464
+
465
+ @buffers[:string] ||= []
466
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
467
+ end
468
+ begin
469
+
470
+ @buffers[:string] ||= []
471
+ yield @buffers[:string]
472
+ end
473
+ end
474
+ end
475
+
476
+ end
477
+ if _goto_level <= _out
478
+ break
479
+ end
480
+ end
481
+ end
482
+
483
+ class << self
484
+ attr_accessor :_bel_trans_keys
485
+ private :_bel_trans_keys, :_bel_trans_keys=
486
+ end
487
+ self._bel_trans_keys = [
488
+ 0, 0, 9, 122, 9, 122,
489
+ 34, 92, 10, 10, 92,
490
+ 92, 10, 122, 10, 122,
491
+ 48, 122, 10, 122, 34, 34,
492
+ 34, 92, 10, 10, 92,
493
+ 92, 0, 0, 0, 0,
494
+ 0, 0, 0
495
+ ]
496
+
497
+ class << self
498
+ attr_accessor :_bel_key_spans
499
+ private :_bel_key_spans, :_bel_key_spans=
500
+ end
501
+ self._bel_key_spans = [
502
+ 0, 114, 114, 59, 1, 1, 113, 113,
503
+ 75, 113, 1, 59, 1, 1, 0, 0,
504
+ 0
505
+ ]
506
+
507
+ class << self
508
+ attr_accessor :_bel_index_offsets
509
+ private :_bel_index_offsets, :_bel_index_offsets=
510
+ end
511
+ self._bel_index_offsets = [
512
+ 0, 0, 115, 230, 290, 292, 294, 408,
513
+ 522, 598, 712, 714, 774, 776, 778, 779,
514
+ 780
515
+ ]
516
+
517
+ class << self
518
+ attr_accessor :_bel_indicies
519
+ private :_bel_indicies, :_bel_indicies=
520
+ end
521
+ self._bel_indicies = [
522
+ 1, 0, 0, 0, 0, 0, 0, 0,
523
+ 0, 0, 0, 0, 0, 0, 0, 0,
524
+ 0, 0, 0, 0, 0, 0, 0, 1,
525
+ 0, 2, 0, 0, 0, 0, 0, 0,
526
+ 0, 0, 0, 0, 0, 0, 0, 3,
527
+ 3, 3, 3, 3, 3, 3, 3, 3,
528
+ 3, 0, 0, 0, 0, 0, 0, 0,
529
+ 3, 3, 3, 3, 3, 3, 3, 3,
530
+ 3, 3, 3, 3, 3, 3, 3, 3,
531
+ 3, 3, 3, 3, 3, 3, 3, 3,
532
+ 3, 3, 0, 0, 0, 0, 3, 0,
533
+ 3, 3, 3, 3, 3, 3, 3, 3,
534
+ 3, 3, 3, 3, 3, 3, 3, 3,
535
+ 3, 3, 3, 3, 3, 3, 3, 3,
536
+ 3, 3, 0, 1, 4, 4, 4, 4,
537
+ 4, 4, 4, 4, 4, 4, 4, 4,
538
+ 4, 4, 4, 4, 4, 4, 4, 4,
539
+ 4, 4, 1, 4, 2, 4, 4, 4,
540
+ 4, 4, 4, 4, 4, 4, 4, 4,
541
+ 4, 4, 5, 5, 5, 5, 5, 5,
542
+ 5, 5, 5, 5, 4, 4, 4, 4,
543
+ 4, 4, 4, 5, 5, 5, 5, 5,
544
+ 5, 5, 5, 5, 5, 5, 5, 5,
545
+ 5, 5, 5, 5, 5, 5, 5, 5,
546
+ 5, 5, 5, 5, 5, 4, 4, 4,
547
+ 4, 5, 4, 5, 5, 5, 5, 5,
548
+ 5, 5, 5, 5, 5, 5, 5, 5,
549
+ 5, 5, 5, 5, 5, 5, 5, 5,
550
+ 5, 5, 5, 5, 5, 4, 7, 6,
551
+ 6, 6, 6, 6, 6, 6, 6, 6,
552
+ 6, 6, 6, 6, 6, 6, 6, 6,
553
+ 6, 6, 6, 6, 6, 6, 6, 6,
554
+ 6, 6, 6, 6, 6, 6, 6, 6,
555
+ 6, 6, 6, 6, 6, 6, 6, 6,
556
+ 6, 6, 6, 6, 6, 6, 6, 6,
557
+ 6, 6, 6, 6, 6, 6, 6, 6,
558
+ 8, 6, 10, 9, 8, 6, 12, 11,
559
+ 11, 11, 11, 11, 11, 11, 11, 11,
560
+ 11, 11, 11, 11, 11, 11, 11, 11,
561
+ 11, 11, 11, 11, 11, 11, 11, 11,
562
+ 11, 11, 11, 11, 11, 11, 11, 11,
563
+ 11, 11, 11, 11, 13, 13, 13, 13,
564
+ 13, 13, 13, 13, 13, 13, 11, 11,
565
+ 11, 11, 11, 11, 11, 13, 13, 13,
566
+ 13, 13, 13, 13, 13, 13, 13, 13,
567
+ 13, 13, 13, 13, 13, 13, 13, 13,
568
+ 13, 13, 13, 13, 13, 13, 13, 11,
569
+ 11, 11, 11, 13, 11, 13, 13, 13,
570
+ 13, 13, 13, 13, 13, 13, 13, 13,
571
+ 13, 13, 13, 13, 13, 13, 13, 13,
572
+ 13, 13, 13, 13, 13, 13, 13, 11,
573
+ 12, 11, 11, 11, 11, 11, 11, 11,
574
+ 11, 11, 11, 11, 11, 11, 11, 11,
575
+ 11, 11, 11, 11, 11, 11, 11, 11,
576
+ 11, 11, 11, 11, 11, 11, 11, 11,
577
+ 11, 11, 11, 11, 11, 11, 14, 14,
578
+ 14, 14, 14, 14, 14, 14, 14, 14,
579
+ 15, 11, 11, 11, 11, 11, 11, 14,
580
+ 14, 14, 14, 14, 14, 14, 14, 14,
581
+ 14, 14, 14, 14, 14, 14, 14, 14,
582
+ 14, 14, 14, 14, 14, 14, 14, 14,
583
+ 14, 11, 11, 11, 11, 14, 11, 14,
584
+ 14, 14, 14, 14, 14, 14, 14, 14,
585
+ 14, 14, 14, 14, 14, 14, 14, 14,
586
+ 14, 14, 14, 14, 14, 14, 14, 14,
587
+ 14, 11, 17, 17, 17, 17, 17, 17,
588
+ 17, 17, 17, 17, 16, 16, 16, 16,
589
+ 16, 16, 16, 17, 17, 17, 17, 17,
590
+ 17, 17, 17, 17, 17, 17, 17, 17,
591
+ 17, 17, 17, 17, 17, 17, 17, 17,
592
+ 17, 17, 17, 17, 17, 16, 16, 16,
593
+ 16, 17, 16, 17, 17, 17, 17, 17,
594
+ 17, 17, 17, 17, 17, 17, 17, 17,
595
+ 17, 17, 17, 17, 17, 17, 17, 17,
596
+ 17, 17, 17, 17, 17, 16, 18, 16,
597
+ 16, 16, 16, 16, 16, 16, 16, 16,
598
+ 16, 16, 16, 16, 16, 16, 16, 16,
599
+ 16, 16, 16, 16, 16, 16, 16, 16,
600
+ 16, 16, 16, 16, 16, 16, 16, 16,
601
+ 16, 16, 16, 16, 19, 19, 19, 19,
602
+ 19, 19, 19, 19, 19, 19, 16, 16,
603
+ 16, 16, 16, 16, 16, 19, 19, 19,
604
+ 19, 19, 19, 19, 19, 19, 19, 19,
605
+ 19, 19, 19, 19, 19, 19, 19, 19,
606
+ 19, 19, 19, 19, 19, 19, 19, 16,
607
+ 16, 16, 16, 19, 16, 19, 19, 19,
608
+ 19, 19, 19, 19, 19, 19, 19, 19,
609
+ 19, 19, 19, 19, 19, 19, 19, 19,
610
+ 19, 19, 19, 19, 19, 19, 19, 16,
611
+ 21, 20, 23, 22, 22, 22, 22, 22,
612
+ 22, 22, 22, 22, 22, 22, 22, 22,
613
+ 22, 22, 22, 22, 22, 22, 22, 22,
614
+ 22, 22, 22, 22, 22, 22, 22, 22,
615
+ 22, 22, 22, 22, 22, 22, 22, 22,
616
+ 22, 22, 22, 22, 22, 22, 22, 22,
617
+ 22, 22, 22, 22, 22, 22, 22, 22,
618
+ 22, 22, 22, 22, 24, 22, 25, 20,
619
+ 24, 22, 26, 26, 26, 0
620
+ ]
621
+
622
+ class << self
623
+ attr_accessor :_bel_trans_targs
624
+ private :_bel_trans_targs, :_bel_trans_targs=
625
+ end
626
+ self._bel_trans_targs = [
627
+ 0, 2, 3, 7, 0, 6, 3, 4,
628
+ 5, 0, 14, 0, 14, 6, 7, 2,
629
+ 0, 9, 15, 9, 0, 11, 11, 12,
630
+ 13, 16, 0
631
+ ]
632
+
633
+ class << self
634
+ attr_accessor :_bel_trans_actions
635
+ private :_bel_trans_actions, :_bel_trans_actions=
636
+ end
637
+ self._bel_trans_actions = [
638
+ 1, 0, 2, 3, 4, 3, 6, 6,
639
+ 6, 5, 7, 8, 9, 10, 10, 11,
640
+ 12, 3, 13, 10, 14, 2, 6, 6,
641
+ 6, 15, 0
642
+ ]
643
+
644
+ class << self
645
+ attr_accessor :_bel_eof_actions
646
+ private :_bel_eof_actions, :_bel_eof_actions=
647
+ end
648
+ self._bel_eof_actions = [
649
+ 0, 1, 4, 5, 5, 5, 8, 8,
650
+ 12, 12, 14, 14, 14, 14, 0, 0,
651
+ 0
652
+ ]
653
+
654
+ class << self
655
+ attr_accessor :bel_start
656
+ end
657
+ self.bel_start = 1;
658
+ class << self
659
+ attr_accessor :bel_first_final
660
+ end
661
+ self.bel_first_final = 14;
662
+ class << self
663
+ attr_accessor :bel_error
664
+ end
665
+ self.bel_error = 0;
666
+
667
+ class << self
668
+ attr_accessor :bel_en_ident
669
+ end
670
+ self.bel_en_ident = 8;
671
+ class << self
672
+ attr_accessor :bel_en_string
673
+ end
674
+ self.bel_en_string = 10;
675
+ class << self
676
+ attr_accessor :bel_en_bel_parameter
677
+ end
678
+ self.bel_en_bel_parameter = 1;
679
+
680
+
681
+ begin
682
+ p ||= 0
683
+ pe ||= data.length
684
+ cs = bel_start
685
+ end
686
+
687
+ begin
688
+ testEof = false
689
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
690
+ _goto_level = 0
691
+ _resume = 10
692
+ _eof_trans = 15
693
+ _again = 20
694
+ _test_eof = 30
695
+ _out = 40
696
+ while true
697
+ if _goto_level <= 0
698
+ if p == pe
699
+ _goto_level = _test_eof
700
+ next
701
+ end
702
+ if cs == 0
703
+ _goto_level = _out
704
+ next
705
+ end
706
+ end
707
+ if _goto_level <= _resume
708
+ _keys = cs << 1
709
+ _inds = _bel_index_offsets[cs]
710
+ _slen = _bel_key_spans[cs]
711
+ _wide = data[p].ord
712
+ _trans = if ( _slen > 0 &&
713
+ _bel_trans_keys[_keys] <= _wide &&
714
+ _wide <= _bel_trans_keys[_keys + 1]
715
+ ) then
716
+ _bel_indicies[ _inds + _wide - _bel_trans_keys[_keys] ]
717
+ else
718
+ _bel_indicies[ _inds + _slen ]
719
+ end
720
+ cs = _bel_trans_targs[_trans]
721
+ if _bel_trans_actions[_trans] != 0
722
+ case _bel_trans_actions[_trans]
723
+ when 10 then
724
+ begin
725
+
726
+ (@buffers[:ident] ||= []) << data[p].ord
727
+ end
728
+ when 8 then
729
+ begin
730
+
731
+ unless @buffers[:ident].is_a?(::AST::Node)
732
+ @buffers[:ident] ||= []
733
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
734
+ end
735
+ end
736
+ when 6 then
737
+ begin
738
+
739
+ (@buffers[:string] ||= []) << data[p].ord
740
+ end
741
+ when 5 then
742
+ begin
743
+
744
+ @buffers[:string] ||= []
745
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
746
+ end
747
+ when 3 then
748
+ begin
749
+
750
+ @buffers[:ident] = []
751
+ end
752
+ begin
753
+
754
+ (@buffers[:ident] ||= []) << data[p].ord
755
+ end
756
+ when 13 then
757
+ begin
758
+
759
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
760
+ end
761
+ begin
762
+
763
+ yield @buffers[:ident]
764
+ end
765
+ when 11 then
766
+ begin
767
+
768
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
769
+ end
770
+ begin
771
+
772
+ @buffers[:parameter] = parameter(prefix(@buffers[:ident]))
773
+ end
774
+ when 12 then
775
+ begin
776
+
777
+ unless @buffers[:ident].is_a?(::AST::Node)
778
+ @buffers[:ident] ||= []
779
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
780
+ end
781
+ end
782
+ begin
783
+
784
+ @buffers[:ident] ||= []
785
+ yield @buffers[:ident]
786
+ end
787
+ when 1 then
788
+ begin
789
+
790
+ unless @buffers[:ident].is_a?(::AST::Node)
791
+ @buffers[:ident] ||= []
792
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
793
+ end
794
+ end
795
+ begin
796
+
797
+ @buffers[:string] ||= []
798
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
799
+ end
800
+ when 2 then
801
+ begin
802
+
803
+ @buffers[:string] = []
804
+ end
805
+ begin
806
+
807
+ (@buffers[:string] ||= []) << data[p].ord
808
+ end
809
+ when 15 then
810
+ begin
811
+
812
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
813
+ end
814
+ begin
815
+
816
+ yield @buffers[:string]
817
+ end
818
+ when 4 then
819
+ begin
820
+
821
+ @buffers[:string] ||= []
822
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
823
+ end
824
+ begin
825
+
826
+ unless @buffers[:ident].is_a?(::AST::Node)
827
+ @buffers[:ident] ||= []
828
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
829
+ end
830
+ end
831
+ when 14 then
832
+ begin
833
+
834
+ @buffers[:string] ||= []
835
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
836
+ end
837
+ begin
838
+
839
+ @buffers[:string] ||= []
840
+ yield @buffers[:string]
841
+ end
842
+ when 9 then
843
+ begin
844
+
845
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
846
+ end
847
+ begin
848
+
849
+ @buffers[:parameter] ||= parameter(prefix(nil))
850
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:ident])
851
+ end
852
+ begin
853
+
854
+ yield @buffers[:parameter]
855
+ end
856
+ when 7 then
857
+ begin
858
+
859
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
860
+ end
861
+ begin
862
+
863
+ @buffers[:parameter] ||= parameter(prefix(nil))
864
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:string])
865
+ end
866
+ begin
867
+
868
+ yield @buffers[:parameter]
869
+ end
870
+ end
871
+ end
872
+ end
873
+ if _goto_level <= _again
874
+ if cs == 0
875
+ _goto_level = _out
876
+ next
877
+ end
878
+ p += 1
879
+ if p != pe
880
+ _goto_level = _resume
881
+ next
882
+ end
883
+ end
884
+ if _goto_level <= _test_eof
885
+ if p == eof
886
+ case _bel_eof_actions[cs]
887
+ when 8 then
888
+ begin
889
+
890
+ unless @buffers[:ident].is_a?(::AST::Node)
891
+ @buffers[:ident] ||= []
892
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
893
+ end
894
+ end
895
+ when 5 then
896
+ begin
897
+
898
+ @buffers[:string] ||= []
899
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
900
+ end
901
+ when 12 then
902
+ begin
903
+
904
+ unless @buffers[:ident].is_a?(::AST::Node)
905
+ @buffers[:ident] ||= []
906
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
907
+ end
908
+ end
909
+ begin
910
+
911
+ @buffers[:ident] ||= []
912
+ yield @buffers[:ident]
913
+ end
914
+ when 1 then
915
+ begin
916
+
917
+ unless @buffers[:ident].is_a?(::AST::Node)
918
+ @buffers[:ident] ||= []
919
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
920
+ end
921
+ end
922
+ begin
923
+
924
+ @buffers[:string] ||= []
925
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
926
+ end
927
+ when 4 then
928
+ begin
929
+
930
+ @buffers[:string] ||= []
931
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
932
+ end
933
+ begin
934
+
935
+ unless @buffers[:ident].is_a?(::AST::Node)
936
+ @buffers[:ident] ||= []
937
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
938
+ end
939
+ end
940
+ when 14 then
941
+ begin
942
+
943
+ @buffers[:string] ||= []
944
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
945
+ end
946
+ begin
947
+
948
+ @buffers[:string] ||= []
949
+ yield @buffers[:string]
950
+ end
951
+ end
952
+ end
953
+
954
+ end
955
+ if _goto_level <= _out
956
+ break
957
+ end
958
+ end
959
+ end
960
+
961
+
962
+ =end
963
+ # end: ragel
964
+
965
+ require_relative '../ast/node'
966
+ require_relative '../mixin/buffer'
967
+ require_relative '../nonblocking_io_wrapper'
968
+
969
+ module BELParser
970
+ module Parsers
971
+ module Expression
972
+ module Parameter
973
+
974
+ class << self
975
+
976
+ MAX_LENGTH = 1024 * 128 # 128K
977
+
978
+ def parse(content)
979
+ return nil unless content
980
+
981
+ Parser.new(content).each do |obj|
982
+ yield obj
983
+ end
984
+ end
985
+ end
986
+
987
+ private
988
+
989
+ class Parser
990
+ include Enumerable
991
+ include BELParser::Parsers::Buffer
992
+ include BELParser::Parsers::AST::Sexp
993
+
994
+ def initialize(content)
995
+ @content = content
996
+ # begin: ragel
997
+
998
+ class << self
999
+ attr_accessor :_bel_trans_keys
1000
+ private :_bel_trans_keys, :_bel_trans_keys=
1001
+ end
1002
+ self._bel_trans_keys = [
1003
+ 0, 0, 9, 122, 9, 122,
1004
+ 34, 92, 10, 10, 92,
1005
+ 92, 10, 122, 10, 122,
1006
+ 48, 122, 10, 122, 34, 34,
1007
+ 34, 92, 10, 10, 92,
1008
+ 92, 0, 0, 0, 0,
1009
+ 0, 0, 0
1010
+ ]
1011
+
1012
+ class << self
1013
+ attr_accessor :_bel_key_spans
1014
+ private :_bel_key_spans, :_bel_key_spans=
1015
+ end
1016
+ self._bel_key_spans = [
1017
+ 0, 114, 114, 59, 1, 1, 113, 113,
1018
+ 75, 113, 1, 59, 1, 1, 0, 0,
1019
+ 0
1020
+ ]
1021
+
1022
+ class << self
1023
+ attr_accessor :_bel_index_offsets
1024
+ private :_bel_index_offsets, :_bel_index_offsets=
1025
+ end
1026
+ self._bel_index_offsets = [
1027
+ 0, 0, 115, 230, 290, 292, 294, 408,
1028
+ 522, 598, 712, 714, 774, 776, 778, 779,
1029
+ 780
1030
+ ]
1031
+
1032
+ class << self
1033
+ attr_accessor :_bel_indicies
1034
+ private :_bel_indicies, :_bel_indicies=
1035
+ end
1036
+ self._bel_indicies = [
1037
+ 1, 0, 0, 0, 0, 0, 0, 0,
1038
+ 0, 0, 0, 0, 0, 0, 0, 0,
1039
+ 0, 0, 0, 0, 0, 0, 0, 1,
1040
+ 0, 2, 0, 0, 0, 0, 0, 0,
1041
+ 0, 0, 0, 0, 0, 0, 0, 3,
1042
+ 3, 3, 3, 3, 3, 3, 3, 3,
1043
+ 3, 0, 0, 0, 0, 0, 0, 0,
1044
+ 3, 3, 3, 3, 3, 3, 3, 3,
1045
+ 3, 3, 3, 3, 3, 3, 3, 3,
1046
+ 3, 3, 3, 3, 3, 3, 3, 3,
1047
+ 3, 3, 0, 0, 0, 0, 3, 0,
1048
+ 3, 3, 3, 3, 3, 3, 3, 3,
1049
+ 3, 3, 3, 3, 3, 3, 3, 3,
1050
+ 3, 3, 3, 3, 3, 3, 3, 3,
1051
+ 3, 3, 0, 1, 4, 4, 4, 4,
1052
+ 4, 4, 4, 4, 4, 4, 4, 4,
1053
+ 4, 4, 4, 4, 4, 4, 4, 4,
1054
+ 4, 4, 1, 4, 2, 4, 4, 4,
1055
+ 4, 4, 4, 4, 4, 4, 4, 4,
1056
+ 4, 4, 5, 5, 5, 5, 5, 5,
1057
+ 5, 5, 5, 5, 4, 4, 4, 4,
1058
+ 4, 4, 4, 5, 5, 5, 5, 5,
1059
+ 5, 5, 5, 5, 5, 5, 5, 5,
1060
+ 5, 5, 5, 5, 5, 5, 5, 5,
1061
+ 5, 5, 5, 5, 5, 4, 4, 4,
1062
+ 4, 5, 4, 5, 5, 5, 5, 5,
1063
+ 5, 5, 5, 5, 5, 5, 5, 5,
1064
+ 5, 5, 5, 5, 5, 5, 5, 5,
1065
+ 5, 5, 5, 5, 5, 4, 7, 6,
1066
+ 6, 6, 6, 6, 6, 6, 6, 6,
1067
+ 6, 6, 6, 6, 6, 6, 6, 6,
1068
+ 6, 6, 6, 6, 6, 6, 6, 6,
1069
+ 6, 6, 6, 6, 6, 6, 6, 6,
1070
+ 6, 6, 6, 6, 6, 6, 6, 6,
1071
+ 6, 6, 6, 6, 6, 6, 6, 6,
1072
+ 6, 6, 6, 6, 6, 6, 6, 6,
1073
+ 8, 6, 10, 9, 8, 6, 12, 11,
1074
+ 11, 11, 11, 11, 11, 11, 11, 11,
1075
+ 11, 11, 11, 11, 11, 11, 11, 11,
1076
+ 11, 11, 11, 11, 11, 11, 11, 11,
1077
+ 11, 11, 11, 11, 11, 11, 11, 11,
1078
+ 11, 11, 11, 11, 13, 13, 13, 13,
1079
+ 13, 13, 13, 13, 13, 13, 11, 11,
1080
+ 11, 11, 11, 11, 11, 13, 13, 13,
1081
+ 13, 13, 13, 13, 13, 13, 13, 13,
1082
+ 13, 13, 13, 13, 13, 13, 13, 13,
1083
+ 13, 13, 13, 13, 13, 13, 13, 11,
1084
+ 11, 11, 11, 13, 11, 13, 13, 13,
1085
+ 13, 13, 13, 13, 13, 13, 13, 13,
1086
+ 13, 13, 13, 13, 13, 13, 13, 13,
1087
+ 13, 13, 13, 13, 13, 13, 13, 11,
1088
+ 12, 11, 11, 11, 11, 11, 11, 11,
1089
+ 11, 11, 11, 11, 11, 11, 11, 11,
1090
+ 11, 11, 11, 11, 11, 11, 11, 11,
1091
+ 11, 11, 11, 11, 11, 11, 11, 11,
1092
+ 11, 11, 11, 11, 11, 11, 14, 14,
1093
+ 14, 14, 14, 14, 14, 14, 14, 14,
1094
+ 15, 11, 11, 11, 11, 11, 11, 14,
1095
+ 14, 14, 14, 14, 14, 14, 14, 14,
1096
+ 14, 14, 14, 14, 14, 14, 14, 14,
1097
+ 14, 14, 14, 14, 14, 14, 14, 14,
1098
+ 14, 11, 11, 11, 11, 14, 11, 14,
1099
+ 14, 14, 14, 14, 14, 14, 14, 14,
1100
+ 14, 14, 14, 14, 14, 14, 14, 14,
1101
+ 14, 14, 14, 14, 14, 14, 14, 14,
1102
+ 14, 11, 17, 17, 17, 17, 17, 17,
1103
+ 17, 17, 17, 17, 16, 16, 16, 16,
1104
+ 16, 16, 16, 17, 17, 17, 17, 17,
1105
+ 17, 17, 17, 17, 17, 17, 17, 17,
1106
+ 17, 17, 17, 17, 17, 17, 17, 17,
1107
+ 17, 17, 17, 17, 17, 16, 16, 16,
1108
+ 16, 17, 16, 17, 17, 17, 17, 17,
1109
+ 17, 17, 17, 17, 17, 17, 17, 17,
1110
+ 17, 17, 17, 17, 17, 17, 17, 17,
1111
+ 17, 17, 17, 17, 17, 16, 18, 16,
1112
+ 16, 16, 16, 16, 16, 16, 16, 16,
1113
+ 16, 16, 16, 16, 16, 16, 16, 16,
1114
+ 16, 16, 16, 16, 16, 16, 16, 16,
1115
+ 16, 16, 16, 16, 16, 16, 16, 16,
1116
+ 16, 16, 16, 16, 19, 19, 19, 19,
1117
+ 19, 19, 19, 19, 19, 19, 16, 16,
1118
+ 16, 16, 16, 16, 16, 19, 19, 19,
1119
+ 19, 19, 19, 19, 19, 19, 19, 19,
1120
+ 19, 19, 19, 19, 19, 19, 19, 19,
1121
+ 19, 19, 19, 19, 19, 19, 19, 16,
1122
+ 16, 16, 16, 19, 16, 19, 19, 19,
1123
+ 19, 19, 19, 19, 19, 19, 19, 19,
1124
+ 19, 19, 19, 19, 19, 19, 19, 19,
1125
+ 19, 19, 19, 19, 19, 19, 19, 16,
1126
+ 21, 20, 23, 22, 22, 22, 22, 22,
1127
+ 22, 22, 22, 22, 22, 22, 22, 22,
1128
+ 22, 22, 22, 22, 22, 22, 22, 22,
1129
+ 22, 22, 22, 22, 22, 22, 22, 22,
1130
+ 22, 22, 22, 22, 22, 22, 22, 22,
1131
+ 22, 22, 22, 22, 22, 22, 22, 22,
1132
+ 22, 22, 22, 22, 22, 22, 22, 22,
1133
+ 22, 22, 22, 22, 24, 22, 25, 20,
1134
+ 24, 22, 26, 26, 26, 0
1135
+ ]
1136
+
1137
+ class << self
1138
+ attr_accessor :_bel_trans_targs
1139
+ private :_bel_trans_targs, :_bel_trans_targs=
1140
+ end
1141
+ self._bel_trans_targs = [
1142
+ 0, 2, 3, 7, 0, 6, 3, 4,
1143
+ 5, 0, 14, 0, 14, 6, 7, 2,
1144
+ 0, 9, 15, 9, 0, 11, 11, 12,
1145
+ 13, 16, 0
1146
+ ]
1147
+
1148
+ class << self
1149
+ attr_accessor :_bel_trans_actions
1150
+ private :_bel_trans_actions, :_bel_trans_actions=
1151
+ end
1152
+ self._bel_trans_actions = [
1153
+ 1, 0, 2, 3, 4, 3, 6, 6,
1154
+ 6, 5, 7, 8, 9, 10, 10, 11,
1155
+ 12, 3, 13, 10, 14, 2, 6, 6,
1156
+ 6, 15, 0
1157
+ ]
1158
+
1159
+ class << self
1160
+ attr_accessor :_bel_eof_actions
1161
+ private :_bel_eof_actions, :_bel_eof_actions=
1162
+ end
1163
+ self._bel_eof_actions = [
1164
+ 0, 1, 4, 5, 5, 5, 8, 8,
1165
+ 12, 12, 14, 14, 14, 14, 0, 0,
1166
+ 0
1167
+ ]
1168
+
1169
+ class << self
1170
+ attr_accessor :bel_start
1171
+ end
1172
+ self.bel_start = 1;
1173
+ class << self
1174
+ attr_accessor :bel_first_final
1175
+ end
1176
+ self.bel_first_final = 14;
1177
+ class << self
1178
+ attr_accessor :bel_error
1179
+ end
1180
+ self.bel_error = 0;
1181
+
1182
+ class << self
1183
+ attr_accessor :bel_en_ident
1184
+ end
1185
+ self.bel_en_ident = 8;
1186
+ class << self
1187
+ attr_accessor :bel_en_string
1188
+ end
1189
+ self.bel_en_string = 10;
1190
+ class << self
1191
+ attr_accessor :bel_en_bel_parameter
1192
+ end
1193
+ self.bel_en_bel_parameter = 1;
1194
+
1195
+
1196
+ # end: ragel
1197
+ end
1198
+
1199
+ def each
1200
+ @buffers = {}
1201
+ data = @content.unpack('C*')
1202
+ p = 0
1203
+ pe = data.length
1204
+ eof = data.length
1205
+
1206
+ # begin: ragel
1207
+
1208
+ begin
1209
+ p ||= 0
1210
+ pe ||= data.length
1211
+ cs = bel_start
1212
+ end
1213
+
1214
+
1215
+ begin
1216
+ testEof = false
1217
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
1218
+ _goto_level = 0
1219
+ _resume = 10
1220
+ _eof_trans = 15
1221
+ _again = 20
1222
+ _test_eof = 30
1223
+ _out = 40
1224
+ while true
1225
+ if _goto_level <= 0
1226
+ if p == pe
1227
+ _goto_level = _test_eof
1228
+ next
1229
+ end
1230
+ if cs == 0
1231
+ _goto_level = _out
1232
+ next
1233
+ end
1234
+ end
1235
+ if _goto_level <= _resume
1236
+ _keys = cs << 1
1237
+ _inds = _bel_index_offsets[cs]
1238
+ _slen = _bel_key_spans[cs]
1239
+ _wide = data[p].ord
1240
+ _trans = if ( _slen > 0 &&
1241
+ _bel_trans_keys[_keys] <= _wide &&
1242
+ _wide <= _bel_trans_keys[_keys + 1]
1243
+ ) then
1244
+ _bel_indicies[ _inds + _wide - _bel_trans_keys[_keys] ]
1245
+ else
1246
+ _bel_indicies[ _inds + _slen ]
1247
+ end
1248
+ cs = _bel_trans_targs[_trans]
1249
+ if _bel_trans_actions[_trans] != 0
1250
+ case _bel_trans_actions[_trans]
1251
+ when 10 then
1252
+ begin
1253
+
1254
+ (@buffers[:ident] ||= []) << data[p].ord
1255
+ end
1256
+ when 8 then
1257
+ begin
1258
+
1259
+ unless @buffers[:ident].is_a?(::AST::Node)
1260
+ @buffers[:ident] ||= []
1261
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1262
+ end
1263
+ end
1264
+ when 6 then
1265
+ begin
1266
+
1267
+ (@buffers[:string] ||= []) << data[p].ord
1268
+ end
1269
+ when 5 then
1270
+ begin
1271
+
1272
+ @buffers[:string] ||= []
1273
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1274
+ end
1275
+ when 3 then
1276
+ begin
1277
+
1278
+ @buffers[:ident] = []
1279
+ end
1280
+ begin
1281
+
1282
+ (@buffers[:ident] ||= []) << data[p].ord
1283
+ end
1284
+ when 13 then
1285
+ begin
1286
+
1287
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
1288
+ end
1289
+ begin
1290
+
1291
+ yield @buffers[:ident]
1292
+ end
1293
+ when 11 then
1294
+ begin
1295
+
1296
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
1297
+ end
1298
+ begin
1299
+
1300
+ @buffers[:parameter] = parameter(prefix(@buffers[:ident]))
1301
+ end
1302
+ when 12 then
1303
+ begin
1304
+
1305
+ unless @buffers[:ident].is_a?(::AST::Node)
1306
+ @buffers[:ident] ||= []
1307
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1308
+ end
1309
+ end
1310
+ begin
1311
+
1312
+ @buffers[:ident] ||= []
1313
+ yield @buffers[:ident]
1314
+ end
1315
+ when 1 then
1316
+ begin
1317
+
1318
+ unless @buffers[:ident].is_a?(::AST::Node)
1319
+ @buffers[:ident] ||= []
1320
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1321
+ end
1322
+ end
1323
+ begin
1324
+
1325
+ @buffers[:string] ||= []
1326
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1327
+ end
1328
+ when 2 then
1329
+ begin
1330
+
1331
+ @buffers[:string] = []
1332
+ end
1333
+ begin
1334
+
1335
+ (@buffers[:string] ||= []) << data[p].ord
1336
+ end
1337
+ when 15 then
1338
+ begin
1339
+
1340
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
1341
+ end
1342
+ begin
1343
+
1344
+ yield @buffers[:string]
1345
+ end
1346
+ when 4 then
1347
+ begin
1348
+
1349
+ @buffers[:string] ||= []
1350
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1351
+ end
1352
+ begin
1353
+
1354
+ unless @buffers[:ident].is_a?(::AST::Node)
1355
+ @buffers[:ident] ||= []
1356
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1357
+ end
1358
+ end
1359
+ when 14 then
1360
+ begin
1361
+
1362
+ @buffers[:string] ||= []
1363
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1364
+ end
1365
+ begin
1366
+
1367
+ @buffers[:string] ||= []
1368
+ yield @buffers[:string]
1369
+ end
1370
+ when 9 then
1371
+ begin
1372
+
1373
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
1374
+ end
1375
+ begin
1376
+
1377
+ @buffers[:parameter] ||= parameter(prefix(nil))
1378
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:ident])
1379
+ end
1380
+ begin
1381
+
1382
+ yield @buffers[:parameter]
1383
+ end
1384
+ when 7 then
1385
+ begin
1386
+
1387
+ @buffers[:string] = string(utf8_string(@buffers[:string]))
1388
+ end
1389
+ begin
1390
+
1391
+ @buffers[:parameter] ||= parameter(prefix(nil))
1392
+ @buffers[:parameter] = @buffers[:parameter] << value(@buffers[:string])
1393
+ end
1394
+ begin
1395
+
1396
+ yield @buffers[:parameter]
1397
+ end
1398
+ end
1399
+ end
1400
+ end
1401
+ if _goto_level <= _again
1402
+ if cs == 0
1403
+ _goto_level = _out
1404
+ next
1405
+ end
1406
+ p += 1
1407
+ if p != pe
1408
+ _goto_level = _resume
1409
+ next
1410
+ end
1411
+ end
1412
+ if _goto_level <= _test_eof
1413
+ if p == eof
1414
+ case _bel_eof_actions[cs]
1415
+ when 8 then
1416
+ begin
1417
+
1418
+ unless @buffers[:ident].is_a?(::AST::Node)
1419
+ @buffers[:ident] ||= []
1420
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1421
+ end
1422
+ end
1423
+ when 5 then
1424
+ begin
1425
+
1426
+ @buffers[:string] ||= []
1427
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1428
+ end
1429
+ when 12 then
1430
+ begin
1431
+
1432
+ unless @buffers[:ident].is_a?(::AST::Node)
1433
+ @buffers[:ident] ||= []
1434
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1435
+ end
1436
+ end
1437
+ begin
1438
+
1439
+ @buffers[:ident] ||= []
1440
+ yield @buffers[:ident]
1441
+ end
1442
+ when 1 then
1443
+ begin
1444
+
1445
+ unless @buffers[:ident].is_a?(::AST::Node)
1446
+ @buffers[:ident] ||= []
1447
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1448
+ end
1449
+ end
1450
+ begin
1451
+
1452
+ @buffers[:string] ||= []
1453
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1454
+ end
1455
+ when 4 then
1456
+ begin
1457
+
1458
+ @buffers[:string] ||= []
1459
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1460
+ end
1461
+ begin
1462
+
1463
+ unless @buffers[:ident].is_a?(::AST::Node)
1464
+ @buffers[:ident] ||= []
1465
+ @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
1466
+ end
1467
+ end
1468
+ when 14 then
1469
+ begin
1470
+
1471
+ @buffers[:string] ||= []
1472
+ @buffers[:string] = string(utf8_string(@buffers[:string]).sub(/\n$/, ''))
1473
+ end
1474
+ begin
1475
+
1476
+ @buffers[:string] ||= []
1477
+ yield @buffers[:string]
1478
+ end
1479
+ end
1480
+ end
1481
+
1482
+ end
1483
+ if _goto_level <= _out
1484
+ break
1485
+ end
1486
+ end
1487
+ end
1488
+
1489
+ # end: ragel
1490
+ end
1491
+ end
1492
+ end
1493
+ end
1494
+ end
1495
+ end
1496
+
1497
+ if __FILE__ == $0
1498
+ $stdin.each_line do |line|
1499
+ BELParser::Parsers::Expression::Parameter.parse(line) { |obj|
1500
+ puts obj.inspect
1501
+ }
1502
+ end
1503
+ end
1504
+
1505
+ # vim: ft=ruby ts=2 sw=2:
1506
+ # encoding: utf-8