From ce42ec62fc489a3606dd0b3817177706c563b190 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Wed, 21 Aug 2024 09:31:22 +0200 Subject: [PATCH 1/4] fix: update docs and flake --- README.md | 4 ++-- flake.lock | 42 +++++++++++++++++++++--------------------- flake.nix | 6 +++++- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 31989c0..33484ff 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [LOGO HERE](https://github.com/reciperium/recipe-lang/issues/1) -> Write recipes understood by humans and machines, powering reciperium.com +> Write recipes understood by humans and machines, powering [reciperium.com](https://www.reciperium.com) > [!WARNING] > -> Recipe lang is in its infancy, this may change unexpectedly +> Recipe lang is in its infancy, things may change unexpectedly ## About diff --git a/flake.lock b/flake.lock index 26a4a72..b7bf4ea 100644 --- a/flake.lock +++ b/flake.lock @@ -27,11 +27,11 @@ "pyproject-nix": "pyproject-nix" }, "locked": { - "lastModified": 1716464232, - "narHash": "sha256-wNhSO6SGWefGf5P8+s9dBpLy2SbFKkfUGIgC0yCzw5c=", + "lastModified": 1722526955, + "narHash": "sha256-fFS8aDnfK9Qfm2FLnQ8pqWk8FzvFEv5LvTuZTZLREnc=", "owner": "nix-community", "repo": "dream2nix", - "rev": "e88ba85d075f943ba4250ca942b2736286bd23b9", + "rev": "3fd4c14d3683baac8d1f94286ae14fe160888b51", "type": "github" }, "original": { @@ -47,11 +47,11 @@ ] }, "locked": { - "lastModified": 1715865404, - "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "lastModified": 1722555600, + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", "type": "github" }, "original": { @@ -88,11 +88,11 @@ "treefmt": "treefmt" }, "locked": { - "lastModified": 1716531196, - "narHash": "sha256-c5vvR/SP5Z/qKvOTh+YXbGU3vKA2DhdaPCKYkEtMA7U=", + "lastModified": 1724134441, + "narHash": "sha256-9I9yQByU5DRgzm6fwytw18o65GglHrFa3BuINK+c5Ns=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "3d0dec0804ac469283eb2595df1d84f123e75037", + "rev": "0de7d447591698463a0220c5f8fc90941131df6d", "type": "github" }, "original": { @@ -103,11 +103,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716330097, - "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "lastModified": 1723991338, + "narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "rev": "8a3354191c0d7144db9756a74755672387b702ba", "type": "github" }, "original": { @@ -125,11 +125,11 @@ ] }, "locked": { - "lastModified": 1715865404, - "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "lastModified": 1722555600, + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", "type": "github" }, "original": { @@ -188,11 +188,11 @@ "rust-overlay": { "flake": false, "locked": { - "lastModified": 1716517042, - "narHash": "sha256-PDPMpBVv+6XdV4FvBWk002IBGofDIWCpo9ewks0kStM=", + "lastModified": 1724120436, + "narHash": "sha256-/MvfxTjco5UDBF6SEvwyeXrXwZG7nz7/mDVreQNKsWg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "66a43411079d0d1b1b776c0a6ced20a5df896edb", + "rev": "48e61fe824f5823e4f3f15dd9a75c19c63649269", "type": "github" }, "original": { @@ -232,11 +232,11 @@ ] }, "locked": { - "lastModified": 1715940852, - "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=", + "lastModified": 1723808491, + "narHash": "sha256-rhis3qNuGmJmYC/okT7Dkc4M8CeUuRCSvW6kC2f3hBc=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b", + "rev": "1d07739554fdc4f8481068f1b11d6ab4c1a4167a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 2df2d4b..2a66863 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,11 @@ }; # export the project devshell as the default devshell - devShells.default = config.nci.outputs."recipe-lang".devShell; + # devShells.default = config.nci.outputs."recipe-lang".devShell; + devShells.default = pkgs.mkShell { + inputsFrom = [ config.nci.outputs."recipe-lang".devShell ]; + packages = [ pkgs.cargo-dist ]; + }; # export the release package of the crate as default package packages.default = config.nci.outputs."recp".packages.release; packages.recp = config.nci.outputs."recp".packages.release; From 426dcb7e0ae4d137ec9a6858e5fe40ee3830a08b Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Sun, 6 Oct 2024 20:19:50 +0200 Subject: [PATCH 2/4] fix: parse backstory and word properly --- crates/recipe-parser/src/parser.rs | 41 +++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/crates/recipe-parser/src/parser.rs b/crates/recipe-parser/src/parser.rs index 798137d..8619f5b 100644 --- a/crates/recipe-parser/src/parser.rs +++ b/crates/recipe-parser/src/parser.rs @@ -1,8 +1,9 @@ use std::fmt::Display; -use winnow::ascii::{line_ending, multispace0, multispace1, space0}; +use winnow::ascii::{line_ending, multispace0, space0, space1}; use winnow::combinator::{alt, cut_err, delimited, opt, preceded, repeat, rest}; use winnow::error::{ContextError, ParseError, StrContext, StrContextValue}; +use winnow::stream::AsChar; use winnow::token::{take_till, take_until, take_while}; use winnow::{Located, PResult, Parser}; @@ -155,8 +156,7 @@ fn parse_recipe_ref<'a>( /// Tokens are separated into words fn parse_word<'a>(input: &mut Input<'a>) -> PResult<&'a str> { - let multispace = " \t\r\n"; - take_till(1.., move |c| multispace.contains(c)).parse_next(input) + take_till(1.., AsChar::is_space).parse_next(input) } fn parse_metadata<'a>(input: &mut Input<'a>) -> PResult<(&'a str, &'a str)> { @@ -288,7 +288,7 @@ pub fn recipe_value<'a>(input: &mut Input<'a>) -> PResult> { parse_comment.map(|v| Token::Comment(v)), "(".map(|v| Token::Word(v)), parse_word.map(|v| Token::Word(v)), - multispace1.map(|v| Token::Space(v)), + space1.map(|v| Token::Space(v)), )) .parse_next(input) } @@ -583,6 +583,23 @@ mod test { println!("{:?}", recipe); } + #[rstest] + #[case("Foo. ")] + #[case("Foo.")] + #[case("Foo, bar")] + #[case("Foo,bar")] + #[case("Foo,")] + #[case("Foo, ")] + #[case("Foo,\n")] + #[case("Foo.\n")] + #[case("Foo.\nfoo")] + #[case("Foo,\nfoo")] + fn test_symbol_parsing(#[case] input: &str) { + let recipe_result = parse(input); + + assert!(recipe_result.is_ok()); + } + #[test] fn test_parse_ok() { let input = "Boil the quinoa for t{5 minutes} in a &{pot}.\nPut the boiled {quinoa}(200gr) in the base of the bowl."; @@ -597,6 +614,22 @@ mod test { println!("{:?}", recipe); } + #[test] + fn test_parse_with_backstory_ok() { + let input = "Foo. \n---\nA backstory"; + let expected = vec![ + Token::Word("Foo."), + Token::Space(" "), + Token::Backstory("A backstory"), + ]; + let recipe = parse(input).expect("parse failed"); + + println!("{:?}", recipe); + + assert_eq!(expected, recipe); + println!("{:?}", recipe); + } + #[test] #[cfg(feature = "serde")] fn test_token_serialization_works() { From 73d30aa9ac1c093c3c77f67ed66542b142cdf729 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Sun, 6 Oct 2024 20:20:45 +0200 Subject: [PATCH 3/4] chore: editor corrections --- .editorconfig | 38 +++++++++++++++++++++++++++++++++++++ .github/workflows/bump.yaml | 2 +- flake.nix | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1134063 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# http://editorconfig.org + +root = true + +[*] +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 + +# Use 2 spaces for the HTML files +[*.html] +indent_size = 2 + +# The JSON files contain newlines inconsistently +[*.json] +indent_size = 2 +insert_final_newline = ignore + +# Use 2 spaces for the JS and TS files +[*.{js, ts}] +indent_style = space +indent_size = 2 + +# Use 2 spaces for the YAML files +[*.{yml, yaml}] +indent_style = space +indent_size = 2 + +# Ignore vendor libraries +[**/static/**/vendor/**] +indent_style = ignore +indent_size = ignore + +# Minified JavaScript files shouldn't be changed +[**.min.js] +indent_style = ignore +insert_final_newline = ignore diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml index 5e6c48c..413251c 100644 --- a/.github/workflows/bump.yaml +++ b/.github/workflows/bump.yaml @@ -7,7 +7,7 @@ on: jobs: bump-version: - if: "!startsWith(github.event.head_commit.message, 'bump:')" + if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }} runs-on: ubuntu-latest name: "Bump version and create changelog with commitizen" steps: diff --git a/flake.nix b/flake.nix index 2a66863..d973de5 100644 --- a/flake.nix +++ b/flake.nix @@ -47,7 +47,7 @@ # devShells.default = config.nci.outputs."recipe-lang".devShell; devShells.default = pkgs.mkShell { inputsFrom = [ config.nci.outputs."recipe-lang".devShell ]; - packages = [ pkgs.cargo-dist ]; + packages = [ pkgs.cargo-dist pkgs.rustup ]; }; # export the release package of the crate as default package packages.default = config.nci.outputs."recp".packages.release; From eed2b125d91bf22bdaff8f4d8301c38e72fd3056 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Willemoes Date: Sun, 6 Oct 2024 20:36:32 +0200 Subject: [PATCH 4/4] build: bump dependencies --- Cargo.lock | 117 +++++++++++++++++++++++--------- crates/recipe-parser/Cargo.toml | 2 +- 2 files changed, 86 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 038449e..a73cb4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,7 +119,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.75", + "syn", ] [[package]] @@ -159,6 +159,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "futures" version = "0.3.30" @@ -215,7 +221,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn", ] [[package]] @@ -254,6 +260,12 @@ dependencies = [ "slab", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "gloo-utils" version = "0.1.7" @@ -267,12 +279,28 @@ dependencies = [ "web-sys", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -336,6 +364,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -347,9 +384,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -407,11 +444,17 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + [[package]] name = "rstest" -version = "0.17.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de1bb486a691878cd320c2f0d319ba91eeaa2e894066d8b5f8f117c000e9d962" +checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" dependencies = [ "futures", "futures-timer", @@ -421,23 +464,27 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.17.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290ca1a1c8ca7edb7c3283bd44dc35dd54fdec6253a3912e201ba1072018fca8" +checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a" dependencies = [ "cfg-if", + "glob", + "proc-macro-crate", "proc-macro2", "quote", + "regex", + "relative-path", "rustc_version", - "syn 1.0.109", + "syn", "unicode-ident", ] [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -469,7 +516,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals 0.29.1", - "syn 2.0.75", + "syn", ] [[package]] @@ -495,7 +542,7 @@ checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn", ] [[package]] @@ -506,7 +553,7 @@ checksum = "e578a843d40b4189a4d66bba51d7684f57da5bd7c304c64e14bd63efbef49509" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn", ] [[package]] @@ -517,7 +564,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn", ] [[package]] @@ -549,9 +596,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -559,23 +606,29 @@ dependencies = [ ] [[package]] -name = "syn" -version = "2.0.75" +name = "tabwriter" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "a327282c4f64f6dc37e3bba4c2b6842cc3a992f204fa58d917696a89f691e5f6" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "unicode-width", ] [[package]] -name = "tabwriter" -version = "1.4.0" +name = "toml_datetime" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a327282c4f64f6dc37e3bba4c2b6842cc3a992f204fa58d917696a89f691e5f6" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "unicode-width", + "indexmap", + "toml_datetime", + "winnow", ] [[package]] @@ -600,14 +653,14 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals 0.28.0", - "syn 2.0.75", + "syn", ] [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" @@ -643,7 +696,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.75", + "syn", "wasm-bindgen-shared", ] @@ -665,7 +718,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/crates/recipe-parser/Cargo.toml b/crates/recipe-parser/Cargo.toml index 68cf2f4..4f3e12f 100644 --- a/crates/recipe-parser/Cargo.toml +++ b/crates/recipe-parser/Cargo.toml @@ -19,7 +19,7 @@ wasm-bindgen = {version = "0.2.92", optional = true} tsify = { version = "0.4.5", optional = true} [dev-dependencies] -rstest = "0.17.0" +rstest = "0.23.0" serde_json = "1.0" [lib]