-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
.Compile()
causes "The parser needs to implement ISkippableSequenceParser
" exception.
#108
Comments
.Compile()
causes The parser needs to implement ISkippableSequenceParser
exception..Compile()
causes "The parser needs to implement ISkippableSequenceParser
" exception.
Then it's a bug in the compilation code. I did some changes recently for some compiled parsers, could you try to reference the source code and use that instead of the nuget package to see if it still reproes? If you can remove as much as possible and it still fails that would help isolate the problem. I will also try that on my side. I believe you are not blocked as long as you don't try to use the compiled version, it's only slightly faster with compilation. |
It's related to a sequence, a list of And() calls. Should be easy to isolate on my side. |
Yes, it's a breaking change but it makes ZeroOrOne easier to use. |
Good morning, Solved the compilation error with var mandatoryIntWithOptionalDecimal =
Terms.Integer(NumberOptions.AllowSign)
.AndSkip(Terms.Char('.'))
.And(ZeroOrOne(Terms.Integer()))
.Then(l=>new ValueTuple<OptionalResult<long>, OptionalResult<long>>(new OptionalResult<long>(true, l.Item1), l.Item2));
var optionalIntWithMandatoryDecimal =
ZeroOrOne(Terms.Integer(NumberOptions.AllowSign))
.AndSkip(Terms.Char('.'))
.And(Terms.Integer())
.Then(l=>new ValueTuple<OptionalResult<long>, OptionalResult<long>>(l.Item1, new OptionalResult<long>(true, l.Item2)));
var decimalPointParser =
OneOf(mandatoryIntWithOptionalDecimal, optionalIntWithMandatoryDecimal)
.AndSkip(ZeroOrOne(Terms.Text("e", true)))
.And(ZeroOrOne(Terms.Integer(NumberOptions.AllowSign)))
.Then<LogicalExpression>((context, x) =>
{
var useDecimalAsDefault = ((LogicalExpressionParserContext)context).UseDecimalsAsDefault;
if (useDecimalAsDefault)
{
decimal decimalValue;
if (x.Item3.HasValue)
decimalValue = Convert.ToDecimal(x.Item1 + "." + x.Item2 + "e" + x.Item3,
CultureInfo.InvariantCulture);
else
decimalValue = Convert.ToDecimal(x.Item1 + "." + x.Item2, CultureInfo.InvariantCulture);
return new ValueExpression(decimalValue);
}
double doubleValue;
if (x.Item3.HasValue)
doubleValue = Convert.ToDouble(x.Item1 + "." + x.Item2 + "e" + x.Item3,
CultureInfo.InvariantCulture);
else
doubleValue = Convert.ToDouble(x.Item1 + "." + x.Item2, CultureInfo.InvariantCulture);
return new ValueExpression(doubleValue);
}); But after calling |
Currently working on it, I have a minimal repro, but I notice you are using Bote that between |
Didn't create a branch and PR by mistake, but it's fixed, understood the problem and added some tests. |
Good night!
I changed the following parser from this:
To this:
And this caused the following exception:
The parser needs to implement
ISkippableSequenceParser
exception.But when I don't compile the parser with
.Compile()
everything works. Is this expected behavior?The text was updated successfully, but these errors were encountered: