{"id":31892513,"url":"https://github.com/fs7744/lmzzz","last_synced_at":"2026-07-13T21:31:06.805Z","repository":{"id":317025413,"uuid":"1065688961","full_name":"fs7744/Lmzzz","owner":"fs7744","description":".net fluent parser","archived":false,"fork":false,"pushed_at":"2026-01-02T08:57:56.000Z","size":337,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-19T18:07:12.398Z","etag":null,"topics":["parser","parser-framework","parser-library","template","template-engine"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fs7744.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T08:22:30.000Z","updated_at":"2026-01-02T08:57:59.000Z","dependencies_parsed_at":"2025-09-28T11:36:56.142Z","dependency_job_id":"75a32f04-7bff-4dc7-87e8-538b18f4c799","html_url":"https://github.com/fs7744/Lmzzz","commit_stats":null,"previous_names":["fs7744/lmzzz"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fs7744/Lmzzz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fs7744%2FLmzzz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fs7744%2FLmzzz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fs7744%2FLmzzz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fs7744%2FLmzzz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fs7744","download_url":"https://codeload.github.com/fs7744/Lmzzz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fs7744%2FLmzzz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35437763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","parser-framework","parser-library","template","template-engine"],"created_at":"2025-10-13T08:51:56.360Z","updated_at":"2026-07-13T21:31:06.798Z","avatar_url":"https://github.com/fs7744.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lmzzz\r\n\r\nLmzzz (Let me zzz) 是一个简单、轻量的辅助实现解析器的.NET 框架, \r\n\r\n让大家可以类函数或Fluent形式贴近 ABNF 格式实现语法定义。\r\n\r\n（PS：目前暂时只支持 string解析，大多实现参考于[Parlot](https://github.com/sebastienros/parlot)）\r\n\r\n## Getting Started\r\n\r\n首先引入命名空间\r\n\r\n``` csharp\r\nusing Lmzzz.Chars.Fluent;\r\nusing static Lmzzz.Chars.Fluent.Parsers;\r\n```\r\n\r\n然后就可以实现相关语法定义，如下是 一个完整的 json 解析器定义\r\n\r\n\r\n``` csharp\r\nusing Lmzzz.Chars.Fluent;\r\nusing static Lmzzz.Chars.Fluent.Parsers;\r\n\r\nnamespace Samples.Json;\r\n\r\npublic class JsonParser\r\n{\r\n    public static readonly Parser\u003cIJson\u003e Json;\r\n\r\n    static JsonParser()\r\n    {\r\n        var lBrace = IgnoreSeparator(Char('{'));\r\n        var rBrace = IgnoreSeparator(Char('}'));\r\n        var lBracket = IgnoreSeparator(Char('['));\r\n        var rBracket = IgnoreSeparator(Char(']'));\r\n        var colon = IgnoreSeparator(Char(':'));\r\n        var comma = IgnoreSeparator(Char(','));\r\n        var nullv = IgnoreSeparator(Text(\"null\")).Then\u003cIJson\u003e(static s =\u003e JsonNull.Value);\r\n        var boolv = IgnoreSeparator((Text(\"true\", true)).Then\u003cIJson\u003e(static s =\u003e JsonBool.True))\r\n                .Or(IgnoreSeparator(Text(\"false\", true)).Then\u003cIJson\u003e(static s =\u003e JsonBool.False));\r\n\r\n        var number = Decimal().Then\u003cIJson\u003e(static s =\u003e new JsonNumber(s));\r\n\r\n        var str = String();\r\n\r\n        var jsonString =\r\n            str\r\n                .Then\u003cIJson\u003e(static s =\u003e new JsonString(s.ToString()));\r\n\r\n        var json = Deferred\u003cIJson\u003e();\r\n\r\n        var jsonArray =\r\n            Between(lBracket, Separated(comma, json), rBracket)\r\n                .Then\u003cIJson\u003e(static els =\u003e new JsonArray(els));\r\n\r\n        var jsonMember =\r\n            str.And(colon).And(json)\r\n                .Then(static member =\u003e new KeyValuePair\u003cstring, IJson\u003e(member.Item1.ToString(), member.Item3));\r\n\r\n        var jsonObject =\r\n            Between(lBrace, Separated(comma, jsonMember), rBrace)\r\n                .Then\u003cIJson\u003e(static kvps =\u003e new JsonObject(new Dictionary\u003cstring, IJson\u003e(kvps)));\r\n\r\n        Json = json.Parser = jsonString.Or(jsonArray).Or(jsonObject).Or(nullv).Or(boolv).Or(number);\r\n        Json = Json.Eof();\r\n    }\r\n\r\n    public static IJson Parse(string input)\r\n    {\r\n        if (Json.TryParse(input, out var result, out _))\r\n        {\r\n            return result;\r\n        }\r\n        else\r\n        {\r\n            return null;\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n## 简单的模板引擎\r\n\r\n为了展示解析器的方便，同时也实现了一个简单的模板引擎\r\n\r\n### 对象取值\r\n\r\n``` csharp\r\n// data: {A: { Age : 15}, B: [ 2, 3, 4]}\r\n\r\n// {{FieldName.FieldName}}\r\n{{ A.Age }}  // result: 15\r\n\r\n// index {{Array.Index}}\r\n{{ B.0 }} // result: 2\r\n{{ B.1 }} // result: 3\r\n{{ B.99 }} // result: null\r\n\r\n```\r\n\r\n### if\r\n\r\n``` csharp\r\n\r\n{{ if(4 == Int || 5 != 6) }}\r\nxx \r\n{{ elseif( true \u0026\u0026 false) }}\r\nyy\r\n{{ else }}\r\nzz\r\n{{endif}}\r\n\r\n```\r\n\r\n### for\r\n\r\n``` csharp\r\n\r\n{{  for(自定义值名,自定义索引名 in Array) }}\r\n\r\n{{ 自定义值名 }}\r\n\r\n{{endfor}}\r\n\r\n```\r\n\r\n## 简单性能展示\r\n\r\n对于简单场景做了一些性能比较\r\n\r\n#### 模板引擎\r\n\r\n```\r\n\r\nBenchmarkDotNet v0.15.7, Windows 11 (10.0.26100.6584/24H2/2024Update/HudsonValley)\r\nIntel Core i7-10700 CPU 2.90GHz, 1 CPU, 16 logical and 8 physical cores\r\n.NET SDK 10.0.100\r\n  [Host]     : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3\r\n  DefaultJob : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3\r\n\r\n\r\n```\r\n| Method            | Mean        | Error     | StdDev    | Gen0   | Gen1   | Allocated |\r\n|------------------ |------------:|----------:|----------:|-------:|-------:|----------:|\r\n| ForNoCache        |  5,386.7 ns | 104.63 ns |  92.75 ns | 0.4730 |      - |    3992 B |\r\n| ForCached         |    446.1 ns |   2.23 ns |   1.98 ns | 0.1030 |      - |     864 B |\r\n| ScribanForNoCache | 23,335.6 ns | 234.61 ns | 183.17 ns | 5.0049 | 0.3662 |   42439 B |\r\n| ScribanForCached  | 13,213.1 ns | 251.76 ns | 279.83 ns | 4.2114 | 0.3662 |   35594 B |\r\n| FluidForNoCache   |  3,423.2 ns |  19.39 ns |  18.14 ns | 0.3510 |      - |    2944 B |\r\n| FluidForCached    |    961.4 ns |   4.18 ns |   3.71 ns | 0.1526 |      - |    1280 B |\r\n|                   |             |           |           |        |        |           |\r\n| IfNoCache         |  9,580.2 ns |  78.95 ns |  69.99 ns | 0.6714 |      - |    5736 B |\r\n| IfCached          |    273.2 ns |   4.33 ns |   4.05 ns | 0.0763 |      - |     640 B |\r\n| ScribanIfNoCache  | 20,510.4 ns | 363.77 ns | 533.21 ns | 4.8828 | 0.3662 |   41182 B |\r\n| ScribanIfCached   | 11,424.6 ns | 157.37 ns | 147.20 ns | 4.0283 | 0.3662 |   33788 B |\r\n| FluidIfNoCache    |  4,670.4 ns |  17.76 ns |  15.75 ns | 0.3738 |      - |    3168 B |\r\n| FluidIfCached     |    405.3 ns |   3.13 ns |   2.93 ns | 0.0572 |      - |     480 B |\r\n\r\n\r\n#### json \r\n\r\n```\r\n\r\nBenchmarkDotNet v0.15.7, Windows 11 (10.0.26100.6584/24H2/2024Update/HudsonValley)\r\nIntel Core i7-10700 CPU 2.90GHz, 1 CPU, 16 logical and 8 physical cores\r\n.NET SDK 10.0.100\r\n  [Host]   : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3\r\n  ShortRun : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3\r\n\r\nJob=ShortRun  IterationCount=3  LaunchCount=1  \r\nWarmupCount=3  \r\n\r\n```\r\n| Method                  | Mean       | Error       | StdDev    | Ratio | RatioSD | Gen0    | Gen1   | Allocated | Alloc Ratio |\r\n|------------------------ |-----------:|------------:|----------:|------:|--------:|--------:|-------:|----------:|------------:|\r\n| BigJson_ParlotCompiled  | 125.121 μs |  16.0291 μs | 0.8786 μs |  1.00 |    0.01 | 11.2305 | 1.4648 |  91.76 KB |        1.00 |\r\n| BigJson_Lmzzz           | 100.051 μs | 142.9565 μs | 7.8359 μs |  0.80 |    0.05 | 21.1182 | 3.1738 | 173.36 KB |        1.89 |\r\n| BigJson_Parlot          | 126.344 μs |  38.5755 μs | 2.1145 μs |  1.01 |    0.02 | 11.2305 | 1.4648 |  91.76 KB |        1.00 |\r\n| BigJson_Newtonsoft      |  97.092 μs |   5.1302 μs | 0.2812 μs |  0.78 |    0.01 | 24.7803 | 7.3242 |  203.1 KB |        2.21 |\r\n| BigJson_SystemTextJson  |  19.048 μs |   3.2110 μs | 0.1760 μs |  0.15 |    0.00 |  2.9297 | 0.2747 |  24.12 KB |        0.26 |\r\n|                         |            |             |           |       |         |         |        |           |             |\r\n| DeepJson_ParlotCompiled |  53.866 μs |   8.5671 μs | 0.4696 μs |  1.00 |    0.01 | 12.0239 | 1.2817 |  98.32 KB |        1.00 |\r\n| DeepJson_Lmzzz          |  71.322 μs |   9.0438 μs | 0.4957 μs |  1.32 |    0.01 | 15.1367 | 1.3428 | 124.37 KB |        1.26 |\r\n| DeepJson_Parlot         |  52.478 μs |   8.7423 μs | 0.4792 μs |  0.97 |    0.01 | 12.0239 | 1.2817 |  98.32 KB |        1.00 |\r\n| DeepJson_Newtonsoft     |  65.771 μs |  10.7962 μs | 0.5918 μs |  1.22 |    0.01 | 21.8506 | 6.4697 | 179.13 KB |        1.82 |\r\n| DeepJson_SystemTextJson |  77.508 μs |   3.3456 μs | 0.1834 μs |  1.44 |    0.01 |  2.4414 | 0.1221 |  20.24 KB |        0.21 |\r\n|                         |            |             |           |       |         |         |        |           |             |\r\n| LongJson_ParlotCompiled |  86.733 μs |  24.4731 μs | 1.3415 μs |  1.00 |    0.02 | 14.4043 | 2.8076 | 118.34 KB |        1.00 |\r\n| LongJson_Lmzzz          |  83.418 μs |  23.3307 μs | 1.2788 μs |  0.96 |    0.02 | 20.7520 | 4.1504 | 170.28 KB |        1.44 |\r\n| LongJson_Parlot         |  83.721 μs |   8.0349 μs | 0.4404 μs |  0.97 |    0.01 | 14.4043 | 2.8076 | 118.34 KB |        1.00 |\r\n| LongJson_Newtonsoft     |  81.515 μs |  19.5927 μs | 1.0739 μs |  0.94 |    0.02 | 24.7803 | 7.4463 | 202.68 KB |        1.71 |\r\n| LongJson_SystemTextJson |  15.643 μs |   1.4569 μs | 0.0799 μs |  0.18 |    0.00 |  2.9297 | 0.2747 |  24.12 KB |        0.20 |\r\n|                         |            |             |           |       |         |         |        |           |             |\r\n| WideJson_ParlotCompiled |  55.410 μs |  31.9426 μs | 1.7509 μs |  1.00 |    0.04 |  4.9438 | 0.4883 |  40.55 KB |        1.00 |\r\n| WideJson_Lmzzz          |  40.326 μs |  12.5477 μs | 0.6878 μs |  0.73 |    0.02 | 11.2915 | 1.0986 |   92.5 KB |        2.28 |\r\n| WideJson_Parlot         |  53.288 μs |   2.2645 μs | 0.1241 μs |  0.96 |    0.03 |  4.9438 | 0.4883 |  40.55 KB |        1.00 |\r\n| WideJson_Newtonsoft     |  47.165 μs |   0.5885 μs | 0.0323 μs |  0.85 |    0.02 | 13.0615 | 2.9297 | 106.72 KB |        2.63 |\r\n| WideJson_SystemTextJson |   8.270 μs |   1.6550 μs | 0.0907 μs |  0.15 |    0.00 |  1.9684 | 0.0763 |  16.12 KB |        0.40 |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffs7744%2Flmzzz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffs7744%2Flmzzz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffs7744%2Flmzzz/lists"}