-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Defer codePointWhere and charWhere description
Improving performance when those descriptions are not needed
- Loading branch information
Showing
11 changed files
with
112 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package name.rayrobdod.stringContextParserCombinator | ||
|
||
private[stringContextParserCombinator] | ||
final case class Expecting[Pos]( | ||
val description:ExpectingDescription, | ||
val position:Pos, | ||
) { | ||
def where(condition:ExpectingDescription) = | ||
new Expecting(description.where(condition), position) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package name.rayrobdod.stringContextParserCombinator | ||
|
||
/** Represents a textual description of under what conditions a parser would return success */ | ||
private[stringContextParserCombinator] | ||
sealed abstract class ExpectingDescription { | ||
private[stringContextParserCombinator] | ||
def where(condition:ExpectingDescription):ExpectingDescription | ||
private[stringContextParserCombinator] | ||
def render:String | ||
} | ||
|
||
private[stringContextParserCombinator] | ||
object ExpectingDescription { | ||
def apply(backing: String): ExpectingDescription = { | ||
new ExpectingDescription { | ||
override def where(condition:ExpectingDescription):ExpectingDescription = { | ||
ExpectingDescription(s"${this.render} where ${condition.render}") | ||
} | ||
override def render: String = { | ||
backing | ||
} | ||
override def toString: String = { | ||
s"ExpectingDescription.eager($backing)" | ||
} | ||
} | ||
} | ||
|
||
def delayed(backingFn: => String): ExpectingDescription = { | ||
new ExpectingDescription { | ||
private lazy val backingValue = backingFn | ||
override def where(condition:ExpectingDescription):ExpectingDescription = { | ||
ExpectingDescription.delayed(s"${this.render} where ${condition.render}") | ||
} | ||
override def render: String = { | ||
backingValue | ||
} | ||
override def toString: String = { | ||
s"ExpectingDescription.delayed(<fn>)" | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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