Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add double and float parsers #84

Merged
merged 3 commits into from
Feb 15, 2024
Merged

Add double and float parsers #84

merged 3 commits into from
Feb 15, 2024

Conversation

sebastienros
Copy link
Owner

No description provided.

/// <summary>
/// Builds a parser that matches a floating point number represented as a <lang cref="float"/> value.
/// </summary>
public Parser<float> Float() => new FloatLiteral();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how often these get called, but could also return FloatLiteral.Default which is internal readonly static field if these don't have state

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A static instance would work, but it's only created a few times in a parser. I am not even sure you would call the same "Float" in multiple places, for instance you'd have a single higher level parser which would use it, like a PrimaryExpression made of integers, floats, strings ...

So I don't think it's worth it. I'll check others though.

@sebastienros sebastienros merged commit c32c0c3 into main Feb 15, 2024
1 check passed
@sebastienros sebastienros deleted the sebros/floats branch February 15, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants