Small C# demo project for the second video example.
Who this is for: developers who want a compact, practical starting point for using parsers generated by the parol parser generator in C#.
It demonstrates how to parse and evaluate simple human-readable filter expressions (for example status, owner, priority, or score checks) as a foundation for ideas like search filters, rule-based views, and API query conditions.
Set-Location "<Path to repository>\FilterQueryDemo"
dotnet build filter_query_demo.csproj cd "<Path to repository>/FilterQueryDemo"
dotnet build filter_query_demo.csprojSet-Content -Path .\test1.txt -Value 'status = "open" and owner = "sam"'
dotnet run -- .\test1.txtprintf '%s' 'status = "open" and owner = "sam"' > ./test1.txt
dotnet run -- ./test1.txtExpected output line:
Evaluation result: true
Set-Content -Path .\test2.txt -Value 'priority >= 3 or score > 90'
dotnet run -- .\test2.txtprintf '%s' 'priority >= 3 or score > 90' > ./test2.txt
dotnet run -- ./test2.txtExpected output line:
Evaluation result: true
Set-Content -Path .\test3.txt -Value 'not archived and (priority >= 3 or owner = "max")'
dotnet run -- .\test3.txtprintf '%s' 'not archived and (priority >= 3 or owner = "max")' > ./test3.txt
dotnet run -- ./test3.txtExpected output line:
Evaluation result: false
- Parsing is still performed by the generated
parolparser. - The boolean result is printed by the demo evaluator in
FilterQueryEvaluator.cs. - The types
FilterIdentifier,FilterNumberandFilterStringare used to demonstrate the use of the%nt_typedirective to provide conversion to user provided types in the generated parser. Please look for these directives infilter_query_demo.par - The default evaluation context is defined in
filter_query_demo_actions.cs.
.\run_demo_cases.ps1bash ./run_demo_cases.sh.\run_demo_cases_clean.ps1bash ./run_demo_cases_clean.sh