Conversation
Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
…ll arities) Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
…egistry (WIP - investigating duplicate generation issue) Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
…to use ParserHelperRegistry Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
* Initial plan * Implement ISourceable for Always, Fail, Eof, Capture, Not, Discard, Optional Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com> * Implement ISourceable for Else, ElseError, Error family, and When Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com> * Implement ISourceable for Identifier, NonWhiteSpaceLiteral Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com> * Implement ISourceable for WhiteSpaceLiteral, WhiteSpaceParser, PatternLiteral, Seekable Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com> * Implement ISourceable for remaining parsers: If, StringLiteral, Separated, Select, Switch, WhenFollowedBy, WhenNotFollowedBy, TextBefore, WithWhiteSpaceParser, IParserAdapter, OneOf Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
…d performance - Updated various parser classes to replace tuple-based result handling with out parameters for success and value retrieval. - This change simplifies the code by eliminating the need for intermediate variable assignments and enhances readability. - Affected classes include Deferred, LeftAssociative, Not, OneOf, OneOrMany, Optional, Sequence, SequenceAndSkip, SequenceSkipAnd, SkipWhiteSpace, Then, Unary, When, ZeroOrMany, and ZeroOrOne.
…d readability and maintainability
|
@Genteure I fixed all the possible compilation issues, at least it works on NCalc which relies on compiled regexes, logging source gen and PolySharp. Just saying that Parlot's source generator will also invoke other source generator so it can build and run the host assembly so it can generate new code for this same host assembly. Not sure how to feel about it, but it seems to work. I am pushing a new version right now. @Bykiev Made some progress and hitting a problem with the outer LeftAssociative parser that throws an exception, I don't understand what it does, neither does the source gen ;) |
|
I was watching the repository so this is already in my inbox, but appreciate the update 🙂 |
|
Should the new version work with |
|
@gpetrou ignore this one. Parlot stubs this one, and logger generator too. It should just work, my benchmark project had one too and it works. |
|
Oh, I see. OK thanks. It seems to be missing the |
…proved performance and memory efficiency
# Conflicts: # src/Parlot/Fluent/LeftAssociative.cs # src/Parlot/Fluent/Unary.cs
|
@gpetrou I added a test with you sample, it's working fine. NCalc is also working correctly without crazy changes. All the things that needed to be altered were described with the analyzer so it was smooth. The most copmlicated was to make the grammar change based on external options, since this can't be done when the parser is constructed anymore, but it all works out with the available parsers combinators (Select). ncalc/ncalc#533 |
- Replace environment variable checks (MSBuildExtensionsPath, MSBUILD_EXE_PATH) with DesignTimeBuild property - DesignTimeBuild is the official MSBuild property set during design-time builds (IDE IntelliSense) - Simplifies detection logic and improves reliability - Prevents assembly loading conflicts when running additional generators in IDE contexts
Hmm, I still observe an error with the latest preview 8. #line 36 "D:\Projects\ParlotWithSourceGenerator\ParlotWithSourceGenerator\MyParser.cs"
private static global::ParlotWithSourceGenerator.MyParser.NodeBase _Parser_lambda0(global::System.ValueTuple<global::System.Int64, global::System.Int64> items) => new BasicNode<TComparand>(
items.Item2);
#line defaultI guess the issue is that we have |
|
@sebastienros this looks awesome 🤩 what's the current state of this? |
|
@slang25 this only thing to add, if anything, is to improve the fact that an hint is displayed in VS or VS Code on the method with the attribute, but couldn't find a way to detect it without impacting the local build (detecting when msbuild is used). It's a niche scenario, and not breaking at all, but I'd prefer to fix it before. This PR is already testable using the published preview. |
@lahma @jbevain just to show you how it's done.
The logic is not part of the source generator and is driven by user code execution, not code syntax.
The source generator has to run the code first to get the object describing the grammar. Then evaluates the generated tree, not the code itself. That requires the code to be in a static method but that's totally fine. If the grammar needs options then one can generate different parser for each option, and reuse grammar portions across.