Prepare Parser for scripting#694
Conversation
c9c9e21 to
54b1b2c
Compare
|
Awesome, I suggest putting all those classes internal? |
NBitcoin/Scripting/Parser/IInput.cs
Outdated
|
|
||
| namespace NBitcoin.Scripting.Parser | ||
| { | ||
| public interface IInput<out T> |
There was a problem hiding this comment.
This one should be internal ?
There was a problem hiding this comment.
Also, I would suggest to inherit from IEnumerator<out T> and remove Advance/GetCurrent/GetNext.
Then just make methods returning IInput<out T> before implement IEnumerable<T> and return IInput<T> .
The nice thing is that people can use foreach then.
There was a problem hiding this comment.
Nice. I wonder why this didn't come up to my mind...
There was a problem hiding this comment.
I've been trying to inherit from IEnumerator. But it is not working well :(
It is because that Input for Parser combinator must be immutable. (Advance() will create another instance each time it proceeds)
IEnumerator is only for mutable object.
I think inheriting from IEnumerable and delegate GetEnuemrator call to underlying Source object is enough.
2fc36c9 to
493ec7f
Compare
Not sure I agree. You could create a specific Enumerator class for this type which is mutable without making your type mutable. |
You mean make my class inherit from |
|
@joemphilips if my suggestion is not really used and does not make the code more visible, then you can just roll it back. |
| { | ||
| return from nothing in Return<char, string>("") | ||
| // dummy so that CultureInfo.CurrentCulture is evaluated later | ||
| from dot in String((ci ?? CultureInfo.CurrentCulture).NumberFormat.NumberDecimalSeparator).Text() |
There was a problem hiding this comment.
oh no, never use CurrentCulture!
There was a problem hiding this comment.
I've drop the support for culture-aware decimal.
now it uses InvariantCulture only.
|
Oh actually it is used in the test, seems better. |
|
Tests failing rebasing on top of master should fix it |
fd4b479 to
7b28689
Compare
|
Rebased but not fixed. It seems that some parts of codes are using obsolete Should I fix on my side? |
|
Yes you can fix... but so strange, on master the build is passing! |
63a7d08 to
4453369
Compare
4453369 to
323e787
Compare
* Since in netstandard1.3, string-as-enumerable should be treated bit differently.
323e787 to
961a6f4
Compare
|
What should I review and merge in priority after @joemphilips ? |
|
I want you to take a look for #696 since the spec is well formalized than #695 , and it has some changes to an existing objects. But honestly, I myself am not in hurry so please take your time. @NicolasDorier |
Original PR is #684
This creates
NBitcoin.Scripting.Parsernamespace, and puts Monadic Parser combinator for internal usage.It does not affect the library's public AP,I nor it has tests. Tests will be done in following PRs.
The API almost completely follows those of Sprache, the biggest difference is that it is generalized against its input type. (Sprache only allows string as an input, but this one will take arbitrary
IEnumerable<T>for input.) This is crucial for Miniscript decompilation.This might be a good candidate for using
Span<T>as an input type to improve the speed. But I didn't want to do an early optimization so I didn't.