opencode-pine2pyne 0.2.3__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/PKG-INFO +6 -5
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/README.md +5 -4
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/PKG-INFO +6 -5
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/SOURCES.txt +13 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/__init__.py +1 -1
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/codegen.py +3 -6
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/import_resolver.py +26 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/legacy_function_names.py +9 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/lexer.py +10 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/library_collision.py +15 -0
- opencode_pine2pyne-0.2.5/pine2pyne/merged_namespace_heads.py +35 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/parse_repair.py +16 -11
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/parser.py +53 -30
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/pine_builtins.py +12 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/scope_renamer.py +65 -6
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/transformer.py +73 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_codegen.py +6 -3
- opencode_pine2pyne-0.2.5/tests/test_color_literal_form.py +160 -0
- opencode_pine2pyne-0.2.5/tests/test_iff_function.py +240 -0
- opencode_pine2pyne-0.2.5/tests/test_input_and_parameter_named_like_a_function_card119.py +159 -0
- opencode_pine2pyne-0.2.5/tests/test_input_and_parameter_named_like_a_function_structure_card119.py +136 -0
- opencode_pine2pyne-0.2.5/tests/test_library_alias_fresh_process.py +193 -0
- opencode_pine2pyne-0.2.5/tests/test_library_alias_naming_a_namespace.py +110 -0
- opencode_pine2pyne-0.2.5/tests/test_library_alias_naming_a_namespace_runtime.py +36 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_library_boundary_runtime.py +4 -9
- opencode_pine2pyne-0.2.5/tests/test_merge_conflict_marker.py +44 -0
- opencode_pine2pyne-0.2.5/tests/test_one_line_function_declaration_body.py +147 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_parse_repair_card55.py +3 -3
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_parser.py +4 -2
- opencode_pine2pyne-0.2.5/tests/test_plain_input_parameter.py +176 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_scope_renamer.py +2 -2
- opencode_pine2pyne-0.2.5/tests/test_syminfo_symbol_function_form.py +179 -0
- opencode_pine2pyne-0.2.5/tests/test_unicode_space_separator.py +93 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/LICENSE +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/dependency_links.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/entry_points.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/requires.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/top_level.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/README.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/TRANSPILER_BEST_PRACTICES.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/TRANSPILER_USAGE.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/__main__.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/ast_nodes.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/ast_walk.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/block_value_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/bool_builtins.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/bool_value_typing.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/cli.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/conditional_history_calls.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/emitted_names.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/errors.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/for_loop_end_bound.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/grouped_history_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/namespace_members.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/once_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/overload_resolution.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/pine_semantics.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/strategy_when_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/strict_boolean.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/symbol_table.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/tokens.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/type_inference.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pine2pyne/udt_field_defaults.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/pyproject.toml +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/setup.cfg +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_assignment_to_a_call_result_field.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_block_tail_value_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_block_value_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_builtin_named_function_and_enum_input.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_cli.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_codegen_operator_grouping.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_codegen_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_collect_bool_annotations.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_collect_namespace_members.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_compare_ground_truth_completeness.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_conditional_history_call_warning.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_corpus_regression.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_dotted_udt_default_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_drawing_receiver_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_emitted_name_collision_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_emitted_name_plan.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_error_demo_claims.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_error_demo_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_errors.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_for_in_pairs_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_for_loop_dynamic_end_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_function_tail_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_generated_tables.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_check_no_output.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_check_own_directory.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_digests.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_manifest_order.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_no_output.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_nondeterministic_marks.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_pynecore_commit.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_run_dir_isolation.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_settings.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ground_truth_wrapper_retired.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_grouped_history_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_grouped_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_import_resolver.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_input_constant_and_enum_order_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_input_history_read_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_input_numeric_positional_binding.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_legacy_unprefixed_functions_card116.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_lexer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_library_name_collision.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_library_name_collision_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_local_named_like_a_function_card118.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_loop_and_array_edge_cases.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_loop_counter_history_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_method_namespaces.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_method_receiver_shape_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_method_routing_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_once_structure_parser.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_once_structure_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_overload_dispatch_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_overload_resolution.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_parser_positions.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_pine_builtins.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_pine_semantics.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_release_artifact_grouping.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_runtime_floor.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_scope_model_drift.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_script_declaration_binding.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_shadowing_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_strategy_when_argument_card117.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_strict_and_or_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_suite_harness_exit_verdict.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_suite_report_compare.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_switch_subject_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_symbol_table.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_ta_conditional_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_transformer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_transformer_receiver_typing.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_transformer_single_use.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_tuple_target_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_type_as_identifier_card115.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_udt_array_new_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_udt_bool_field_default_by_version_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_udt_field_defaults_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_udt_field_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_udt_type_proof.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_untyped_na_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_user_declaration_shadows_builtin_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_v5_bool_cast_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_var_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/tests/test_variable_function_runtime.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencode-pine2pyne
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Pine Script v6 to PyneCore Python transpiler
|
|
5
5
|
Author: rubycell
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -35,9 +35,10 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
35
35
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
36
36
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
37
37
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
38
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
39
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
40
|
-
|
|
38
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.5` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
39
|
+
Live PyPI state is UNVERIFIED: 0.2.5 is prepared (commit and branch `worker/Worker1ForPine2Pyne/release-0-2-5-rebased`), not
|
|
40
|
+
uploaded and not tagged. 0.2.4 is on PyPI (the simple index lists 0.1.0 to 0.2.4; tag `v0.2.4` is pushed).
|
|
41
|
+
`CHANGELOG.md` lists the changes since 0.2.4 under 0.2.5; the tag `v0.2.4` is the release before them.
|
|
41
42
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
42
43
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
43
44
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
|
@@ -211,7 +212,7 @@ There are three test systems. A green run of one says nothing about the others.
|
|
|
211
212
|
Reports go to `test_results{,_pds}.{json,txt}` at the repo root (git-ignored), or into `--run-dir`.
|
|
212
213
|
- Latest local reports, 2026-10-02 08:45 (`test_results.json`, `test_results_pds.json`; local files, not tracked):
|
|
213
214
|
- `sample/pinescript`: 411 run, 2 skipped, 411 transpiled, 393 passed, 18 failed
|
|
214
|
-
(11 `pynecore_api`,
|
|
215
|
+
(11 `pynecore_api`, 7 `missing_security_data`).
|
|
215
216
|
- `sample_pds`: 328 run, 3 skipped, 319 transpiled, 322 passed, 6 failed (all `missing_security_data`).
|
|
216
217
|
Of the 322 passes, 304 ran clean and 18 are expected-error samples (`expect_error` in
|
|
217
218
|
`tools/sample_expectations.toml`): 9 `pine_refusal` (transpile refused, so not in the 319),
|
|
@@ -15,9 +15,10 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
15
15
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
16
16
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
17
17
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
18
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
19
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
20
|
-
|
|
18
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.5` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
19
|
+
Live PyPI state is UNVERIFIED: 0.2.5 is prepared (commit and branch `worker/Worker1ForPine2Pyne/release-0-2-5-rebased`), not
|
|
20
|
+
uploaded and not tagged. 0.2.4 is on PyPI (the simple index lists 0.1.0 to 0.2.4; tag `v0.2.4` is pushed).
|
|
21
|
+
`CHANGELOG.md` lists the changes since 0.2.4 under 0.2.5; the tag `v0.2.4` is the release before them.
|
|
21
22
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
22
23
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
23
24
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
|
@@ -191,7 +192,7 @@ There are three test systems. A green run of one says nothing about the others.
|
|
|
191
192
|
Reports go to `test_results{,_pds}.{json,txt}` at the repo root (git-ignored), or into `--run-dir`.
|
|
192
193
|
- Latest local reports, 2026-10-02 08:45 (`test_results.json`, `test_results_pds.json`; local files, not tracked):
|
|
193
194
|
- `sample/pinescript`: 411 run, 2 skipped, 411 transpiled, 393 passed, 18 failed
|
|
194
|
-
(11 `pynecore_api`,
|
|
195
|
+
(11 `pynecore_api`, 7 `missing_security_data`).
|
|
195
196
|
- `sample_pds`: 328 run, 3 skipped, 319 transpiled, 322 passed, 6 failed (all `missing_security_data`).
|
|
196
197
|
Of the 322 passes, 304 ran clean and 18 are expected-error samples (`expect_error` in
|
|
197
198
|
`tools/sample_expectations.toml`): 9 `pine_refusal` (transpile refused, so not in the 319),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencode-pine2pyne
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Pine Script v6 to PyneCore Python transpiler
|
|
5
5
|
Author: rubycell
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -35,9 +35,10 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
35
35
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
36
36
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
37
37
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
38
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
39
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
40
|
-
|
|
38
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.5` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
39
|
+
Live PyPI state is UNVERIFIED: 0.2.5 is prepared (commit and branch `worker/Worker1ForPine2Pyne/release-0-2-5-rebased`), not
|
|
40
|
+
uploaded and not tagged. 0.2.4 is on PyPI (the simple index lists 0.1.0 to 0.2.4; tag `v0.2.4` is pushed).
|
|
41
|
+
`CHANGELOG.md` lists the changes since 0.2.4 under 0.2.5; the tag `v0.2.4` is the release before them.
|
|
41
42
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
42
43
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
43
44
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
|
@@ -211,7 +212,7 @@ There are three test systems. A green run of one says nothing about the others.
|
|
|
211
212
|
Reports go to `test_results{,_pds}.{json,txt}` at the repo root (git-ignored), or into `--run-dir`.
|
|
212
213
|
- Latest local reports, 2026-10-02 08:45 (`test_results.json`, `test_results_pds.json`; local files, not tracked):
|
|
213
214
|
- `sample/pinescript`: 411 run, 2 skipped, 411 transpiled, 393 passed, 18 failed
|
|
214
|
-
(11 `pynecore_api`,
|
|
215
|
+
(11 `pynecore_api`, 7 `missing_security_data`).
|
|
215
216
|
- `sample_pds`: 328 run, 3 skipped, 319 transpiled, 322 passed, 6 failed (all `missing_security_data`).
|
|
216
217
|
Of the 322 passes, 304 ran clean and 18 are expected-error samples (`expect_error` in
|
|
217
218
|
`tools/sample_expectations.toml`): 9 `pine_refusal` (transpile refused, so not in the 319),
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.5}/opencode_pine2pyne.egg-info/SOURCES.txt
RENAMED
|
@@ -28,6 +28,7 @@ pine2pyne/import_resolver.py
|
|
|
28
28
|
pine2pyne/legacy_function_names.py
|
|
29
29
|
pine2pyne/lexer.py
|
|
30
30
|
pine2pyne/library_collision.py
|
|
31
|
+
pine2pyne/merged_namespace_heads.py
|
|
31
32
|
pine2pyne/namespace_members.py
|
|
32
33
|
pine2pyne/once_lowering.py
|
|
33
34
|
pine2pyne/overload_resolution.py
|
|
@@ -53,6 +54,7 @@ tests/test_codegen_operator_grouping.py
|
|
|
53
54
|
tests/test_codegen_refusal.py
|
|
54
55
|
tests/test_collect_bool_annotations.py
|
|
55
56
|
tests/test_collect_namespace_members.py
|
|
57
|
+
tests/test_color_literal_form.py
|
|
56
58
|
tests/test_compare_ground_truth_completeness.py
|
|
57
59
|
tests/test_conditional_history_call_warning.py
|
|
58
60
|
tests/test_corpus_regression.py
|
|
@@ -79,23 +81,31 @@ tests/test_ground_truth_settings.py
|
|
|
79
81
|
tests/test_ground_truth_wrapper_retired.py
|
|
80
82
|
tests/test_grouped_history_lowering.py
|
|
81
83
|
tests/test_grouped_history_runtime.py
|
|
84
|
+
tests/test_iff_function.py
|
|
82
85
|
tests/test_import_resolver.py
|
|
86
|
+
tests/test_input_and_parameter_named_like_a_function_card119.py
|
|
87
|
+
tests/test_input_and_parameter_named_like_a_function_structure_card119.py
|
|
83
88
|
tests/test_input_constant_and_enum_order_runtime.py
|
|
84
89
|
tests/test_input_history_read_runtime.py
|
|
85
90
|
tests/test_input_numeric_positional_binding.py
|
|
86
91
|
tests/test_legacy_unprefixed_functions_card116.py
|
|
87
92
|
tests/test_lexer.py
|
|
93
|
+
tests/test_library_alias_fresh_process.py
|
|
94
|
+
tests/test_library_alias_naming_a_namespace.py
|
|
95
|
+
tests/test_library_alias_naming_a_namespace_runtime.py
|
|
88
96
|
tests/test_library_boundary_runtime.py
|
|
89
97
|
tests/test_library_name_collision.py
|
|
90
98
|
tests/test_library_name_collision_runtime.py
|
|
91
99
|
tests/test_local_named_like_a_function_card118.py
|
|
92
100
|
tests/test_loop_and_array_edge_cases.py
|
|
93
101
|
tests/test_loop_counter_history_refusal.py
|
|
102
|
+
tests/test_merge_conflict_marker.py
|
|
94
103
|
tests/test_method_namespaces.py
|
|
95
104
|
tests/test_method_receiver_shape_runtime.py
|
|
96
105
|
tests/test_method_routing_runtime.py
|
|
97
106
|
tests/test_once_structure_parser.py
|
|
98
107
|
tests/test_once_structure_runtime.py
|
|
108
|
+
tests/test_one_line_function_declaration_body.py
|
|
99
109
|
tests/test_overload_dispatch_runtime.py
|
|
100
110
|
tests/test_overload_resolution.py
|
|
101
111
|
tests/test_parse_repair_card55.py
|
|
@@ -103,6 +113,7 @@ tests/test_parser.py
|
|
|
103
113
|
tests/test_parser_positions.py
|
|
104
114
|
tests/test_pine_builtins.py
|
|
105
115
|
tests/test_pine_semantics.py
|
|
116
|
+
tests/test_plain_input_parameter.py
|
|
106
117
|
tests/test_release_artifact_grouping.py
|
|
107
118
|
tests/test_runtime_floor.py
|
|
108
119
|
tests/test_scope_model_drift.py
|
|
@@ -115,6 +126,7 @@ tests/test_suite_harness_exit_verdict.py
|
|
|
115
126
|
tests/test_suite_report_compare.py
|
|
116
127
|
tests/test_switch_subject_runtime.py
|
|
117
128
|
tests/test_symbol_table.py
|
|
129
|
+
tests/test_syminfo_symbol_function_form.py
|
|
118
130
|
tests/test_ta_conditional_runtime.py
|
|
119
131
|
tests/test_transformer.py
|
|
120
132
|
tests/test_transformer_receiver_typing.py
|
|
@@ -126,6 +138,7 @@ tests/test_udt_bool_field_default_by_version_runtime.py
|
|
|
126
138
|
tests/test_udt_field_defaults_runtime.py
|
|
127
139
|
tests/test_udt_field_history_runtime.py
|
|
128
140
|
tests/test_udt_type_proof.py
|
|
141
|
+
tests/test_unicode_space_separator.py
|
|
129
142
|
tests/test_untyped_na_runtime.py
|
|
130
143
|
tests/test_user_declaration_shadows_builtin_runtime.py
|
|
131
144
|
tests/test_v5_bool_cast_runtime.py
|
|
@@ -498,10 +498,6 @@ class CodeGenerator:
|
|
|
498
498
|
# Regular assignment
|
|
499
499
|
value = self.generate_expression(stmt.value)
|
|
500
500
|
|
|
501
|
-
# Wrap string literals assigned to Color type as Color('...')
|
|
502
|
-
if stmt.type_hint == 'Color' and value.startswith("'") and value.endswith("'"):
|
|
503
|
-
value = f'Color({value})'
|
|
504
|
-
|
|
505
501
|
# Add type hint if present
|
|
506
502
|
if stmt.type_hint:
|
|
507
503
|
self.emit(f'{target}: {stmt.type_hint} = {value}')
|
|
@@ -850,10 +846,11 @@ class CodeGenerator:
|
|
|
850
846
|
elif expr.literal_type == 'bool':
|
|
851
847
|
return 'True' if expr.value else 'False'
|
|
852
848
|
elif expr.literal_type == 'color':
|
|
849
|
+
# A color is a Color object: pynecore reads .value, .r, .t and compares two colors through it
|
|
853
850
|
if expr.is_double_quoted:
|
|
854
|
-
return f'"{self._escape_string(expr.value, chr(34))}"'
|
|
851
|
+
return f'Color("{self._escape_string(expr.value, chr(34))}")'
|
|
855
852
|
else:
|
|
856
|
-
return f"'{self._escape_string(expr.value, chr(39))}'"
|
|
853
|
+
return f"Color('{self._escape_string(expr.value, chr(39))}')"
|
|
857
854
|
else:
|
|
858
855
|
return str(expr.value)
|
|
859
856
|
|
|
@@ -10,6 +10,7 @@ from .errors import UnsupportedFeatureError
|
|
|
10
10
|
from .ast_walk import walk
|
|
11
11
|
from .block_value_lowering import bool_is_never_na
|
|
12
12
|
from .udt_field_defaults import FIELD_FACTORY_IMPORT, emitted_default_requires_na, is_series_default
|
|
13
|
+
from .namespace_members import NAMESPACE_MEMBERS
|
|
13
14
|
from .pine_builtins import (
|
|
14
15
|
PYNECORE_LIB_MODULES, DRAWING_TYPES, CHART_TYPES,
|
|
15
16
|
SERIES_VARIABLES, is_series_variable, needs_plot_style_remap
|
|
@@ -56,6 +57,9 @@ class ImportResolver:
|
|
|
56
57
|
# A namespace spelled by an alias because an input or export keeps its name
|
|
57
58
|
# (scope_renamer, card #9): module name -> alias ('size' -> '_size_module')
|
|
58
59
|
self.aliased_modules: dict[str, str] = {}
|
|
60
|
+
# A library imported under the name of a namespace the script reads: namespace -> (the name its module is
|
|
61
|
+
# imported by, the name of the library merged over the built-in namespace) (job transpileerrors2)
|
|
62
|
+
self.shadowed_namespaces: dict[str, tuple[str, str]] = {}
|
|
59
63
|
|
|
60
64
|
def analyze(self, script: Script) -> None:
|
|
61
65
|
"""Analyze script to determine what needs to be imported."""
|
|
@@ -127,6 +131,10 @@ class ImportResolver:
|
|
|
127
131
|
if isinstance(node, NaLiteral):
|
|
128
132
|
self.uses_na = True
|
|
129
133
|
|
|
134
|
+
# A color literal is emitted as Color('#...') (job colorliteral)
|
|
135
|
+
if isinstance(node, Literal) and node.literal_type == 'color':
|
|
136
|
+
self.drawing_types.add('Color')
|
|
137
|
+
|
|
130
138
|
# Handle function calls
|
|
131
139
|
if isinstance(node, FunctionCall):
|
|
132
140
|
self._process_function_call(node)
|
|
@@ -407,6 +415,7 @@ class ImportResolver:
|
|
|
407
415
|
self.lib_modules.add('NA')
|
|
408
416
|
|
|
409
417
|
all_lib_imports = []
|
|
418
|
+
self.lib_modules.update('string' if namespace == 'str' else namespace for namespace in self.shadowed_namespaces)
|
|
410
419
|
if self.lib_modules:
|
|
411
420
|
all_lib_imports.extend(sorted(self.lib_modules))
|
|
412
421
|
if self.builtin_variables:
|
|
@@ -450,4 +459,21 @@ class ImportResolver:
|
|
|
450
459
|
types = sorted(self.chart_types)
|
|
451
460
|
imports.append(f"from pynecore.types.chart import {', '.join(types)}")
|
|
452
461
|
|
|
462
|
+
# 11. A library imported under a namespace name: the name is the library merged over the built-in. The
|
|
463
|
+
# library's exports win and every other member is the built-in's (TradingView, measured; pynecore's
|
|
464
|
+
# `shadowed_namespace`)
|
|
465
|
+
# pynecore imports the submodule `pynecore.lib.<namespace>` for an `import pynecore.lib.<namespace>` statement,
|
|
466
|
+
# not for the bare read the merge line makes, and `pynecore.lib` itself imports only some of them: a fresh
|
|
467
|
+
# `pyne run` failed with "module 'pynecore.lib' has no attribute 'ta'" (job namespaceimport). A name that
|
|
468
|
+
# pynecore.lib defines as a function (`nz`, `fixnan`, `timestamp`, ...) has no submodule, and importing it is a
|
|
469
|
+
# ModuleNotFoundError: NAMESPACE_MEMBERS, generated from the runtime, holds exactly the names that have one
|
|
470
|
+
if self.shadowed_namespaces:
|
|
471
|
+
python_names = {namespace: 'string' if namespace == 'str' else namespace
|
|
472
|
+
for namespace in self.shadowed_namespaces}
|
|
473
|
+
imports.append("from pynecore.core.pine_import import shadowed_namespace")
|
|
474
|
+
imports.extend(f"import pynecore.lib.{python_name}" for python_name in sorted(set(python_names.values()))
|
|
475
|
+
if python_name in NAMESPACE_MEMBERS)
|
|
476
|
+
for namespace, (library_name, merged_name) in sorted(self.shadowed_namespaces.items()):
|
|
477
|
+
imports.append(f"{merged_name} = shadowed_namespace({library_name}, {python_names[namespace]})")
|
|
478
|
+
|
|
453
479
|
return imports
|
|
@@ -12,6 +12,9 @@ name from the table is renamed, and only when the script declares no FUNCTION of
|
|
|
12
12
|
scope at the call, so the builtin is the callee. A source with no //@version line, or one at v5 or later, is not
|
|
13
13
|
touched.
|
|
14
14
|
|
|
15
|
+
`iff(cond, then, else)` is a function of those versions too (v5 removed it for `?:`), and it is not a renamed call: the
|
|
16
|
+
transformer emits it (`iff_is_the_function` tells it when the name is the builtin; job iffunction).
|
|
17
|
+
|
|
15
18
|
Left out on purpose (card #116 follow-ups): names a Python builtin of the same spelling already answers
|
|
16
19
|
(`abs`, `max`, `min`, `round`, `pow`, `range`), which run today with Python semantics; and the legacy names
|
|
17
20
|
that are series, not calls (a bare `tr`, `vwap`, `obv`, `tickerid`, ...).
|
|
@@ -64,3 +67,9 @@ def qualify_legacy_function_names(script: Script) -> Script:
|
|
|
64
67
|
if isinstance(node, FunctionCall) and isinstance(node.func, str) and node.func in renames:
|
|
65
68
|
node.func = renames[node.func]
|
|
66
69
|
return script
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def iff_is_the_function(script: Script) -> bool:
|
|
73
|
+
"""True when a call `iff(...)` of this script is the Pine v1-v4 function: the script declares //@version 1-4
|
|
74
|
+
and no function named `iff` of its own (a user's own `iff` wins, as for every name above)."""
|
|
75
|
+
return 1 <= _declared_version(script) <= 4 and 'iff' not in _declared_function_names(script)
|
|
@@ -10,6 +10,10 @@ from .errors import LexerError
|
|
|
10
10
|
from .tokens import Token, TokenType, KEYWORDS, TYPE_KEYWORDS
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
# A git merge conflict marker: seven `<`, `=` or `>` at the start of a line, then the end of the line or a space
|
|
14
|
+
MERGE_CONFLICT_MARKER = re.compile(r'^(?:<{7}|={7}|>{7})(?=[ \t\r]|$)', re.MULTILINE)
|
|
15
|
+
|
|
16
|
+
|
|
13
17
|
class Lexer:
|
|
14
18
|
"""Tokenizes Pine Script v6 source code."""
|
|
15
19
|
|
|
@@ -359,6 +363,12 @@ class Lexer:
|
|
|
359
363
|
|
|
360
364
|
def tokenize(self) -> List[Token]:
|
|
361
365
|
"""Tokenize the entire source code."""
|
|
366
|
+
marker = MERGE_CONFLICT_MARKER.search(self.source)
|
|
367
|
+
if marker:
|
|
368
|
+
# `<<<<<<<` would lex as `<<` tokens and be refused as an unexpected token, which reads like a
|
|
369
|
+
# transpiler bug; a file saved with an unresolved conflict is not Pine
|
|
370
|
+
raise LexerError(f'unresolved merge conflict marker {marker.group()!r}: resolve the conflict in the file',
|
|
371
|
+
self.source.count('\n', 0, marker.start()) + 1, 1)
|
|
362
372
|
self.tokens = []
|
|
363
373
|
at_line_start = True
|
|
364
374
|
|
|
@@ -44,6 +44,21 @@ def colliding_names(script: Script) -> FrozenSet[str]:
|
|
|
44
44
|
return frozenset(bound & used & PYNECORE_LIB_MODULES)
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
def namespace_heads_read(script: Script) -> FrozenSet[str]:
|
|
48
|
+
"""pynecore.lib namespaces the script writes as a dotted head (`ta.sma(...)`, `math.pi`) and never calls bare.
|
|
49
|
+
A library imported under such a name is merged over the namespace (job transpileerrors2)."""
|
|
50
|
+
dotted: Set[str] = set()
|
|
51
|
+
called: Set[str] = set()
|
|
52
|
+
for node in walk(script):
|
|
53
|
+
if isinstance(node, FunctionCall) and isinstance(node.func, str):
|
|
54
|
+
(dotted if '.' in node.func else called).add(node.func.split('.')[0])
|
|
55
|
+
elif isinstance(node, Identifier) and '.' in node.name:
|
|
56
|
+
dotted.add(node.name.split('.')[0])
|
|
57
|
+
elif isinstance(node, MemberAccess) and isinstance(node.object, str):
|
|
58
|
+
dotted.add(node.object.split('.')[0])
|
|
59
|
+
return frozenset((dotted - called) & (PYNECORE_LIB_MODULES | {'str'}))
|
|
60
|
+
|
|
61
|
+
|
|
47
62
|
def _names_bound_by(node):
|
|
48
63
|
if isinstance(node, (VarDecl, VaripDecl, InputDecl, Parameter)):
|
|
49
64
|
return (node.name,)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""The reads of a namespace that a library alias spells, renamed to the merged namespace (job transpileerrors2).
|
|
2
|
+
|
|
3
|
+
`import TradingView/ta/9` makes `ta` the library merged over the built-in `ta` (member by member, as TradingView
|
|
4
|
+
resolves it). The compiled module binds the merged namespace to a name of its own, because pynecore reads every
|
|
5
|
+
imported name as its library object: a rebound `ta` would lose the library's exports. The transformer keeps its
|
|
6
|
+
knowledge of the built-in calls under the name `ta`, so the reads are renamed after it has run: this pass turns each
|
|
7
|
+
dotted read headed by the namespace (`ta.sma`, `ta.atr`, a library export `ta.doubled`) into one headed by the
|
|
8
|
+
merged name.
|
|
9
|
+
"""
|
|
10
|
+
import dataclasses
|
|
11
|
+
from typing import Dict
|
|
12
|
+
|
|
13
|
+
from .ast_nodes import FunctionCall, Identifier, MemberAccess
|
|
14
|
+
from .ast_walk import child_field_names, map_children
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def rename_namespace_heads(tree, merged_names: Dict[str, str]):
|
|
18
|
+
"""A copy of `tree` (nodes, lists, tuples, dicts) in which every dotted function call, identifier and member access
|
|
19
|
+
headed by a key of `merged_names` is headed by its value instead."""
|
|
20
|
+
def rebuild(node):
|
|
21
|
+
changes = {name: map_children(getattr(node, name), rebuild) for name in child_field_names(type(node))}
|
|
22
|
+
if isinstance(node, FunctionCall) and isinstance(node.func, str):
|
|
23
|
+
changes['func'] = _renamed(node.func, merged_names)
|
|
24
|
+
elif isinstance(node, Identifier):
|
|
25
|
+
changes['name'] = _renamed(node.name, merged_names)
|
|
26
|
+
elif isinstance(node, MemberAccess) and isinstance(node.object, str):
|
|
27
|
+
changes['object'] = _renamed(node.object, merged_names)
|
|
28
|
+
return dataclasses.replace(node, **changes)
|
|
29
|
+
|
|
30
|
+
return map_children(tree, rebuild)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _renamed(dotted: str, merged_names: Dict[str, str]) -> str:
|
|
34
|
+
head, dot, rest = dotted.partition('.')
|
|
35
|
+
return merged_names[head] + dot + rest if dot and head in merged_names else dotted
|
|
@@ -6,7 +6,8 @@ the spellings of valid Pine below, it is rewritten into the spelling the grammar
|
|
|
6
6
|
already accepts, and the source is parsed again. A source that parses today
|
|
7
7
|
never reaches a repair, so its output cannot change.
|
|
8
8
|
|
|
9
|
-
row 1
|
|
9
|
+
row 1 a Unicode space separator (Zs) used as whitespace -> a space (outside strings and comments):
|
|
10
|
+
U+00A0, U+2000-U+200A, U+202F, U+205F, U+3000. U+200B (Cf) and U+FEFF stay refused
|
|
10
11
|
CRLF `\\r\\n` / `\\r` line ends in a str -> `\\n`, as reading the file in text mode does
|
|
11
12
|
row 2 unary `+x` -> `x`
|
|
12
13
|
row 3 `.99` -> `0.99`
|
|
@@ -25,8 +26,9 @@ Each parse costs one pass of the file's budget; when a chain dead-ends or the
|
|
|
25
26
|
budget runs out, the FIRST error is raised, with the message and line:col the
|
|
26
27
|
unrepaired source gave, and the error the chain ended on as its __cause__.
|
|
27
28
|
|
|
28
|
-
UNPROVEN on TradingView, pinned by tests/test_parse_repair_card55.py: `\\xa0`
|
|
29
|
-
|
|
29
|
+
UNPROVEN on TradingView, pinned by tests/test_parse_repair_card55.py: `\\xa0` and the
|
|
30
|
+
Zs spaces other than U+200A as whitespace (U+200A is proven: a script published on
|
|
31
|
+
TradingView has it in its import lines; U+200B is refused by TradingView, measured); comma statements; `var p = 0, q = 0` makes only `p` a var here; a
|
|
30
32
|
statement led by `+` on the indent grid stays refused; unary `+` on a non-number
|
|
31
33
|
(`+"a"`) is accepted; an operator-led wrap indented by a multiple of 4 is joined, as
|
|
32
34
|
the lexer already joins a trailing-operator wrap on any indent.
|
|
@@ -40,7 +42,8 @@ from .parser import Parser
|
|
|
40
42
|
from .tokens import Token, TokenType
|
|
41
43
|
|
|
42
44
|
MINIMUM_REPAIR_PASSES = 200
|
|
43
|
-
|
|
45
|
+
# Unicode category Zs, but U+0020 (the lexer reads it already)
|
|
46
|
+
SPACE_SEPARATORS = ('\xa0', *map(chr, range(0x2000, 0x200b)), '\u202f', '\u205f', '\u3000')
|
|
44
47
|
CARRIAGE_RETURN = '\r'
|
|
45
48
|
|
|
46
49
|
OPERAND_END_TYPES = {
|
|
@@ -123,12 +126,12 @@ def _budget_refusal(first_error: ParserError, budget: int) -> ParserError:
|
|
|
123
126
|
|
|
124
127
|
|
|
125
128
|
def _tokenize(source: str, repairs: List[str]) -> Tuple[List[Token], Optional[LexerError]]:
|
|
126
|
-
"""Lex `source`; on a
|
|
129
|
+
"""Lex `source`; on a space separator or a carriage return, rewrite it once and lex again.
|
|
127
130
|
|
|
128
131
|
Returns the tokens and the first lexer error a rewrite got past (None if none did).
|
|
129
132
|
"""
|
|
130
|
-
rewrites = {
|
|
131
|
-
|
|
133
|
+
rewrites = {character: ('space_separator', _space_separators_outside_strings) for character in SPACE_SEPARATORS}
|
|
134
|
+
rewrites[CARRIAGE_RETURN] = ('carriage_return', _universal_newlines)
|
|
132
135
|
first_error = None
|
|
133
136
|
while True:
|
|
134
137
|
try:
|
|
@@ -139,13 +142,15 @@ def _tokenize(source: str, repairs: List[str]) -> Tuple[List[Token], Optional[Le
|
|
|
139
142
|
if character not in rewrites:
|
|
140
143
|
raise first_error from (None if error is first_error else error)
|
|
141
144
|
kind, rewrite = rewrites.pop(character)
|
|
145
|
+
if kind == 'space_separator': # one rewrite handles every separator
|
|
146
|
+
rewrites = {key: value for key, value in rewrites.items() if value[0] != kind}
|
|
142
147
|
repairs.append(f'{kind}@{error.line}:{error.column}')
|
|
143
148
|
source = rewrite(source)
|
|
144
149
|
|
|
145
150
|
|
|
146
151
|
def _rejected_character(error: LexerError) -> Optional[str]:
|
|
147
152
|
"""The character of an `Unexpected character: <repr>` lexer error, else None."""
|
|
148
|
-
for character in (
|
|
153
|
+
for character in (*SPACE_SEPARATORS, CARRIAGE_RETURN):
|
|
149
154
|
if error.message == f'Unexpected character: {character!r}':
|
|
150
155
|
return character
|
|
151
156
|
return None
|
|
@@ -156,8 +161,8 @@ def _universal_newlines(source: str) -> str:
|
|
|
156
161
|
return source.replace('\r\n', '\n').replace('\r', '\n')
|
|
157
162
|
|
|
158
163
|
|
|
159
|
-
def
|
|
160
|
-
"""Every
|
|
164
|
+
def _space_separators_outside_strings(source: str) -> str:
|
|
165
|
+
"""Every Unicode space separator outside a string literal or a `//` comment becomes a space."""
|
|
161
166
|
characters, quote, index = list(source), None, 0
|
|
162
167
|
while index < len(characters):
|
|
163
168
|
character = characters[index]
|
|
@@ -172,7 +177,7 @@ def _no_break_space_outside_strings(source: str) -> str:
|
|
|
172
177
|
index = source.find('\n', index)
|
|
173
178
|
index = len(source) if index < 0 else index
|
|
174
179
|
continue
|
|
175
|
-
elif character
|
|
180
|
+
elif character in SPACE_SEPARATORS:
|
|
176
181
|
characters[index] = ' '
|
|
177
182
|
index += 1
|
|
178
183
|
return ''.join(characters)
|
|
@@ -523,13 +523,16 @@ class Parser:
|
|
|
523
523
|
"""Parse single-line function body with optional comma-separated statements.
|
|
524
524
|
Pine Script allows: fn(x) => stmt1, stmt2, return_expr
|
|
525
525
|
Each comma-separated item can be an assignment or expression.
|
|
526
|
-
Returns a single expression (no commas) or a list of statements (commas present
|
|
526
|
+
Returns a single expression (no commas) or a list of statements (commas present, or
|
|
527
|
+
one declaration: its value is the function's value, as in the multi-line form).
|
|
527
528
|
"""
|
|
528
529
|
# Parse first item — could be var declaration, assignment, or expression
|
|
529
530
|
first = self._parse_positioned_single_line_item()
|
|
530
531
|
|
|
531
532
|
# Check for comma (multiple statements)
|
|
532
533
|
if not self.match(TokenType.COMMA):
|
|
534
|
+
if isinstance(first, (Assignment, VarDecl, VaripDecl)):
|
|
535
|
+
return [first] # A body is an expression or a list of statements, never one declaration
|
|
533
536
|
return first # Single expression, return as-is
|
|
534
537
|
|
|
535
538
|
# Multiple comma-separated statements
|
|
@@ -545,8 +548,8 @@ class Parser:
|
|
|
545
548
|
"""Parse a single item in a comma-separated single-line function body.
|
|
546
549
|
Can be: var type name = expr, name = expr, or just expr.
|
|
547
550
|
"""
|
|
548
|
-
# Handle 'var' declarations: var type name = expr
|
|
549
|
-
if self.match(TokenType.VAR):
|
|
551
|
+
# Handle 'var' and 'varip' declarations: var type name = expr
|
|
552
|
+
if self.match(TokenType.VAR, TokenType.VARIP):
|
|
550
553
|
return self.parse_statement()
|
|
551
554
|
|
|
552
555
|
# Try assignment: name = expr (look ahead for IDENTIFIER followed by ASSIGN)
|
|
@@ -792,35 +795,26 @@ class Parser:
|
|
|
792
795
|
result = (self.match(TokenType.ASSIGN) and
|
|
793
796
|
((self.peek_token().type == TokenType.IDENTIFIER and
|
|
794
797
|
self.peek_token().value.startswith('input.')) or
|
|
795
|
-
self.
|
|
798
|
+
self._input_call_ahead()))
|
|
796
799
|
|
|
797
800
|
self.pos = saved_pos
|
|
798
801
|
return result
|
|
799
802
|
|
|
800
|
-
def
|
|
801
|
-
"""At `= input(`
|
|
802
|
-
(card #115
|
|
803
|
-
|
|
803
|
+
def _input_call_ahead(self) -> bool:
|
|
804
|
+
"""At `= input(` ...: true when the whole right side is a call parse_function_call rewrote to an
|
|
805
|
+
input.<type> call (a `type=` keyword, card #115, or a default that shows the type), so the statement
|
|
806
|
+
is an input declaration as its input.<type> spelling is. `input(10) * 2` is not: it is an expression."""
|
|
804
807
|
if self.peek_token().value != 'input' or self.peek_token(2).type != TokenType.LPAREN:
|
|
805
808
|
return False
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
if depth == 0:
|
|
816
|
-
return False
|
|
817
|
-
elif (depth == 1 and token.type == TokenType.IDENTIFIER and token.value == 'type'
|
|
818
|
-
and self.peek_token(offset + 1).type == TokenType.ASSIGN):
|
|
819
|
-
kind = self.peek_token(offset + 2)
|
|
820
|
-
# a bare `float`/`bool`/`string`/`color` lexes as TYPE_IDENTIFIER; parse_function_call rewrites it too
|
|
821
|
-
return (kind.type in (TokenType.IDENTIFIER, TokenType.TYPE_IDENTIFIER)
|
|
822
|
-
and kind.value.removeprefix('input.') in LEGACY_INPUT_TYPE_ARGUMENT_FUNCTIONS)
|
|
823
|
-
offset += 1
|
|
809
|
+
saved_pos = self.pos
|
|
810
|
+
self.pos += 1 # past the `=`
|
|
811
|
+
try:
|
|
812
|
+
call = self.parse_expression()
|
|
813
|
+
except ParserError:
|
|
814
|
+
return False
|
|
815
|
+
finally:
|
|
816
|
+
self.pos = saved_pos
|
|
817
|
+
return isinstance(call, FunctionCall) and isinstance(call.func, str) and call.func.startswith('input.')
|
|
824
818
|
|
|
825
819
|
def parse_input_declaration(self) -> InputDecl:
|
|
826
820
|
"""Parse input declaration. Handles: name = input.*() and type name = input.*()"""
|
|
@@ -1554,10 +1548,10 @@ class Parser:
|
|
|
1554
1548
|
else:
|
|
1555
1549
|
func_name = func
|
|
1556
1550
|
|
|
1557
|
-
# Pine v2-v4 `input(defval, title, type=input.float)` is the v5 `input.float(defval, title)` (card #115)
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
typed_function =
|
|
1551
|
+
# Pine v2-v4 `input(defval, title, type=input.float)` is the v5 `input.float(defval, title)` (card #115);
|
|
1552
|
+
# a plain `input(20)` is the input.<type> call its default value shows
|
|
1553
|
+
if func_name == 'input':
|
|
1554
|
+
typed_function = self._plain_input_function(args, kwargs)
|
|
1561
1555
|
if typed_function is not None:
|
|
1562
1556
|
func_name = typed_function
|
|
1563
1557
|
kwargs = {key: value for key, value in kwargs.items() if key != 'type'}
|
|
@@ -1566,6 +1560,35 @@ class Parser:
|
|
|
1566
1560
|
return FunctionCall(func=func_name, args=args, kwargs=kwargs,
|
|
1567
1561
|
line=getattr(func, 'line', 0), column=getattr(func, 'column', 0))
|
|
1568
1562
|
|
|
1563
|
+
@staticmethod
|
|
1564
|
+
def _plain_input_function(args: list, kwargs: dict) -> Optional[str]:
|
|
1565
|
+
"""The input.<type> function a plain `input(...)` call stands for, else None (the call stays as it is).
|
|
1566
|
+
|
|
1567
|
+
The `type=` keyword names it (card #115). Else the default value does, as on TradingView: a literal by
|
|
1568
|
+
its type, a negative number by its operand, a builtin source series by its name, `color.<name>` as a
|
|
1569
|
+
color. A call with three or more positional arguments is not decided here: after `title` the order
|
|
1570
|
+
differs by version and by input type.
|
|
1571
|
+
"""
|
|
1572
|
+
from .pine_builtins import (LEGACY_INPUT_TYPE_ARGUMENT_FUNCTIONS, PLAIN_INPUT_LITERAL_FUNCTIONS,
|
|
1573
|
+
PLAIN_INPUT_SOURCE_NAMES)
|
|
1574
|
+
if isinstance(kwargs.get('type'), Identifier):
|
|
1575
|
+
return LEGACY_INPUT_TYPE_ARGUMENT_FUNCTIONS.get(kwargs['type'].name.removeprefix('input.'))
|
|
1576
|
+
if len(args) > 2 or (args and 'defval' in kwargs):
|
|
1577
|
+
return None
|
|
1578
|
+
default = args[0] if args else kwargs.get('defval')
|
|
1579
|
+
if isinstance(default, UnaryOp) and default.op == '-' and isinstance(default.operand, Literal):
|
|
1580
|
+
default = default.operand
|
|
1581
|
+
if default.literal_type not in ('int', 'float'):
|
|
1582
|
+
return None
|
|
1583
|
+
if isinstance(default, Literal):
|
|
1584
|
+
return PLAIN_INPUT_LITERAL_FUNCTIONS.get(default.literal_type)
|
|
1585
|
+
if isinstance(default, Identifier):
|
|
1586
|
+
if default.name in PLAIN_INPUT_SOURCE_NAMES:
|
|
1587
|
+
return 'input.source'
|
|
1588
|
+
if default.name.startswith('color.'):
|
|
1589
|
+
return 'input.color'
|
|
1590
|
+
return None
|
|
1591
|
+
|
|
1569
1592
|
def parse_method_call(self, obj: Expression, method: str) -> MethodCall:
|
|
1570
1593
|
"""Parse method call arguments."""
|
|
1571
1594
|
self.expect(TokenType.LPAREN)
|
|
@@ -268,6 +268,18 @@ LEGACY_INPUT_TYPE_ARGUMENT_FUNCTIONS: Dict[str, str] = {
|
|
|
268
268
|
'session': 'input.session', 'time': 'input.time', 'color': 'input.color', 'price': 'input.price',
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
# Plain `input(defval, ...)` (no namespace, v4 and v5) takes its type from the default value, as the input.<type>
|
|
272
|
+
# function of that type does (measured on TradingView: metainfo.inputs of one script). `defval`'s node decides:
|
|
273
|
+
# a literal by its type, a negative number literal by its operand, a builtin source series by its name,
|
|
274
|
+
# a `color.<name>` constant as a color.
|
|
275
|
+
PLAIN_INPUT_LITERAL_FUNCTIONS: Dict[str, str] = {
|
|
276
|
+
'int': 'input.int', 'float': 'input.float', 'bool': 'input.bool', 'string': 'input.string',
|
|
277
|
+
'color': 'input.color',
|
|
278
|
+
}
|
|
279
|
+
# The series TradingView lists as a source input's options
|
|
280
|
+
PLAIN_INPUT_SOURCE_NAMES: FrozenSet[str] = frozenset({
|
|
281
|
+
'open', 'high', 'low', 'close', 'hl2', 'hlc3', 'hlcc4', 'ohlc4', 'volume',
|
|
282
|
+
})
|
|
271
283
|
# input.int/input.float have a second positional form after `title` (v6 reference): the options form,
|
|
272
284
|
# selected by a list third argument (pynecore's _bind_numeric_tail, _NUMERIC_OPTIONS_TAIL; card #95).
|
|
273
285
|
NUMERIC_INPUT_FUNCTIONS: FrozenSet[str] = frozenset({'input.int', 'input.float'})
|