-
Notifications
You must be signed in to change notification settings - Fork 22
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
Parsley 4 Major Changes #98
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Removed redundant parameter in expression, whoops! * Fixed for scala 3... I think they have bugs with co-variance... * Modernised the design of the precedence, this new scheme works a bit nicer on Scala 3 * Updated documentation
* Removed strictness on main non-operator combinators * User API is fully strict now, internal is lazy * Fixed 2.12 * Unary AST-nodes strict * Amazing, looks like we've hit a Scala 3 bug... reverting * uncurried Binary * fully strict left on Binary
…apshot names are more faithful to the semver. Version names are checked before release
…, implemented getMax radix method.
* Broke out into infix and chain * Make zipped strict, and added mixed precedence
…ondition that residual input is non-empty
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR consolidates the Parsley 4 major API changes ready for the eventual release of next release series.
The scope of Parsley 4's changes are massive: probably the largest shift in Parsley's history! The aims of this project have been the following:
User-Facing Changes
Major Changes
<\>
combinator, which both had an inappropriate associativity, and encouraged an overuse ofattempt
unsafeLabel
, which leveraged the previously unsound error message system of pre-2.6.0: this just simply isn't needed, and optimisations oflabel
in the backend more than make up for its loss.unsafe
API in general: none of this functionality is required, and causes a variety of legacy code maintenance problemsLazyParsley
extension class still exists, and it supports theunary_~
combinator to make a parser lazy for use in the fully strictzipped
combinators. As a result, the structure of the library is simplified, with all the combinators defined as methods onParsley
itself.infix
with the homogeneous ones inchain
.cast
combinator, as the register restriction is lifted, and it can be a misleading combinator.Parsley.sequence
->combinator.sequence
Parsley.traverse
->combinator.traverse
Parsley.skip
->combinator.skip
Parsley.void
made into a method onParsley
itselfcharacter.anyChar
->character.item
combinator.repeat
->combinator.exactly
combinator.optionally
->combinator.optionalAs
Parsley.LazyMapParsley
->extension.HaskellStyleMap
Parsley.LazyChooseParsley
->extension.LazyChooseParsley
fail
must receive at least one argumentstring
no longer accepts the empty string (there is no reason to do this!)collectMsg
now accepts 1 or more message argumentscollectMsg
andguardAgainst
now produceSeq[String]
as the messages (this should be non-empty!)precedence
requires at least one atom and one level, this also allows for vararg versions in the other directionzipped
combinators are now fully strict, andLazyZipped
has been removed entirelyIndexedSeq[Char]
) at fail position additionally given the amount of input the parser tried to parse unsuccessfully.Major
parsley.token
ChangesBitSet
andImpl
LanguageDef
and replace withLexicalDesc
and friendsLexer
into categories, which can share functionality with each other:numeric
(tests forCombined
required)text
symbol
names
space
separators
enclosing
Minor Changes
fresh
combinator, for generation of unique results frompure
strings
combinator, which efficiently parses one of a set of stringsstrings
combinator, which efficiently parses one a mapping of strings to other parsersstringOfMany
andstringOfSome
combinators, which allow for efficient string construction, instead of the old.map(_.mkString)
idiom onmany
orsome
|
combinator aliasfilterWith
back onto the APIcombinator.ifP
extensions.OperatorSugar
which comes with a few operators inspired by the SPC librarynewReg
andfillReg
combinatorsforP
andforP_
combinatorsforYieldP
, andforYieldP_
combinatorsmapFilter
combinatorParserBridge0
throughParserBridge22
as well asParserSingletonBridge
for basic use of the Parser Bridge and Singleton Bridge patterns.ap1
throughap22
, which are logical precursors tolift1
tolift22
.markAsToken
andunexpectedWhen
combinators toparsley.errors.combinator
fail
andunexpected
should be able to specify the caret width of their error, for unexpected errors, widest now wins against ambiguity (docs required)Patch Changes
persist
<|>
combinator more consistent when the (internal)JumpTable
optimisation appliedlabel
act only on the first set of hints? mrkkrp/megaparsec#482.unexpected
,.!
,.collectMsg
,.guardAgainst
,.filter
,.collect
,.filterMap
,.filterOut
, and.filterNot
combinators now have amended semantics by default, and sets the caret width to be the thing that was parsed. (behaviour needs documentation)Other Changes
M.m.p
represents binary back-compat, source back-compat and then patch. This should make the library far more stable in the wild, and the policy is enforced by CI.Internal Changes
Cont
to not require a given result type at the operation level, this allows the same instance to be used in different placesStrictParsley
and a partially lazy AST calledLazyParsley
. This divides the work of processing a tree into a frontend and a backend. This improves performance and allows for more advanced use of mutable structure in the backend. This is also much more maintainable.parsley.internal.collections
<|>
and*>
,<*
nodes withChoice
andSeq
constructors, which can normalise the tree in linear time as opposed to polynomial time.CalleeSave
, which is a special case)Call
has been much more optimised, andGoSub
has been removed as a result: in general the return mechanism is greatly simplified and improvedContext#status
flag has been replaced byContext#good
andContext#running
, which allows for a tighter loop inContext#run()
. In addition,Context#fail()
can only be called whenContext#good
is already false: this avoids some redundant work being performed by failure handlers which re-fail.