Open j-mie6 opened 1 year ago
I also want to deal with the tab situation properly.
Here's a sketch of an implementation that might work better:
parsley.PositionConfig
, with def startLine: Int
, def startCol: Int
, def tabCol(col: Int): Int
.
Then, this could also expose a def updatePos(c: Char, pos: PosState): Unit
(and one for codepoints, for #129?) with a default implementation using tabCol
, checking for newline etc. This could be overriden by a user who wants the extra control over what characters do what.PosState
is an abstract class at the parsley level, but is sealed within parsley
(abstract class PosState private [parsley]
): this
way we control the sub-classes, and the user doesn't know what they are. This exposes def getCol
, def setCol
, def getLine
, def setLine
, methods: these are called by updatePos
. The Context
implements this itself.updatePos
hot. This may involve keeping a helper in Context
that forwards to the config, which then bounces back. We absolutely want JIT to specialise this to whatever the user has come up with.Hopefully, this design gives maximal control to the user, and minimal overhead to the internals. There will be a new implicit parameter added to parse
, which is the PositionConfig
.
Parsley 5 will provide an opportunity to address some of the pain points of the API once again. This list may evolve over time.
In addition to #172, #184, and #168:
Major Changes
parsley.io._
, and instead move the implicit class withinobject Parsley
. This will go with aextends PlatformSpecific
trick to allow for theio
stuff to be enabled forjvm
andnative
but notjs
but not require any imports. RenameparseFromFile
toparse
.Lexer
hierarchy somewhat: the plainobjects
aren't really buying us much other than indirection:numeric
,text
etc can just go I think.attempt
toatomic
(after seeking feedback on this from other experts and users), since I think it makes much more sense as a name and clears up some misconceptions: this might even be done pre-5, but with the binary compatible change.>>=
,getOrElse
,join
:>>=
is provided byparsley-cats
anyway, and is not something to encourage (same withjoin
); andgetOrElse
is a misleading name, so this is going.attemptChoice
, I don't want to encourage that in the API.TokenSpan
from the API, and changeLexToken
to useoffset
instead of position, wayyyyyy simpler.traverse
to be curried, with function as second set of brackets.hide
so that it totally suppresses the errors underneath: #193 and #198 have already laid the groundwork for this to happen, sincelabel("")
is no longer legal. Instead.hide
should be its own combinator independent oflabel
itself -- this is an outdated notion now. Additionally, clean up the various overloads: it should be a single label combinator requiring at least one label, all non-empty.verifiedUnexpected
->verifiedExplain
, with the argumentless variant remaining as is: newverifiedUnexpected
variants to be introduced in 5.1?genericbridges
renamed togeneric
, we don't know what else might end up there, and the name is a bit nicer.Specialised
error toSpecialized
LexToken
can swap to the simpler definition from thesis, andTokenSpan
can be removed.many
,some
, andeof
to move toParsley
-- they are definitely core, and I want to cut down on imports (this is in tandem with #141)more
andbetween
, they just aren't useful.skip
variants of the combinators, includingskipMany
,skipSome
,skip
,range_
; but notforP
, as this optimisation cannot recognise "dead registers".sequence
should be given an extra argument, same withtraverse
.exactly
should have ann > 1
invariant.manyUntil
andsomeUntil
are unusual names, they should be calledmanyTill
andsomeTill
for consistency with all the other parsecs! (this change will affectparsley-cats
, renamecount
andcount1
tocountMany
andcountSome
.implicits
packages/object intosyntax
? Gives us better "parity" with the typelevel style.ifP
,guard
,when
, andwhileP
to all use anS
postfixInteger
,Real
,String
,Character
to all have aParsers
suffix: it'll be better for clashes with Scala and important forgigaparsec
.multiMap
andsingleMap
in theLexer
config, they can just be merged into amapping
instead?predicate
into a package, as opposed to an object.Ops
et alparsley.implicits.combinator
and moveparsley.extension
asparsley.syntax.extension
atomicChoice
.Failure
as a proper case class againErrorBuilder
softKeyword
have the maximal munch behaviour, likesoftOperator
.Minor Changes
verified
andprevent
though. Note that the deprecated constructors intoken.errors
will be reinstatedimport parsley.quickstart.*
or something to cut down on theparsley.Parsley, Parsley.*, parsley.character.*, parsley.combinator.*
import pattern..all
object in there to export out thezipped
andlift
syntaxes, perhaps?