Commit d797d415 by dongshufeng

chore: Bump

parent c67d0a0d
...@@ -43,9 +43,9 @@ dependencies = [ ...@@ -43,9 +43,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.96" version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]] [[package]]
name = "anymap2" name = "anymap2"
...@@ -73,9 +73,9 @@ dependencies = [ ...@@ -73,9 +73,9 @@ dependencies = [
[[package]] [[package]]
name = "arrow-schema" name = "arrow-schema"
version = "54.2.0" version = "54.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f40f6be8f78af1ab610db7d9b236e21d587b7168e368a36275d2e5670096735" checksum = "85934a9d0261e0fa5d4e2a5295107d743b543a6e0484a835d4b8db2da15306f9"
dependencies = [ dependencies = [
"serde", "serde",
] ]
...@@ -112,9 +112,9 @@ dependencies = [ ...@@ -112,9 +112,9 @@ dependencies = [
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.8.0" version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]] [[package]]
name = "boolinator" name = "boolinator"
...@@ -130,9 +130,9 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" ...@@ -130,9 +130,9 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.21.0" version = "1.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
...@@ -163,9 +163,9 @@ dependencies = [ ...@@ -163,9 +163,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.15" version = "1.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
...@@ -178,16 +178,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" ...@@ -178,16 +178,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.39" version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c"
dependencies = [ dependencies = [
"android-tzdata", "android-tzdata",
"iana-time-zone", "iana-time-zone",
"js-sys", "js-sys",
"num-traits", "num-traits",
"wasm-bindgen", "wasm-bindgen",
"windows-targets", "windows-link",
] ]
[[package]] [[package]]
...@@ -313,27 +313,27 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" ...@@ -313,27 +313,27 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
name = "derive_more" name = "derive_more"
version = "1.0.0" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [ dependencies = [
"derive_more-impl", "derive_more-impl",
] ]
[[package]] [[package]]
name = "derive_more-impl" name = "derive_more-impl"
version = "1.0.0" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
"unicode-xid", "unicode-xid",
] ]
...@@ -345,7 +345,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" ...@@ -345,7 +345,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -427,7 +427,7 @@ dependencies = [ ...@@ -427,7 +427,7 @@ dependencies = [
"ciborium", "ciborium",
"log", "log",
"mems", "mems",
"petgraph 0.7.1", "petgraph",
] ]
[[package]] [[package]]
...@@ -451,7 +451,7 @@ dependencies = [ ...@@ -451,7 +451,7 @@ dependencies = [
"eig-domain", "eig-domain",
"eig-expr", "eig-expr",
"log", "log",
"petgraph 0.7.1", "petgraph",
"serde", "serde",
] ]
...@@ -482,9 +482,9 @@ dependencies = [ ...@@ -482,9 +482,9 @@ dependencies = [
[[package]] [[package]]
name = "either" name = "either"
version = "1.13.0" version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
...@@ -519,21 +519,15 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" ...@@ -519,21 +519,15 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]] [[package]]
name = "fixedbitset" name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "fixedbitset"
version = "0.5.7" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.35" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide",
...@@ -598,7 +592,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" ...@@ -598,7 +592,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1023,7 +1017,7 @@ dependencies = [ ...@@ -1023,7 +1017,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1146,7 +1140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -1146,7 +1140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9311685eb9a34808bbb0608ad2fcab9ae216266beca5848613e95553ac914e3b" checksum = "9311685eb9a34808bbb0608ad2fcab9ae216266beca5848613e95553ac914e3b"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1187,9 +1181,9 @@ dependencies = [ ...@@ -1187,9 +1181,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.169" version = "0.2.170"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
...@@ -1236,12 +1230,6 @@ dependencies = [ ...@@ -1236,12 +1230,6 @@ dependencies = [
] ]
[[package]] [[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.5" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
...@@ -1274,7 +1262,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" ...@@ -1274,7 +1262,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1294,12 +1282,11 @@ dependencies = [ ...@@ -1294,12 +1282,11 @@ dependencies = [
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [ dependencies = [
"memchr", "memchr",
"minimal-lexical",
] ]
[[package]] [[package]]
...@@ -1398,24 +1385,14 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" ...@@ -1398,24 +1385,14 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "petgraph" name = "petgraph"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db"
dependencies = [
"fixedbitset 0.4.2",
"indexmap 2.7.1",
"serde",
"serde_derive",
]
[[package]]
name = "petgraph"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772"
dependencies = [ dependencies = [
"fixedbitset 0.5.7", "fixedbitset",
"indexmap 2.7.1", "indexmap 2.7.1",
"serde",
"serde_derive",
] ]
[[package]] [[package]]
...@@ -1473,7 +1450,7 @@ checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" ...@@ -1473,7 +1450,7 @@ checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1501,9 +1478,9 @@ dependencies = [ ...@@ -1501,9 +1478,9 @@ dependencies = [
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.10.0" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
[[package]] [[package]]
name = "portable-atomic-util" name = "portable-atomic-util"
...@@ -1531,7 +1508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -1531,7 +1508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -1570,9 +1547,9 @@ dependencies = [ ...@@ -1570,9 +1547,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.93" version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
...@@ -1658,9 +1635,9 @@ dependencies = [ ...@@ -1658,9 +1635,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.38" version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
...@@ -1804,14 +1781,14 @@ checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" ...@@ -1804,14 +1781,14 @@ checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.139" version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
...@@ -1884,9 +1861,9 @@ dependencies = [ ...@@ -1884,9 +1861,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.98" version = "2.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
...@@ -1918,11 +1895,11 @@ dependencies = [ ...@@ -1918,11 +1895,11 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.11" version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [ dependencies = [
"thiserror-impl 2.0.11", "thiserror-impl 2.0.12",
] ]
[[package]] [[package]]
...@@ -1933,18 +1910,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" ...@@ -1933,18 +1910,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "2.0.11" version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -2004,7 +1981,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" ...@@ -2004,7 +1981,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
...@@ -2077,7 +2054,7 @@ dependencies = [ ...@@ -2077,7 +2054,7 @@ dependencies = [
"log", "log",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
...@@ -2112,7 +2089,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" ...@@ -2112,7 +2089,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
...@@ -2168,6 +2145,12 @@ dependencies = [ ...@@ -2168,6 +2145,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "windows-link"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3"
[[package]]
name = "windows-sys" name = "windows-sys"
version = "0.59.0" version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
...@@ -2321,7 +2304,7 @@ dependencies = [ ...@@ -2321,7 +2304,7 @@ dependencies = [
[[package]] [[package]]
name = "yew-bulma" name = "yew-bulma"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/shufengdong/yew-bulma.git#e553f07bcd09f5fdc24a503adb5fa961993cdd18" source = "git+https://github.com/shufengdong/yew-bulma.git#9d4e782152f1fe43408dba5087638e24cb483ceb"
dependencies = [ dependencies = [
"bytes", "bytes",
"chrono", "chrono",
...@@ -2329,7 +2312,7 @@ dependencies = [ ...@@ -2329,7 +2312,7 @@ dependencies = [
"gloo-utils 0.2.0", "gloo-utils 0.2.0",
"js-sys", "js-sys",
"log", "log",
"petgraph 0.6.5", "petgraph",
"serde", "serde",
"serde_cbor", "serde_cbor",
"serde_json", "serde_json",
...@@ -2367,14 +2350,14 @@ dependencies = [ ...@@ -2367,14 +2350,14 @@ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.98", "syn 2.0.99",
] ]
[[package]] [[package]]
name = "zip" name = "zip"
version = "2.2.2" version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae9c1ea7b3a5e1f4b922ff856a129881167511563dc219869afe3787fc0c1a45" checksum = "b280484c454e74e5fff658bbf7df8fdbe7a07c6b2de4a53def232c15ef138f3a"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"crc32fast", "crc32fast",
...@@ -2383,7 +2366,7 @@ dependencies = [ ...@@ -2383,7 +2366,7 @@ dependencies = [
"flate2", "flate2",
"indexmap 2.7.1", "indexmap 2.7.1",
"memchr", "memchr",
"thiserror 2.0.11", "thiserror 2.0.12",
"zopfli", "zopfli",
] ]
......
...@@ -7,7 +7,7 @@ rust-version.workspace = true ...@@ -7,7 +7,7 @@ rust-version.workspace = true
[dependencies] [dependencies]
fnv = "1.0" fnv = "1.0"
nom = "7.1" nom = "8.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
num-traits = "0.2" num-traits = "0.2"
num-complex = "0.4" num-complex = "0.4"
......
...@@ -3,7 +3,7 @@ use fnv::FnvHashMap; ...@@ -3,7 +3,7 @@ use fnv::FnvHashMap;
use ndarray::{Array, Ix1, Ix2, IxDyn}; use ndarray::{Array, Ix1, Ix2, IxDyn};
use num_complex::Complex64; use num_complex::Complex64;
use crate::{CtxProvider, Expr, Operation, Token::*}; use crate::{CtxMaps, Expr, Operation, Token::*};
use crate::{ContextProvider, Error, factorial, FuncEvalError, MyCx, MyF}; use crate::{ContextProvider, Error, factorial, FuncEvalError, MyCx, MyF};
use crate::expr::Context; use crate::expr::Context;
use crate::expr_complex::ContextCx; use crate::expr_complex::ContextCx;
...@@ -13,7 +13,7 @@ use crate::tsfn_basic::*; ...@@ -13,7 +13,7 @@ use crate::tsfn_basic::*;
thread_local!(static DEFAULT_CONTEXT: Context<'static> = Context::new()); thread_local!(static DEFAULT_CONTEXT: Context<'static> = Context::new());
thread_local!(pub static DEFAULT_CONTEXT_TENSOR: ContextTensor<'static> = ContextTensor::new()); thread_local!(pub static DEFAULT_CONTEXT_TENSOR: ContextTensor<'static> = ContextTensor::new());
impl ContextProvider for CtxProvider { impl ContextProvider for CtxMaps {
fn get_var(&self, name: &str) -> Option<f64> { fn get_var(&self, name: &str) -> Option<f64> {
self.var_values.get(name).cloned() self.var_values.get(name).cloned()
} }
......
...@@ -33,7 +33,7 @@ pub enum MyCx { ...@@ -33,7 +33,7 @@ pub enum MyCx {
pub enum ParseError { pub enum ParseError {
/// A token that is not allowed at the given location (contains the location of the offending /// A token that is not allowed at the given location (contains the location of the offending
/// character in the source string). /// character in the source string).
UnexpectedToken(usize), UnexpectedToken(usize, usize),
/// Missing right parentheses at the end of the source string (contains the number of missing /// Missing right parentheses at the end of the source string (contains the number of missing
/// parens). /// parens).
MissingRParen(i32), MissingRParen(i32),
...@@ -44,13 +44,9 @@ pub enum ParseError { ...@@ -44,13 +44,9 @@ pub enum ParseError {
impl Display for ParseError { impl Display for ParseError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self { match *self {
ParseError::UnexpectedToken(i) => write!(f, "Unexpected token at byte {}.", i), ParseError::UnexpectedToken(row, col) => write!(f, "Unexpected char at line: {row} column: {col}"),
ParseError::MissingRParen(i) => write!( ParseError::MissingRParen(i) => write!(f, "Missing {i} right parenthes{}.",
f, if i == 1 { "is" } else { "es" }),
"Missing {} right parenthes{}.",
i,
if i == 1 { "is" } else { "es" }
),
ParseError::MissingArgument => write!(f, "Missing argument at the end of expression."), ParseError::MissingArgument => write!(f, "Missing argument at the end of expression."),
} }
} }
...@@ -59,7 +55,7 @@ impl Display for ParseError { ...@@ -59,7 +55,7 @@ impl Display for ParseError {
impl std::error::Error for ParseError { impl std::error::Error for ParseError {
fn description(&self) -> &str { fn description(&self) -> &str {
match *self { match *self {
ParseError::UnexpectedToken(_) => "unexpected token", ParseError::UnexpectedToken(_, _) => "unexpected token",
ParseError::MissingRParen(_) => "missing right parenthesis", ParseError::MissingRParen(_) => "missing right parenthesis",
ParseError::MissingArgument => "missing argument", ParseError::MissingArgument => "missing argument",
} }
...@@ -79,7 +75,7 @@ impl Display for FuncEvalError { ...@@ -79,7 +75,7 @@ impl Display for FuncEvalError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self { match *self {
FuncEvalError::UnknownFunction => write!(f, "Unknown function"), FuncEvalError::UnknownFunction => write!(f, "Unknown function"),
FuncEvalError::NumberArgs(i) => write!(f, "Expected {} arguments", i), FuncEvalError::NumberArgs(i) => write!(f, "Expected {i} arguments"),
FuncEvalError::TooFewArguments => write!(f, "Too few arguments"), FuncEvalError::TooFewArguments => write!(f, "Too few arguments"),
FuncEvalError::TooManyArguments => write!(f, "Too many arguments"), FuncEvalError::TooManyArguments => write!(f, "Too many arguments"),
} }
...@@ -134,19 +130,19 @@ impl Display for RPNError { ...@@ -134,19 +130,19 @@ impl Display for RPNError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self { match *self {
RPNError::MismatchedLParen(i) => { RPNError::MismatchedLParen(i) => {
write!(f, "Mismatched left parenthesis at token {}.", i) write!(f, "Mismatched left parenthesis at token {i}.")
} }
RPNError::MismatchedRParen(i) => { RPNError::MismatchedRParen(i) => {
write!(f, "Mismatched right parenthesis at token {}.", i) write!(f, "Mismatched right parenthesis at token {i}.")
} }
RPNError::MismatchedLBracket(i) => { RPNError::MismatchedLBracket(i) => {
write!(f, "Mismatched left blackets at token {}.", i) write!(f, "Mismatched left blackets at token {i}.")
} }
RPNError::MismatchedRBracket(i) => { RPNError::MismatchedRBracket(i) => {
write!(f, "Mismatched right blackets at token {}.", i) write!(f, "Mismatched right blackets at token {i}.")
} }
RPNError::UnexpectedComma(i) => write!(f, "Unexpected comma at token {}", i), RPNError::UnexpectedComma(i) => write!(f, "Unexpected comma at token {i}"),
RPNError::NotEnoughOperands(i) => write!(f, "Missing operands at token {}", i), RPNError::NotEnoughOperands(i) => write!(f, "Missing operands at token {i}"),
RPNError::TooManyOperands => { RPNError::TooManyOperands => {
write!(f, "Too many operands left at the end of expression.") write!(f, "Too many operands left at the end of expression.")
} }
...@@ -306,7 +302,7 @@ pub struct Expr { ...@@ -306,7 +302,7 @@ pub struct Expr {
} }
impl Display for Expr { impl Display for Expr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{:?}", self) write!(f, "{:?}", self)
} }
} }
...@@ -344,22 +340,22 @@ pub trait ContextProvider { ...@@ -344,22 +340,22 @@ pub trait ContextProvider {
} }
} }
pub struct CtxProvider { pub struct CtxMaps {
var_values: HashMap<String, f64>, var_values: HashMap<String, f64>,
var_values_cx: HashMap<String, Complex64>, var_values_cx: HashMap<String, Complex64>,
var_values_tensor: HashMap<String, Array<f64, IxDyn>>, var_values_tensor: HashMap<String, Array<f64, IxDyn>>,
var_values_tensor_cx: HashMap<String, Array<Complex64, IxDyn>>, var_values_tensor_cx: HashMap<String, Array<Complex64, IxDyn>>,
} }
impl Default for CtxProvider { impl Default for CtxMaps {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
} }
} }
impl CtxProvider { impl CtxMaps {
pub fn new() -> Self { pub fn new() -> Self {
CtxProvider { CtxMaps {
var_values: Default::default(), var_values: Default::default(),
var_values_cx: Default::default(), var_values_cx: Default::default(),
var_values_tensor: Default::default(), var_values_tensor: Default::default(),
...@@ -427,3 +423,4 @@ pub fn parse_exprs(s: &str) -> Option<Vec<(String, Expr)>> { ...@@ -427,3 +423,4 @@ pub fn parse_exprs(s: &str) -> Option<Vec<(String, Expr)>> {
} }
Some(exprs) Some(exprs)
} }
// above should as same as in sparrowzz
\ No newline at end of file
//! Tokenizer that converts a mathematical expression in a string form into a series of `Token`s.
//!
//! The underlying parser is build using the [nom] parser combinator crate.
//!
//! The parser should tokenize only well-formed expressions.
//!
//! [nom]: https://crates.io/crates/nom
//!
use std; use std;
use std::fmt; use std::fmt;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
...@@ -9,7 +17,7 @@ use nom::character::complete::{digit0, digit1, multispace0}; ...@@ -9,7 +17,7 @@ use nom::character::complete::{digit0, digit1, multispace0};
use nom::combinator::{complete, map, map_res, opt}; use nom::combinator::{complete, map, map_res, opt};
use nom::error::{Error, ErrorKind}; use nom::error::{Error, ErrorKind};
use nom::sequence::{delimited, preceded, terminated}; use nom::sequence::{delimited, preceded, terminated};
use nom::IResult; use nom::{IResult, Parser};
use crate::{ParseError, Token, Operation}; use crate::{ParseError, Token, Operation};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
...@@ -59,29 +67,29 @@ fn binop(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -59,29 +67,29 @@ fn binop(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag(">"), |_| Token::Binary(Operation::GreatThan)), map(tag(">"), |_| Token::Binary(Operation::GreatThan)),
map(tag("<"), |_| Token::Binary(Operation::LessThan)), map(tag("<"), |_| Token::Binary(Operation::LessThan)),
)), )),
))(i) )).parse(i)
} }
// //
fn lparen(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn lparen(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag("("), |_| Token::LParen)(i) map(tag("("), |_| Token::LParen).parse(i)
} }
fn tensor(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn tensor(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag("["), |_| Token::Tensor(None))(i) map(tag("["), |_| Token::Tensor(None)).parse(i)
} }
fn rparen(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn rparen(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag(")"), |_| Token::RParen)(i) map(tag(")"), |_| Token::RParen).parse(i)
} }
fn rbracket(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn rbracket(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag("]"), |_| Token::RBracket)(i) map(tag("]"), |_| Token::RBracket).parse(i)
} }
fn fact(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn fact(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
if !i.starts_with(&b"!="[..]) { if !i.starts_with(&b"!="[..]) {
map(tag("!"), |_| Token::Unary(Operation::Fact))(i) map(tag("!"), |_| Token::Unary(Operation::Fact)).parse(i)
} else { } else {
Err(nom::Err::Error(Error { Err(nom::Err::Error(Error {
input: i, input: i,
...@@ -91,29 +99,29 @@ fn fact(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -91,29 +99,29 @@ fn fact(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
} }
fn comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag(","), |_| Token::Comma)(i) map(tag(","), |_| Token::Comma).parse(i)
} }
fn negpos(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn negpos(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
alt(( alt((
map(tag("+"), |_| Token::Unary(Operation::Plus)), map(tag("+"), |_| Token::Unary(Operation::Plus)),
map(tag("-"), |_| Token::Unary(Operation::Minus)), map(tag("-"), |_| Token::Unary(Operation::Minus)),
))(i) )).parse(i)
} }
fn not(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn not(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag("~~"), |_| Token::Unary(Operation::Not))(i) map(tag("~~"), |_| Token::Unary(Operation::Not)).parse(i)
} }
fn bitnot(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn bitnot(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(tag("~"), |_| Token::Unary(Operation::BitNot))(i) map(tag("~"), |_| Token::Unary(Operation::BitNot)).parse(i)
} }
fn number(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn number(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
let (left, mut len) = map(digit1, |s: &[u8]| s.len())(i)?; let (left, mut len) = map(digit1, |s: &[u8]| s.len()).parse(i)?;
let (left, s) = opt(preceded(tag("."), map(digit0, |s: &[u8]| s.len() + 1)))(left)?; let (left, s) = opt(preceded(tag("."), map(digit0, |s: &[u8]| s.len() + 1))).parse(left)?;
len += s.unwrap_or(0); len += s.unwrap_or(0);
let (mut left, op) = opt(alt((tag("e"), tag("E"))))(left)?; let (mut left, op) = opt(alt((tag("e"), tag("E")))).parse(left)?;
if op.is_some() { if op.is_some() {
let (l, s) = alt(( let (l, s) = alt((
preceded( preceded(
...@@ -121,7 +129,7 @@ fn number(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -121,7 +129,7 @@ fn number(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(digit1, |s: &[u8]| s.len() + 2), map(digit1, |s: &[u8]| s.len() + 2),
), ),
map(digit1, |s: &[u8]| s.len() + 1), map(digit1, |s: &[u8]| s.len() + 1),
))(left)?; )).parse(left)?;
len += s; len += s;
left = l; left = l;
} }
...@@ -142,6 +150,7 @@ fn ident(input: &[u8]) -> IResult<&[u8], &[u8], Error<&[u8]>> { ...@@ -142,6 +150,7 @@ fn ident(input: &[u8]) -> IResult<&[u8], &[u8], Error<&[u8]>> {
let (parsed, rest) = input.split_at(n + 1); let (parsed, rest) = input.split_at(n + 1);
Ok((rest, parsed)) Ok((rest, parsed))
} }
// support chinese variable name
Some(b'\'') | Some(b'\"')=> { Some(b'\'') | Some(b'\"')=> {
let start = *input.first().unwrap(); let start = *input.first().unwrap();
let n = input let n = input
...@@ -167,7 +176,7 @@ fn ident(input: &[u8]) -> IResult<&[u8], &[u8], Error<&[u8]>> { ...@@ -167,7 +176,7 @@ fn ident(input: &[u8]) -> IResult<&[u8], &[u8], Error<&[u8]>> {
} }
fn var(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn var(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
map(map_res(ident, from_utf8), |s: &str| Token::Var(s.into()))(i) map(map_res(ident, from_utf8), |s: &str| Token::Var(s.into())).parse(i)
} }
fn func(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn func(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
...@@ -177,7 +186,7 @@ fn func(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -177,7 +186,7 @@ fn func(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
from_utf8, from_utf8,
), ),
|s: &str| Token::Func(s.into(), None), |s: &str| Token::Func(s.into(), None),
)(i) ).parse(i)
} }
fn lexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn lexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
...@@ -185,7 +194,7 @@ fn lexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -185,7 +194,7 @@ fn lexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
multispace0, multispace0,
alt((number, func, tensor, var, negpos, lparen, not, bitnot, fact)), alt((number, func, tensor, var, negpos, lparen, not, bitnot, fact)),
multispace0, multispace0,
)(i) ).parse(i)
} }
fn after_rexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn after_rexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
...@@ -193,11 +202,11 @@ fn after_rexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -193,11 +202,11 @@ fn after_rexpr(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
multispace0, multispace0,
alt((binop, rparen, rbracket)), alt((binop, rparen, rbracket)),
multispace0, multispace0,
)(i) ).parse(i)
} }
fn after_rexpr_no_paren(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn after_rexpr_no_paren(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
delimited(multispace0, binop, multispace0)(i) delimited(multispace0, binop, multispace0).parse(i)
} }
fn after_rexpr_comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { fn after_rexpr_comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
...@@ -205,7 +214,7 @@ fn after_rexpr_comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> { ...@@ -205,7 +214,7 @@ fn after_rexpr_comma(i: &[u8]) -> IResult<&[u8], Token, Error<&[u8]>> {
multispace0, multispace0,
alt((binop, rparen, rbracket, comma)), alt((binop, rparen, rbracket, comma)),
multispace0, multispace0,
)(i) ).parse(i)
} }
pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> { pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> {
...@@ -235,7 +244,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> { ...@@ -235,7 +244,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> {
} }
Token::Tensor(_) => { Token::Tensor(_) => {
paren_stack.push(ParenState::Tensor); paren_stack.push(ParenState::Tensor);
if let Ok((rest2, _)) = delimited(multispace0, rbracket, multispace0)(rest) { if let Ok((rest2, _)) = delimited(multispace0, rbracket, multispace0).parse(rest) {
res.push(Token::Tensor(Some(0))); res.push(Token::Tensor(Some(0)));
s = rest2; s = rest2;
paren_stack.pop().expect("The paren_stack is empty!"); paren_stack.pop().expect("The paren_stack is empty!");
...@@ -245,7 +254,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> { ...@@ -245,7 +254,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> {
} }
Token::Func(name, _) => { Token::Func(name, _) => {
paren_stack.push(ParenState::Func); paren_stack.push(ParenState::Func);
if let Ok((rest2, _)) = delimited(multispace0, rparen, multispace0)(rest) { if let Ok((rest2, _)) = delimited(multispace0, rparen, multispace0).parse(rest) {
res.push(Token::Func(name.clone(), Some(0))); res.push(Token::Func(name.clone(), Some(0)));
s = rest2; s = rest2;
paren_stack.pop().expect("The paren_stack is empty!"); paren_stack.pop().expect("The paren_stack is empty!");
...@@ -277,7 +286,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> { ...@@ -277,7 +286,7 @@ pub fn tokenize<S: AsRef<str>>(input: S) -> Result<Vec<Token>, ParseError> {
String::from_utf8_lossy(s), String::from_utf8_lossy(s),
r r
); );
return Err(ParseError::UnexpectedToken(s.len())); return Err(ParseError::UnexpectedToken(1, s.len()));
} }
} }
} }
...@@ -336,4 +345,299 @@ impl Display for Token { ...@@ -336,4 +345,299 @@ impl Display for Token {
Token::Tensor(size) => write!(f, "Tensor({:?})", size), Token::Tensor(size) => write!(f, "Tensor({:?})", size),
} }
} }
} }
\ No newline at end of file
#[cfg(test)]
mod tests {
use nom::error;
use nom::error::ErrorKind::{Alpha, Digit};
use nom::Err::Error;
use crate::ParseError;
use super::*;
#[test]
fn test_binop() {
assert_eq!(
binop(b"+"),
Ok((&b""[..], Token::Binary(Operation::Plus)))
);
assert_eq!(
binop(b"-"),
Ok((&b""[..], Token::Binary(Operation::Minus)))
);
assert_eq!(
binop(b"*"),
Ok((&b""[..], Token::Binary(Operation::Times)))
);
assert_eq!(
binop(b"/"),
Ok((&b""[..], Token::Binary(Operation::Div)))
);
}
#[test]
fn test_number() {
assert_eq!(
number(b"32143"),
Ok((&b""[..], Token::Number(32143f64)))
);
assert_eq!(
number(b"2."),
Ok((&b""[..], Token::Number(2.0f64)))
);
assert_eq!(
number(b"32143.25"),
Ok((&b""[..], Token::Number(32143.25f64)))
);
assert_eq!(
number(b"0.125e9"),
Ok((&b""[..], Token::Number(0.125e9f64)))
);
assert_eq!(
number(b"20.5E-3"),
Ok((&b""[..], Token::Number(20.5E-3f64)))
);
assert_eq!(
number(b"123423e+50"),
Ok((&b""[..], Token::Number(123423e+50f64)))
);
assert_eq!(
number(b""),
Err(Error(error::Error {
input: &b""[..],
code: Digit
}))
);
assert_eq!(
number(b".2"),
Err(Error(error::Error {
input: &b".2"[..],
code: Digit
}))
);
assert_eq!(
number(b"+"),
Err(Error(error::Error {
input: &b"+"[..],
code: Digit
}))
);
assert_eq!(
number(b"e"),
Err(Error(error::Error {
input: &b"e"[..],
code: Digit
}))
);
assert_eq!(
number(b"1E"),
Err(Error(error::Error {
input: &b""[..],
code: Digit
}))
);
assert_eq!(
number(b"1e+"),
Err(Error(error::Error {
input: &b"+"[..],
code: Digit
}))
);
}
#[test]
fn test_var() {
for &s in ["abc", "U0", "_034", "a_be45EA", "aAzZ_"].iter() {
assert_eq!(
var(s.as_bytes()),
Ok((&b""[..], Token::Var(s.into())))
);
}
for &s in ["\'a\'", "\"U0\"", "\"_034\"", "'*'", "\"+\""].iter() {
assert_eq!(
var(s.as_bytes()),
Ok((&b""[..], tokenize(s).unwrap()[0].clone()))
);
}
assert_eq!(
var(b""),
Err(Error(error::Error {
input: &b""[..],
code: Alpha
}))
);
assert_eq!(
var(b"0"),
Err(Error(error::Error {
input: &b"0"[..],
code: Alpha
}))
);
}
#[test]
fn test_func() {
for &s in ["abc(", "u0(", "_034 (", "A_be45EA ("].iter() {
assert_eq!(
func(s.as_bytes()),
Ok((&b""[..], Token::Func(s[0..s.len() - 1].trim().into(), None)))
);
}
assert_eq!(
func(b""),
Err(Error(error::Error {
input: &b""[..],
code: Alpha
}))
);
assert_eq!(
func(b"("),
Err(Error(error::Error {
input: &b"("[..],
code: Alpha
}))
);
assert_eq!(
func(b"0("),
Err(Error(error::Error {
input: &b"0("[..],
code: Alpha
}))
);
}
#[test]
fn test_tokenize() {
use super::Operation::*;
use super::Token::*;
assert_eq!(tokenize("a"), Ok(vec![Var("a".into())]));
assert_eq!(
tokenize("2 +(3--2) "),
Ok(vec![
Number(2f64),
Binary(Plus),
LParen,
Number(3f64),
Binary(Minus),
Unary(Minus),
Number(2f64),
RParen,
])
);
assert_eq!(
tokenize("-2^ ab0 *12 - C_0"),
Ok(vec![
Unary(Minus),
Number(2f64),
Binary(Pow),
Var("ab0".into()),
Binary(Times),
Number(12f64),
Binary(Minus),
Var("C_0".into()),
])
);
assert_eq!(
tokenize("-sin(pi * 3)^ cos(2) / Func2(x, f(y), z) * _buildIN(y)"),
Ok(vec![
Unary(Minus),
Func("sin".into(), None),
Var("pi".into()),
Binary(Times),
Number(3f64),
RParen,
Binary(Pow),
Func("cos".into(), None),
Number(2f64),
RParen,
Binary(Div),
Func("Func2".into(), None),
Var("x".into()),
Comma,
Func("f".into(), None),
Var("y".into()),
RParen,
Comma,
Var("z".into()),
RParen,
Binary(Times),
Func("_buildIN".into(), None),
Var("y".into()),
RParen,
])
);
assert_eq!(
tokenize("2 % 3"),
Ok(vec![Number(2f64), Binary(Rem), Number(3f64)])
);
assert_eq!(
tokenize("1 + !3 + 1"),
Ok(vec![
Number(1f64),
Binary(Plus),
Unary(Fact),
Number(3f64),
Binary(Plus),
Number(1f64),
])
);
assert_eq!(tokenize("3!"), Err(ParseError::UnexpectedToken(1, 1)));
assert_eq!(tokenize("()"), Err(ParseError::UnexpectedToken(1, 1)));
assert_eq!(tokenize(""), Err(ParseError::MissingArgument));
assert_eq!(tokenize("2)"), Err(ParseError::UnexpectedToken(1, 1)));
assert_eq!(tokenize("2^"), Err(ParseError::MissingArgument));
assert_eq!(tokenize("(((2)"), Err(ParseError::MissingRParen(2)));
assert_eq!(tokenize("f(2,)"), Err(ParseError::UnexpectedToken(1, 1)));
assert_eq!(tokenize("f(,2)"), Err(ParseError::UnexpectedToken(1, 3)));
}
#[test]
fn test_func_with_no_para() {
assert_eq!(
tokenize("f()"),
Ok(vec![Token::Func("f".to_string(), Some(0))])
);
assert_eq!(
tokenize("f( )"),
Ok(vec![Token::Func("f".to_string(), Some(0))])
);
assert!(tokenize("f(f2(1), f3())").is_ok());
assert!(tokenize("f(f2(1), f3(), a)").is_ok());
assert!(tokenize("f(a, b, f2(), f3(), c)").is_ok());
assert!(tokenize("-sin(pi * 3)^ cos(2) / Func2(x, f(), z) * _buildIN()").is_ok());
}
#[test]
fn test_show_latex() {
//let test_token = tokenize("x1^2-10*x1+x2^2+8<=5*2").unwrap();
//let test_token = tokenize("max((5*1)*x1+3*x2+2*x3+(10-3)*x4+4*x5)").unwrap();
//let test_token = tokenize("1*3*x2+sin(8-2)*x3 - cos(pi)< 7").unwrap();
//let test_token = tokenize("x1%5+3/3*x2+min(2,5)*x3*2e19 && 1").unwrap();
//let test_token = tokenize("2!").unwrap();
let test_token = tokenize("~x1").unwrap();
println!("{:?}", test_token);
for x in test_token {
println!("{}", x);
}
}
#[test]
fn test_tensor() {
assert_eq!(
tokenize("[3]"),
Ok(vec![Token::Tensor(None), Token::Number(3.), Token::RBracket])
);
assert!(tokenize("[[1,2],[3,4]]").is_ok());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论