coinex-api 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl
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.
- {coinex_api-0.0.7.dist-info → coinex_api-0.0.8.dist-info}/METADATA +33 -14
- coinex_api-0.0.8.dist-info/RECORD +3 -0
- coinex_api/__init__.py +0 -7
- coinex_api/ccxt/__init__.py +0 -101
- coinex_api/ccxt/abstract/coinex.py +0 -237
- coinex_api/ccxt/async_support/__init__.py +0 -80
- coinex_api/ccxt/async_support/base/__init__.py +0 -1
- coinex_api/ccxt/async_support/base/exchange.py +0 -2100
- coinex_api/ccxt/async_support/base/throttler.py +0 -50
- coinex_api/ccxt/async_support/base/ws/__init__.py +0 -38
- coinex_api/ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- coinex_api/ccxt/async_support/base/ws/cache.py +0 -213
- coinex_api/ccxt/async_support/base/ws/client.py +0 -214
- coinex_api/ccxt/async_support/base/ws/fast_client.py +0 -97
- coinex_api/ccxt/async_support/base/ws/functions.py +0 -59
- coinex_api/ccxt/async_support/base/ws/future.py +0 -69
- coinex_api/ccxt/async_support/base/ws/order_book.py +0 -78
- coinex_api/ccxt/async_support/base/ws/order_book_side.py +0 -174
- coinex_api/ccxt/async_support/coinex.py +0 -5833
- coinex_api/ccxt/base/__init__.py +0 -27
- coinex_api/ccxt/base/decimal_to_precision.py +0 -174
- coinex_api/ccxt/base/errors.py +0 -267
- coinex_api/ccxt/base/exchange.py +0 -6770
- coinex_api/ccxt/base/precise.py +0 -297
- coinex_api/ccxt/base/types.py +0 -577
- coinex_api/ccxt/coinex.py +0 -5832
- coinex_api/ccxt/pro/__init__.py +0 -21
- coinex_api/ccxt/pro/coinex.py +0 -1366
- coinex_api/ccxt/static_dependencies/README.md +0 -1
- coinex_api/ccxt/static_dependencies/__init__.py +0 -1
- coinex_api/ccxt/static_dependencies/ecdsa/__init__.py +0 -14
- coinex_api/ccxt/static_dependencies/ecdsa/_version.py +0 -520
- coinex_api/ccxt/static_dependencies/ecdsa/curves.py +0 -56
- coinex_api/ccxt/static_dependencies/ecdsa/der.py +0 -221
- coinex_api/ccxt/static_dependencies/ecdsa/ecdsa.py +0 -310
- coinex_api/ccxt/static_dependencies/ecdsa/ellipticcurve.py +0 -197
- coinex_api/ccxt/static_dependencies/ecdsa/keys.py +0 -332
- coinex_api/ccxt/static_dependencies/ecdsa/numbertheory.py +0 -531
- coinex_api/ccxt/static_dependencies/ecdsa/rfc6979.py +0 -100
- coinex_api/ccxt/static_dependencies/ecdsa/util.py +0 -266
- coinex_api/ccxt/static_dependencies/ethereum/__init__.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/abi/__init__.py +0 -16
- coinex_api/ccxt/static_dependencies/ethereum/abi/abi.py +0 -19
- coinex_api/ccxt/static_dependencies/ethereum/abi/base.py +0 -152
- coinex_api/ccxt/static_dependencies/ethereum/abi/codec.py +0 -217
- coinex_api/ccxt/static_dependencies/ethereum/abi/constants.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/abi/decoding.py +0 -565
- coinex_api/ccxt/static_dependencies/ethereum/abi/encoding.py +0 -720
- coinex_api/ccxt/static_dependencies/ethereum/abi/exceptions.py +0 -139
- coinex_api/ccxt/static_dependencies/ethereum/abi/grammar.py +0 -443
- coinex_api/ccxt/static_dependencies/ethereum/abi/packed.py +0 -13
- coinex_api/ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/abi/registry.py +0 -643
- coinex_api/ccxt/static_dependencies/ethereum/abi/tools/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +0 -230
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/numeric.py +0 -83
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/padding.py +0 -27
- coinex_api/ccxt/static_dependencies/ethereum/abi/utils/string.py +0 -19
- coinex_api/ccxt/static_dependencies/ethereum/account/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +0 -4
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +0 -239
- coinex_api/ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +0 -40
- coinex_api/ccxt/static_dependencies/ethereum/account/messages.py +0 -263
- coinex_api/ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/__init__.py +0 -5
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/_utils.py +0 -54
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/main.py +0 -65
- coinex_api/ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/typing/__init__.py +0 -63
- coinex_api/ccxt/static_dependencies/ethereum/typing/abi.py +0 -6
- coinex_api/ccxt/static_dependencies/ethereum/typing/bls.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/typing/discovery.py +0 -5
- coinex_api/ccxt/static_dependencies/ethereum/typing/encoding.py +0 -7
- coinex_api/ccxt/static_dependencies/ethereum/typing/enums.py +0 -17
- coinex_api/ccxt/static_dependencies/ethereum/typing/ethpm.py +0 -9
- coinex_api/ccxt/static_dependencies/ethereum/typing/evm.py +0 -20
- coinex_api/ccxt/static_dependencies/ethereum/typing/networks.py +0 -1122
- coinex_api/ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/utils/__init__.py +0 -115
- coinex_api/ccxt/static_dependencies/ethereum/utils/abi.py +0 -72
- coinex_api/ccxt/static_dependencies/ethereum/utils/address.py +0 -171
- coinex_api/ccxt/static_dependencies/ethereum/utils/applicators.py +0 -151
- coinex_api/ccxt/static_dependencies/ethereum/utils/conversions.py +0 -190
- coinex_api/ccxt/static_dependencies/ethereum/utils/currency.py +0 -107
- coinex_api/ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -269
- coinex_api/ccxt/static_dependencies/ethereum/utils/debug.py +0 -20
- coinex_api/ccxt/static_dependencies/ethereum/utils/decorators.py +0 -132
- coinex_api/ccxt/static_dependencies/ethereum/utils/encoding.py +0 -6
- coinex_api/ccxt/static_dependencies/ethereum/utils/exceptions.py +0 -4
- coinex_api/ccxt/static_dependencies/ethereum/utils/functional.py +0 -75
- coinex_api/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +0 -74
- coinex_api/ccxt/static_dependencies/ethereum/utils/humanize.py +0 -188
- coinex_api/ccxt/static_dependencies/ethereum/utils/logging.py +0 -159
- coinex_api/ccxt/static_dependencies/ethereum/utils/module_loading.py +0 -31
- coinex_api/ccxt/static_dependencies/ethereum/utils/numeric.py +0 -43
- coinex_api/ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/ethereum/utils/toolz.py +0 -76
- coinex_api/ccxt/static_dependencies/ethereum/utils/types.py +0 -54
- coinex_api/ccxt/static_dependencies/ethereum/utils/typing/__init__.py +0 -18
- coinex_api/ccxt/static_dependencies/ethereum/utils/typing/misc.py +0 -14
- coinex_api/ccxt/static_dependencies/ethereum/utils/units.py +0 -31
- coinex_api/ccxt/static_dependencies/keccak/__init__.py +0 -3
- coinex_api/ccxt/static_dependencies/keccak/keccak.py +0 -197
- coinex_api/ccxt/static_dependencies/lark/__init__.py +0 -38
- coinex_api/ccxt/static_dependencies/lark/__pyinstaller/__init__.py +0 -6
- coinex_api/ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +0 -14
- coinex_api/ccxt/static_dependencies/lark/ast_utils.py +0 -59
- coinex_api/ccxt/static_dependencies/lark/common.py +0 -86
- coinex_api/ccxt/static_dependencies/lark/exceptions.py +0 -292
- coinex_api/ccxt/static_dependencies/lark/grammar.py +0 -130
- coinex_api/ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/lark/grammars/common.lark +0 -59
- coinex_api/ccxt/static_dependencies/lark/grammars/lark.lark +0 -62
- coinex_api/ccxt/static_dependencies/lark/grammars/python.lark +0 -302
- coinex_api/ccxt/static_dependencies/lark/grammars/unicode.lark +0 -7
- coinex_api/ccxt/static_dependencies/lark/indenter.py +0 -143
- coinex_api/ccxt/static_dependencies/lark/lark.py +0 -658
- coinex_api/ccxt/static_dependencies/lark/lexer.py +0 -678
- coinex_api/ccxt/static_dependencies/lark/load_grammar.py +0 -1428
- coinex_api/ccxt/static_dependencies/lark/parse_tree_builder.py +0 -391
- coinex_api/ccxt/static_dependencies/lark/parser_frontends.py +0 -257
- coinex_api/ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/lark/parsers/cyk.py +0 -340
- coinex_api/ccxt/static_dependencies/lark/parsers/earley.py +0 -314
- coinex_api/ccxt/static_dependencies/lark/parsers/earley_common.py +0 -42
- coinex_api/ccxt/static_dependencies/lark/parsers/earley_forest.py +0 -801
- coinex_api/ccxt/static_dependencies/lark/parsers/grammar_analysis.py +0 -203
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_analysis.py +0 -332
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +0 -158
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_parser.py +0 -122
- coinex_api/ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +0 -110
- coinex_api/ccxt/static_dependencies/lark/parsers/xearley.py +0 -165
- coinex_api/ccxt/static_dependencies/lark/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/lark/reconstruct.py +0 -107
- coinex_api/ccxt/static_dependencies/lark/tools/__init__.py +0 -70
- coinex_api/ccxt/static_dependencies/lark/tools/nearley.py +0 -202
- coinex_api/ccxt/static_dependencies/lark/tools/serialize.py +0 -32
- coinex_api/ccxt/static_dependencies/lark/tools/standalone.py +0 -196
- coinex_api/ccxt/static_dependencies/lark/tree.py +0 -267
- coinex_api/ccxt/static_dependencies/lark/tree_matcher.py +0 -186
- coinex_api/ccxt/static_dependencies/lark/tree_templates.py +0 -180
- coinex_api/ccxt/static_dependencies/lark/utils.py +0 -343
- coinex_api/ccxt/static_dependencies/lark/visitors.py +0 -596
- coinex_api/ccxt/static_dependencies/marshmallow/__init__.py +0 -81
- coinex_api/ccxt/static_dependencies/marshmallow/base.py +0 -65
- coinex_api/ccxt/static_dependencies/marshmallow/class_registry.py +0 -94
- coinex_api/ccxt/static_dependencies/marshmallow/decorators.py +0 -231
- coinex_api/ccxt/static_dependencies/marshmallow/error_store.py +0 -60
- coinex_api/ccxt/static_dependencies/marshmallow/exceptions.py +0 -71
- coinex_api/ccxt/static_dependencies/marshmallow/fields.py +0 -2114
- coinex_api/ccxt/static_dependencies/marshmallow/orderedset.py +0 -89
- coinex_api/ccxt/static_dependencies/marshmallow/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/marshmallow/schema.py +0 -1228
- coinex_api/ccxt/static_dependencies/marshmallow/types.py +0 -12
- coinex_api/ccxt/static_dependencies/marshmallow/utils.py +0 -378
- coinex_api/ccxt/static_dependencies/marshmallow/validate.py +0 -678
- coinex_api/ccxt/static_dependencies/marshmallow/warnings.py +0 -2
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/__init__.py +0 -1047
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +0 -51
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +0 -45
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/mypy.py +0 -71
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/typing.py +0 -14
- coinex_api/ccxt/static_dependencies/marshmallow_dataclass/union_field.py +0 -82
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +0 -1
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +0 -193
- coinex_api/ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- coinex_api/ccxt/static_dependencies/msgpack/__init__.py +0 -55
- coinex_api/ccxt/static_dependencies/msgpack/_cmsgpack.pyx +0 -11
- coinex_api/ccxt/static_dependencies/msgpack/_packer.pyx +0 -374
- coinex_api/ccxt/static_dependencies/msgpack/_unpacker.pyx +0 -547
- coinex_api/ccxt/static_dependencies/msgpack/buff_converter.h +0 -8
- coinex_api/ccxt/static_dependencies/msgpack/exceptions.py +0 -48
- coinex_api/ccxt/static_dependencies/msgpack/ext.py +0 -168
- coinex_api/ccxt/static_dependencies/msgpack/fallback.py +0 -951
- coinex_api/ccxt/static_dependencies/msgpack/pack.h +0 -89
- coinex_api/ccxt/static_dependencies/msgpack/pack_template.h +0 -820
- coinex_api/ccxt/static_dependencies/msgpack/sysdep.h +0 -194
- coinex_api/ccxt/static_dependencies/msgpack/unpack.h +0 -391
- coinex_api/ccxt/static_dependencies/msgpack/unpack_define.h +0 -95
- coinex_api/ccxt/static_dependencies/msgpack/unpack_template.h +0 -464
- coinex_api/ccxt/static_dependencies/parsimonious/__init__.py +0 -10
- coinex_api/ccxt/static_dependencies/parsimonious/exceptions.py +0 -105
- coinex_api/ccxt/static_dependencies/parsimonious/expressions.py +0 -479
- coinex_api/ccxt/static_dependencies/parsimonious/grammar.py +0 -487
- coinex_api/ccxt/static_dependencies/parsimonious/nodes.py +0 -325
- coinex_api/ccxt/static_dependencies/parsimonious/utils.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/model.py +0 -44
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/parser.py +0 -216
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/schemas.py +0 -72
- coinex_api/ccxt/static_dependencies/starknet/abi/v0/shape.py +0 -63
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/core_structures.json +0 -14
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/model.py +0 -39
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/parser.py +0 -220
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/parser_transformer.py +0 -179
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/schemas.py +0 -66
- coinex_api/ccxt/static_dependencies/starknet/abi/v1/shape.py +0 -47
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/__init__.py +0 -2
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/model.py +0 -89
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/parser.py +0 -293
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/parser_transformer.py +0 -192
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/schemas.py +0 -132
- coinex_api/ccxt/static_dependencies/starknet/abi/v2/shape.py +0 -107
- coinex_api/ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/data_types.py +0 -123
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +0 -77
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +0 -46
- coinex_api/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +0 -138
- coinex_api/ccxt/static_dependencies/starknet/cairo/felt.py +0 -64
- coinex_api/ccxt/static_dependencies/starknet/cairo/type_parser.py +0 -121
- coinex_api/ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +0 -59
- coinex_api/ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +0 -77
- coinex_api/ccxt/static_dependencies/starknet/ccxt_utils.py +0 -7
- coinex_api/ccxt/static_dependencies/starknet/common.py +0 -15
- coinex_api/ccxt/static_dependencies/starknet/constants.py +0 -39
- coinex_api/ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/hash/address.py +0 -79
- coinex_api/ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +0 -111
- coinex_api/ccxt/static_dependencies/starknet/hash/selector.py +0 -16
- coinex_api/ccxt/static_dependencies/starknet/hash/storage.py +0 -12
- coinex_api/ccxt/static_dependencies/starknet/hash/utils.py +0 -78
- coinex_api/ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/models/typed_data.py +0 -45
- coinex_api/ccxt/static_dependencies/starknet/serialization/__init__.py +0 -24
- coinex_api/ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/serialization/_context.py +0 -142
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +0 -10
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +0 -82
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +0 -43
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +0 -37
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +0 -66
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +0 -71
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +0 -71
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +0 -50
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +0 -58
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +0 -43
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +0 -40
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +0 -72
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +0 -36
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +0 -36
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +0 -76
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +0 -100
- coinex_api/ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +0 -32
- coinex_api/ccxt/static_dependencies/starknet/serialization/errors.py +0 -10
- coinex_api/ccxt/static_dependencies/starknet/serialization/factory.py +0 -229
- coinex_api/ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +0 -110
- coinex_api/ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +0 -59
- coinex_api/ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +0 -86
- coinex_api/ccxt/static_dependencies/starknet/utils/iterable.py +0 -13
- coinex_api/ccxt/static_dependencies/starknet/utils/schema.py +0 -13
- coinex_api/ccxt/static_dependencies/starknet/utils/typed_data.py +0 -182
- coinex_api/ccxt/static_dependencies/starkware/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +0 -50
- coinex_api/ccxt/static_dependencies/starkware/crypto/math_utils.py +0 -78
- coinex_api/ccxt/static_dependencies/starkware/crypto/signature.py +0 -2344
- coinex_api/ccxt/static_dependencies/starkware/crypto/utils.py +0 -63
- coinex_api/ccxt/static_dependencies/sympy/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/core/intfunc.py +0 -35
- coinex_api/ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/sympy/external/gmpy.py +0 -345
- coinex_api/ccxt/static_dependencies/sympy/external/importtools.py +0 -187
- coinex_api/ccxt/static_dependencies/sympy/external/ntheory.py +0 -637
- coinex_api/ccxt/static_dependencies/sympy/external/pythonmpq.py +0 -341
- coinex_api/ccxt/static_dependencies/toolz/__init__.py +0 -26
- coinex_api/ccxt/static_dependencies/toolz/_signatures.py +0 -784
- coinex_api/ccxt/static_dependencies/toolz/_version.py +0 -520
- coinex_api/ccxt/static_dependencies/toolz/compatibility.py +0 -30
- coinex_api/ccxt/static_dependencies/toolz/curried/__init__.py +0 -101
- coinex_api/ccxt/static_dependencies/toolz/curried/exceptions.py +0 -22
- coinex_api/ccxt/static_dependencies/toolz/curried/operator.py +0 -22
- coinex_api/ccxt/static_dependencies/toolz/dicttoolz.py +0 -339
- coinex_api/ccxt/static_dependencies/toolz/functoolz.py +0 -1049
- coinex_api/ccxt/static_dependencies/toolz/itertoolz.py +0 -1057
- coinex_api/ccxt/static_dependencies/toolz/recipes.py +0 -46
- coinex_api/ccxt/static_dependencies/toolz/utils.py +0 -9
- coinex_api/ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- coinex_api/ccxt/static_dependencies/typing_inspect/typing_inspect.py +0 -851
- coinex_api-0.0.7.dist-info/RECORD +0 -288
- {coinex_api-0.0.7.dist-info → coinex_api-0.0.8.dist-info}/WHEEL +0 -0
@@ -1,487 +0,0 @@
|
|
1
|
-
"""A convenience which constructs expression trees from an easy-to-read syntax
|
2
|
-
|
3
|
-
Use this unless you have a compelling reason not to; it performs some
|
4
|
-
optimizations that would be tedious to do when constructing an expression tree
|
5
|
-
by hand.
|
6
|
-
|
7
|
-
"""
|
8
|
-
from collections import OrderedDict
|
9
|
-
|
10
|
-
from .exceptions import BadGrammar, UndefinedLabel
|
11
|
-
from .expressions import (Literal, Regex, Sequence, OneOf,
|
12
|
-
Lookahead, Optional, ZeroOrMore, OneOrMore, Not, TokenMatcher,
|
13
|
-
expression, is_callable)
|
14
|
-
from .nodes import NodeVisitor
|
15
|
-
from .utils import evaluate_string
|
16
|
-
|
17
|
-
class Grammar(OrderedDict):
|
18
|
-
"""A collection of rules that describe a language
|
19
|
-
|
20
|
-
You can start parsing from the default rule by calling ``parse()``
|
21
|
-
directly on the ``Grammar`` object::
|
22
|
-
|
23
|
-
g = Grammar('''
|
24
|
-
polite_greeting = greeting ", my good " title
|
25
|
-
greeting = "Hi" / "Hello"
|
26
|
-
title = "madam" / "sir"
|
27
|
-
''')
|
28
|
-
g.parse('Hello, my good sir')
|
29
|
-
|
30
|
-
Or start parsing from any of the other rules; you can pull them out of the
|
31
|
-
grammar as if it were a dictionary::
|
32
|
-
|
33
|
-
g['title'].parse('sir')
|
34
|
-
|
35
|
-
You could also just construct a bunch of ``Expression`` objects yourself
|
36
|
-
and stitch them together into a language, but using a ``Grammar`` has some
|
37
|
-
important advantages:
|
38
|
-
|
39
|
-
* Languages are much easier to define in the nice syntax it provides.
|
40
|
-
* Circular references aren't a pain.
|
41
|
-
* It does all kinds of whizzy space- and time-saving optimizations, like
|
42
|
-
factoring up repeated subexpressions into a single object, which should
|
43
|
-
increase cache hit ratio. [Is this implemented yet?]
|
44
|
-
|
45
|
-
"""
|
46
|
-
def __init__(self, rules='', **more_rules):
|
47
|
-
"""Construct a grammar.
|
48
|
-
|
49
|
-
:arg rules: A string of production rules, one per line.
|
50
|
-
:arg default_rule: The name of the rule invoked when you call
|
51
|
-
:meth:`parse()` or :meth:`match()` on the grammar. Defaults to the
|
52
|
-
first rule. Falls back to None if there are no string-based rules
|
53
|
-
in this grammar.
|
54
|
-
:arg more_rules: Additional kwargs whose names are rule names and
|
55
|
-
values are Expressions or custom-coded callables which accomplish
|
56
|
-
things the built-in rule syntax cannot. These take precedence over
|
57
|
-
``rules`` in case of naming conflicts.
|
58
|
-
|
59
|
-
"""
|
60
|
-
|
61
|
-
decorated_custom_rules = {
|
62
|
-
k: (expression(v, k, self) if is_callable(v) else v)
|
63
|
-
for k, v in more_rules.items()}
|
64
|
-
|
65
|
-
exprs, first = self._expressions_from_rules(rules, decorated_custom_rules)
|
66
|
-
super(Grammar, self).__init__(exprs.items())
|
67
|
-
self.default_rule = first # may be None
|
68
|
-
|
69
|
-
def default(self, rule_name):
|
70
|
-
"""Return a new Grammar whose :term:`default rule` is ``rule_name``."""
|
71
|
-
new = self._copy()
|
72
|
-
new.default_rule = new[rule_name]
|
73
|
-
return new
|
74
|
-
|
75
|
-
def _copy(self):
|
76
|
-
"""Return a shallow copy of myself.
|
77
|
-
|
78
|
-
Deep is unnecessary, since Expression trees are immutable. Subgrammars
|
79
|
-
recreate all the Expressions from scratch, and AbstractGrammars have
|
80
|
-
no Expressions.
|
81
|
-
|
82
|
-
"""
|
83
|
-
new = Grammar.__new__(Grammar)
|
84
|
-
super(Grammar, new).__init__(self.items())
|
85
|
-
new.default_rule = self.default_rule
|
86
|
-
return new
|
87
|
-
|
88
|
-
def _expressions_from_rules(self, rules, custom_rules):
|
89
|
-
"""Return a 2-tuple: a dict of rule names pointing to their
|
90
|
-
expressions, and then the first rule.
|
91
|
-
|
92
|
-
It's a web of expressions, all referencing each other. Typically,
|
93
|
-
there's a single root to the web of references, and that root is the
|
94
|
-
starting symbol for parsing, but there's nothing saying you can't have
|
95
|
-
multiple roots.
|
96
|
-
|
97
|
-
:arg custom_rules: A map of rule names to custom-coded rules:
|
98
|
-
Expressions
|
99
|
-
|
100
|
-
"""
|
101
|
-
tree = rule_grammar.parse(rules)
|
102
|
-
return RuleVisitor(custom_rules).visit(tree)
|
103
|
-
|
104
|
-
def parse(self, text, pos=0):
|
105
|
-
"""Parse some text with the :term:`default rule`.
|
106
|
-
|
107
|
-
:arg pos: The index at which to start parsing
|
108
|
-
|
109
|
-
"""
|
110
|
-
self._check_default_rule()
|
111
|
-
return self.default_rule.parse(text, pos=pos)
|
112
|
-
|
113
|
-
def match(self, text, pos=0):
|
114
|
-
"""Parse some text with the :term:`default rule` but not necessarily
|
115
|
-
all the way to the end.
|
116
|
-
|
117
|
-
:arg pos: The index at which to start parsing
|
118
|
-
|
119
|
-
"""
|
120
|
-
self._check_default_rule()
|
121
|
-
return self.default_rule.match(text, pos=pos)
|
122
|
-
|
123
|
-
def _check_default_rule(self):
|
124
|
-
"""Raise RuntimeError if there is no default rule defined."""
|
125
|
-
if not self.default_rule:
|
126
|
-
raise RuntimeError("Can't call parse() on a Grammar that has no "
|
127
|
-
"default rule. Choose a specific rule instead, "
|
128
|
-
"like some_grammar['some_rule'].parse(...).")
|
129
|
-
|
130
|
-
def __str__(self):
|
131
|
-
"""Return a rule string that, when passed to the constructor, would
|
132
|
-
reconstitute the grammar."""
|
133
|
-
exprs = [self.default_rule] if self.default_rule else []
|
134
|
-
exprs.extend(expr for expr in self.values() if
|
135
|
-
expr is not self.default_rule)
|
136
|
-
return '\n'.join(expr.as_rule() for expr in exprs)
|
137
|
-
|
138
|
-
def __repr__(self):
|
139
|
-
"""Return an expression that will reconstitute the grammar."""
|
140
|
-
return "Grammar({!r})".format(str(self))
|
141
|
-
|
142
|
-
|
143
|
-
class TokenGrammar(Grammar):
|
144
|
-
"""A Grammar which takes a list of pre-lexed tokens instead of text
|
145
|
-
|
146
|
-
This is useful if you want to do the lexing yourself, as a separate pass:
|
147
|
-
for example, to implement indentation-based languages.
|
148
|
-
|
149
|
-
"""
|
150
|
-
def _expressions_from_rules(self, rules, custom_rules):
|
151
|
-
tree = rule_grammar.parse(rules)
|
152
|
-
return TokenRuleVisitor(custom_rules).visit(tree)
|
153
|
-
|
154
|
-
|
155
|
-
class BootstrappingGrammar(Grammar):
|
156
|
-
"""The grammar used to recognize the textual rules that describe other
|
157
|
-
grammars
|
158
|
-
|
159
|
-
This grammar gets its start from some hard-coded Expressions and claws its
|
160
|
-
way from there to an expression tree that describes how to parse the
|
161
|
-
grammar description syntax.
|
162
|
-
|
163
|
-
"""
|
164
|
-
def _expressions_from_rules(self, rule_syntax, custom_rules):
|
165
|
-
"""Return the rules for parsing the grammar definition syntax.
|
166
|
-
|
167
|
-
Return a 2-tuple: a dict of rule names pointing to their expressions,
|
168
|
-
and then the top-level expression for the first rule.
|
169
|
-
|
170
|
-
"""
|
171
|
-
# Hard-code enough of the rules to parse the grammar that describes the
|
172
|
-
# grammar description language, to bootstrap:
|
173
|
-
comment = Regex(r'#[^\r\n]*', name='comment')
|
174
|
-
meaninglessness = OneOf(Regex(r'\s+'), comment, name='meaninglessness')
|
175
|
-
_ = ZeroOrMore(meaninglessness, name='_')
|
176
|
-
equals = Sequence(Literal('='), _, name='equals')
|
177
|
-
label = Sequence(Regex(r'[a-zA-Z_][a-zA-Z_0-9]*'), _, name='label')
|
178
|
-
reference = Sequence(label, Not(equals), name='reference')
|
179
|
-
quantifier = Sequence(Regex(r'[*+?]'), _, name='quantifier')
|
180
|
-
# This pattern supports empty literals. TODO: A problem?
|
181
|
-
spaceless_literal = Regex(r'u?r?"[^"\\]*(?:\\.[^"\\]*)*"',
|
182
|
-
ignore_case=True,
|
183
|
-
dot_all=True,
|
184
|
-
name='spaceless_literal')
|
185
|
-
literal = Sequence(spaceless_literal, _, name='literal')
|
186
|
-
regex = Sequence(Literal('~'),
|
187
|
-
literal,
|
188
|
-
Regex('[ilmsuxa]*', ignore_case=True),
|
189
|
-
_,
|
190
|
-
name='regex')
|
191
|
-
atom = OneOf(reference, literal, regex, name='atom')
|
192
|
-
quantified = Sequence(atom, quantifier, name='quantified')
|
193
|
-
|
194
|
-
term = OneOf(quantified, atom, name='term')
|
195
|
-
not_term = Sequence(Literal('!'), term, _, name='not_term')
|
196
|
-
term.members = (not_term,) + term.members
|
197
|
-
|
198
|
-
sequence = Sequence(term, OneOrMore(term), name='sequence')
|
199
|
-
or_term = Sequence(Literal('/'), _, term, name='or_term')
|
200
|
-
ored = Sequence(term, OneOrMore(or_term), name='ored')
|
201
|
-
expression = OneOf(ored, sequence, term, name='expression')
|
202
|
-
rule = Sequence(label, equals, expression, name='rule')
|
203
|
-
rules = Sequence(_, OneOrMore(rule), name='rules')
|
204
|
-
|
205
|
-
# Use those hard-coded rules to parse the (more extensive) rule syntax.
|
206
|
-
# (For example, unless I start using parentheses in the rule language
|
207
|
-
# definition itself, I should never have to hard-code expressions for
|
208
|
-
# those above.)
|
209
|
-
|
210
|
-
rule_tree = rules.parse(rule_syntax)
|
211
|
-
|
212
|
-
# Turn the parse tree into a map of expressions:
|
213
|
-
return RuleVisitor().visit(rule_tree)
|
214
|
-
|
215
|
-
|
216
|
-
# The grammar for parsing PEG grammar definitions:
|
217
|
-
# This is a nice, simple grammar. We may someday add to it, but it's a safe bet
|
218
|
-
# that the future will always be a superset of this.
|
219
|
-
rule_syntax = (r'''
|
220
|
-
# Ignored things (represented by _) are typically hung off the end of the
|
221
|
-
# leafmost kinds of nodes. Literals like "/" count as leaves.
|
222
|
-
|
223
|
-
rules = _ rule*
|
224
|
-
rule = label equals expression
|
225
|
-
equals = "=" _
|
226
|
-
literal = spaceless_literal _
|
227
|
-
|
228
|
-
# So you can't spell a regex like `~"..." ilm`:
|
229
|
-
spaceless_literal = ~"u?r?\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\""is /
|
230
|
-
~"u?r?'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'"is
|
231
|
-
|
232
|
-
expression = ored / sequence / term
|
233
|
-
or_term = "/" _ term
|
234
|
-
ored = term or_term+
|
235
|
-
sequence = term term+
|
236
|
-
not_term = "!" term _
|
237
|
-
lookahead_term = "&" term _
|
238
|
-
term = not_term / lookahead_term / quantified / atom
|
239
|
-
quantified = atom quantifier
|
240
|
-
atom = reference / literal / regex / parenthesized
|
241
|
-
regex = "~" spaceless_literal ~"[ilmsuxa]*"i _
|
242
|
-
parenthesized = "(" _ expression ")" _
|
243
|
-
quantifier = ~"[*+?]" _
|
244
|
-
reference = label !equals
|
245
|
-
|
246
|
-
# A subsequent equal sign is the only thing that distinguishes a label
|
247
|
-
# (which begins a new rule) from a reference (which is just a pointer to a
|
248
|
-
# rule defined somewhere else):
|
249
|
-
label = ~"[a-zA-Z_][a-zA-Z_0-9]*" _
|
250
|
-
|
251
|
-
# _ = ~r"\s*(?:#[^\r\n]*)?\s*"
|
252
|
-
_ = meaninglessness*
|
253
|
-
meaninglessness = ~r"\s+" / comment
|
254
|
-
comment = ~r"#[^\r\n]*"
|
255
|
-
''')
|
256
|
-
|
257
|
-
|
258
|
-
class LazyReference(str):
|
259
|
-
"""A lazy reference to a rule, which we resolve after grokking all the
|
260
|
-
rules"""
|
261
|
-
|
262
|
-
name = u''
|
263
|
-
|
264
|
-
# Just for debugging:
|
265
|
-
def _as_rhs(self):
|
266
|
-
return u'<LazyReference to %s>' % self
|
267
|
-
|
268
|
-
|
269
|
-
class RuleVisitor(NodeVisitor):
|
270
|
-
"""Turns a parse tree of a grammar definition into a map of ``Expression``
|
271
|
-
objects
|
272
|
-
|
273
|
-
This is the magic piece that breathes life into a parsed bunch of parse
|
274
|
-
rules, allowing them to go forth and parse other things.
|
275
|
-
|
276
|
-
"""
|
277
|
-
quantifier_classes = {'?': Optional, '*': ZeroOrMore, '+': OneOrMore}
|
278
|
-
|
279
|
-
visit_expression = visit_term = visit_atom = NodeVisitor.lift_child
|
280
|
-
|
281
|
-
def __init__(self, custom_rules=None):
|
282
|
-
"""Construct.
|
283
|
-
|
284
|
-
:arg custom_rules: A dict of {rule name: expression} holding custom
|
285
|
-
rules which will take precedence over the others
|
286
|
-
|
287
|
-
"""
|
288
|
-
self.custom_rules = custom_rules or {}
|
289
|
-
|
290
|
-
def visit_parenthesized(self, node, parenthesized):
|
291
|
-
"""Treat a parenthesized subexpression as just its contents.
|
292
|
-
|
293
|
-
Its position in the tree suffices to maintain its grouping semantics.
|
294
|
-
|
295
|
-
"""
|
296
|
-
left_paren, _, expression, right_paren, _ = parenthesized
|
297
|
-
return expression
|
298
|
-
|
299
|
-
def visit_quantifier(self, node, quantifier):
|
300
|
-
"""Turn a quantifier into just its symbol-matching node."""
|
301
|
-
symbol, _ = quantifier
|
302
|
-
return symbol
|
303
|
-
|
304
|
-
def visit_quantified(self, node, quantified):
|
305
|
-
atom, quantifier = quantified
|
306
|
-
return self.quantifier_classes[quantifier.text](atom)
|
307
|
-
|
308
|
-
def visit_lookahead_term(self, node, lookahead_term):
|
309
|
-
ampersand, term, _ = lookahead_term
|
310
|
-
return Lookahead(term)
|
311
|
-
|
312
|
-
def visit_not_term(self, node, not_term):
|
313
|
-
exclamation, term, _ = not_term
|
314
|
-
return Not(term)
|
315
|
-
|
316
|
-
def visit_rule(self, node, rule):
|
317
|
-
"""Assign a name to the Expression and return it."""
|
318
|
-
label, equals, expression = rule
|
319
|
-
expression.name = label # Assign a name to the expr.
|
320
|
-
return expression
|
321
|
-
|
322
|
-
def visit_sequence(self, node, sequence):
|
323
|
-
"""A parsed Sequence looks like [term node, OneOrMore node of
|
324
|
-
``another_term``s]. Flatten it out."""
|
325
|
-
term, other_terms = sequence
|
326
|
-
return Sequence(term, *other_terms)
|
327
|
-
|
328
|
-
def visit_ored(self, node, ored):
|
329
|
-
first_term, other_terms = ored
|
330
|
-
return OneOf(first_term, *other_terms)
|
331
|
-
|
332
|
-
def visit_or_term(self, node, or_term):
|
333
|
-
"""Return just the term from an ``or_term``.
|
334
|
-
|
335
|
-
We already know it's going to be ored, from the containing ``ored``.
|
336
|
-
|
337
|
-
"""
|
338
|
-
slash, _, term = or_term
|
339
|
-
return term
|
340
|
-
|
341
|
-
def visit_label(self, node, label):
|
342
|
-
"""Turn a label into a unicode string."""
|
343
|
-
name, _ = label
|
344
|
-
return name.text
|
345
|
-
|
346
|
-
def visit_reference(self, node, reference):
|
347
|
-
"""Stick a :class:`LazyReference` in the tree as a placeholder.
|
348
|
-
|
349
|
-
We resolve them all later.
|
350
|
-
|
351
|
-
"""
|
352
|
-
label, not_equals = reference
|
353
|
-
return LazyReference(label)
|
354
|
-
|
355
|
-
def visit_regex(self, node, regex):
|
356
|
-
"""Return a ``Regex`` expression."""
|
357
|
-
tilde, literal, flags, _ = regex
|
358
|
-
flags = flags.text.upper()
|
359
|
-
pattern = literal.literal # Pull the string back out of the Literal
|
360
|
-
# object.
|
361
|
-
return Regex(pattern, ignore_case='I' in flags,
|
362
|
-
locale='L' in flags,
|
363
|
-
multiline='M' in flags,
|
364
|
-
dot_all='S' in flags,
|
365
|
-
unicode='U' in flags,
|
366
|
-
verbose='X' in flags,
|
367
|
-
ascii='A' in flags)
|
368
|
-
|
369
|
-
def visit_spaceless_literal(self, spaceless_literal, visited_children):
|
370
|
-
"""Turn a string literal into a ``Literal`` that recognizes it."""
|
371
|
-
return Literal(evaluate_string(spaceless_literal.text))
|
372
|
-
|
373
|
-
def visit_literal(self, node, literal):
|
374
|
-
"""Pick just the literal out of a literal-and-junk combo."""
|
375
|
-
spaceless_literal, _ = literal
|
376
|
-
return spaceless_literal
|
377
|
-
|
378
|
-
def generic_visit(self, node, visited_children):
|
379
|
-
"""Replace childbearing nodes with a list of their children; keep
|
380
|
-
others untouched.
|
381
|
-
|
382
|
-
For our case, if a node has children, only the children are important.
|
383
|
-
Otherwise, keep the node around for (for example) the flags of the
|
384
|
-
regex rule. Most of these kept-around nodes are subsequently thrown
|
385
|
-
away by the other visitor methods.
|
386
|
-
|
387
|
-
We can't simply hang the visited children off the original node; that
|
388
|
-
would be disastrous if the node occurred in more than one place in the
|
389
|
-
tree.
|
390
|
-
|
391
|
-
"""
|
392
|
-
return visited_children or node # should semantically be a tuple
|
393
|
-
|
394
|
-
def _resolve_refs(self, rule_map, expr, done):
|
395
|
-
"""Return an expression with all its lazy references recursively
|
396
|
-
resolved.
|
397
|
-
|
398
|
-
Resolve any lazy references in the expression ``expr``, recursing into
|
399
|
-
all subexpressions.
|
400
|
-
|
401
|
-
:arg done: The set of Expressions that have already been or are
|
402
|
-
currently being resolved, to ward off redundant work and prevent
|
403
|
-
infinite recursion for circular refs
|
404
|
-
|
405
|
-
"""
|
406
|
-
if isinstance(expr, LazyReference):
|
407
|
-
label = str(expr)
|
408
|
-
try:
|
409
|
-
reffed_expr = rule_map[label]
|
410
|
-
except KeyError:
|
411
|
-
raise UndefinedLabel(expr)
|
412
|
-
return self._resolve_refs(rule_map, reffed_expr, done)
|
413
|
-
else:
|
414
|
-
if getattr(expr, 'members', ()) and expr not in done:
|
415
|
-
# Prevents infinite recursion for circular refs. At worst, one
|
416
|
-
# of `expr.members` can refer back to `expr`, but it can't go
|
417
|
-
# any farther.
|
418
|
-
done.add(expr)
|
419
|
-
expr.members = tuple(self._resolve_refs(rule_map, member, done)
|
420
|
-
for member in expr.members)
|
421
|
-
return expr
|
422
|
-
|
423
|
-
def visit_rules(self, node, rules_list):
|
424
|
-
"""Collate all the rules into a map. Return (map, default rule).
|
425
|
-
|
426
|
-
The default rule is the first one. Or, if you have more than one rule
|
427
|
-
of that name, it's the last-occurring rule of that name. (This lets you
|
428
|
-
override the default rule when you extend a grammar.) If there are no
|
429
|
-
string-based rules, the default rule is None, because the custom rules,
|
430
|
-
due to being kwarg-based, are unordered.
|
431
|
-
|
432
|
-
"""
|
433
|
-
_, rules = rules_list
|
434
|
-
|
435
|
-
# Map each rule's name to its Expression. Later rules of the same name
|
436
|
-
# override earlier ones. This lets us define rules multiple times and
|
437
|
-
# have the last declaration win, so you can extend grammars by
|
438
|
-
# concatenation.
|
439
|
-
rule_map = OrderedDict((expr.name, expr) for expr in rules)
|
440
|
-
|
441
|
-
# And custom rules override string-based rules. This is the least
|
442
|
-
# surprising choice when you compare the dict constructor:
|
443
|
-
# dict({'x': 5}, x=6).
|
444
|
-
rule_map.update(self.custom_rules)
|
445
|
-
|
446
|
-
# Resolve references. This tolerates forward references.
|
447
|
-
done = set()
|
448
|
-
rule_map = OrderedDict((expr.name, self._resolve_refs(rule_map, expr, done))
|
449
|
-
for expr in rule_map.values())
|
450
|
-
|
451
|
-
# isinstance() is a temporary hack around the fact that * rules don't
|
452
|
-
# always get transformed into lists by NodeVisitor. We should fix that;
|
453
|
-
# it's surprising and requires writing lame branches like this.
|
454
|
-
return rule_map, (rule_map[rules[0].name]
|
455
|
-
if isinstance(rules, list) and rules else None)
|
456
|
-
|
457
|
-
|
458
|
-
class TokenRuleVisitor(RuleVisitor):
|
459
|
-
"""A visitor which builds expression trees meant to work on sequences of
|
460
|
-
pre-lexed tokens rather than strings"""
|
461
|
-
|
462
|
-
def visit_spaceless_literal(self, spaceless_literal, visited_children):
|
463
|
-
"""Turn a string literal into a ``TokenMatcher`` that matches
|
464
|
-
``Token`` objects by their ``type`` attributes."""
|
465
|
-
return TokenMatcher(evaluate_string(spaceless_literal.text))
|
466
|
-
|
467
|
-
def visit_regex(self, node, regex):
|
468
|
-
tilde, literal, flags, _ = regex
|
469
|
-
raise BadGrammar('Regexes do not make sense in TokenGrammars, since '
|
470
|
-
'TokenGrammars operate on pre-lexed tokens rather '
|
471
|
-
'than characters.')
|
472
|
-
|
473
|
-
|
474
|
-
# Bootstrap to level 1...
|
475
|
-
rule_grammar = BootstrappingGrammar(rule_syntax)
|
476
|
-
# ...and then to level 2. This establishes that the node tree of our rule
|
477
|
-
# syntax is built by the same machinery that will build trees of our users'
|
478
|
-
# grammars. And the correctness of that tree is tested, indirectly, in
|
479
|
-
# test_grammar.
|
480
|
-
rule_grammar = Grammar(rule_syntax)
|
481
|
-
|
482
|
-
|
483
|
-
# TODO: Teach Expression trees how to spit out Python representations of
|
484
|
-
# themselves. Then we can just paste that in above, and we won't have to
|
485
|
-
# bootstrap on import. Though it'll be a little less DRY. [Ah, but this is not
|
486
|
-
# so clean, because it would have to output multiple statements to get multiple
|
487
|
-
# refs to a single expression hooked up.]
|